Created
January 5, 2012 08:49
-
-
Save bdha/1564314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Determine which init system we're using and load daemontools for it. | |
init_system = File.readlink("/proc/1/exe") | |
case init_system | |
when /upstart/ | |
log "Using upstart" | |
cookbook_file "/etc/init/svscanboot.conf" do | |
source "upstart.svc" | |
owner "root" | |
group "root" | |
mode "0644" | |
end | |
execute "start_svscanboot" do | |
command "/sbin/initctl start svscanboot" | |
not_if "/sbin/initctl status svscanboot | /bin/grep running" | |
action :run | |
end | |
when /systemd/ | |
log "Using systemd" | |
cookbook_file "/etc/systemd/system/svscanboot.service" do | |
source "systemd.svc" | |
owner "root" | |
group "root" | |
mode "0755" | |
end | |
execute "start_svscanboot" do | |
command "/bin/systemctl start svscanboot.service" | |
not_if "/bin/systemctl status svscanboot.service | grep 'Active: active'" | |
action :run | |
end | |
when "/sbin/init" | |
log "Using init like a beard." | |
execute "add_svscanboot_inittab" do | |
command "/bin/echo SV:123456:respawn:/usr/local/bin/svscanboot >> /etc/inittab ; /sbin/telinit q" | |
not_if "/bin/grep 'SV:123456:respawn:/usr/local/bin/svscanboot' /etc/inittab" | |
action :run | |
end | |
else | |
log("No idea what init system we're using. That's not good.") { level :error } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment