Skip to content

Commit

Permalink
Add gentoo support to runit cookbook. Authors: Darrin Eden, Michael Hale
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehale authored and jtimberman committed Aug 27, 2010
1 parent c6a0114 commit 1ee0a78
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
4 changes: 4 additions & 0 deletions attributes/default.rb
Expand Up @@ -23,4 +23,8 @@
set[:runit][:chpst_bin] = "/usr/bin/chpst"
set[:runit][:service_dir] = "/etc/service"
set[:runit][:sv_dir] = "/etc/sv"
when "gentoo"
set[:runit][:sv_bin] = "/usr/bin/sv"
set[:runit][:service_dir] = "/etc/service"
set[:runit][:sv_dir] = "/var/service"
end
6 changes: 4 additions & 2 deletions definitions/runit_service.rb
Expand Up @@ -111,8 +111,10 @@
end
end

link service_dir_name do
to sv_dir_name
unless node[:platform] == "gentoo"
link service_dir_name do
to sv_dir_name
end
end

ruby_block "supervise_#{params[:name]}_sleep" do
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Expand Up @@ -6,7 +6,7 @@

recipe "runit", "Installs and configures runit"

%w{ ubuntu debian }.each do |os|
%w{ ubuntu debian gentoo }.each do |os|
supports os
end

Expand Down
16 changes: 12 additions & 4 deletions recipes/default.rb
Expand Up @@ -18,11 +18,12 @@
#

case node[:platform]
when "debian","ubuntu"
when "debian","ubuntu", "gentoo"
execute "start-runsvdir" do
command value_for_platform(
"debian" => { "default" => "runsvdir-start" },
"ubuntu" => { "default" => "start runsvdir" }
"ubuntu" => { "default" => "start runsvdir" },
"gentoo" => { "default" => "/etc/init.d/runit-start start" }
)
action :nothing
end
Expand All @@ -33,6 +34,13 @@
action :nothing
end

if platform? "gentoo"
template "/etc/init.d/runit-start" do
source "runit-start.sh.erb"
mode 0755
end
end

package "runit" do
action :install
if platform?("ubuntu", "debian")
Expand All @@ -44,8 +52,8 @@
"default" => :nothing,
"9.04" => :run,
"8.10" => :run,
"8.04" => :run
}
"8.04" => :run },
"gentoo" => { "default" => :run }
), resources(:execute => "start-runsvdir"), :immediately
notifies value_for_platform(
"debian" => { "squeeze/sid" => :run, "default" => :nothing },
Expand Down
32 changes: 32 additions & 0 deletions templates/gentoo/runit-start.sh.erb
@@ -0,0 +1,32 @@
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
after net
}

start() {
ebegin "Starting runsvdir"
start-stop-daemon --start --exec /usr/bin/runsvdir \
--background --make-pidfile \
--pidfile /var/run/runsvdir.pid -- <%= node.runit.sv_dir %>
eend $?
}

stop() {
local ret1 ret2
ebegin "Stopping runsvdir"
start-stop-daemon --stop --oknodo --pidfile /var/run/runsvdir.pid
ret1=$?
eend ${ret1}

ebegin "Stopping services and logging"
sv shutdown -w 10 <%= node.runit.sv_dir %>/*
ret2=$?
eend ${ret2}

return $((ret1+ret2))
}

0 comments on commit 1ee0a78

Please sign in to comment.