forked from benhoskings/babushka-deps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monit.rb
54 lines (45 loc) · 1.38 KB
/
monit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
dep 'monit' do
if Babushka::SystemProfile.for_host.name == :precise
requires 'monit.managed', 'monit.link'
else
requires 'monit.src', 'autostart monit'
end
end
dep 'monit.managed'
dep 'monit.src' do
source 'https://github.com/downloads/protonet/custom_debs/monit_5.3.2-custom_v2_amd64.deb'
process_source {
sudo("rm -f /etc/monit/monitrc")
sudo("ln -s /etc/monit/monitrc /etc/monitrc")
sudo("dpkg -i --force-confnew --force-confmiss monit_5.3.2-custom_v2_amd64.deb")
}
provides ['monit']
end
dep "autostart monit" do
met? { !grep(/^[^#]*startup=0/, "/etc/default/monit") && File.exists?("/etc/init/monit.conf") }
meet {
change_line "startup=0", "startup=1", "/etc/default/monit"
# remove existing monit startscripts
sudo("update-rc.d -f monit remove")
unless(File.exists?("/etc/init/monit.conf"))
render_erb 'monit/monit.erb', :to => '/etc/init/monit.conf', :sudo => true
end
}
end
dep "remove autostart monit" do
requires 'monit'
requires 'rcconf.managed'
met? { shell("rcconf --list").val_for('monit') == 'off' }
meet {
sudo("update-rc.d -f monit remove")
}
end
dep "stop monit" do
requires 'monit'
met? { !system("/etc/init.d/monit status") }
meet { sudo("/etc/init.d/monit stop") }
end
dep 'monit.link' do
met? { File.exists?("/usr/sbin/monit") }
meet { sudo("ln -s /usr/bin/monit /usr/sbin/monit") }
end