Permalink
Browse files

Add gentoo support to runit cookbook. Authors: Darrin Eden, Michael Hale

  • Loading branch information...
1 parent c6a0114 commit 1ee0a783ae1b2a9b1966323c4377eede079d8e28 @mikehale mikehale committed with jtimberman Aug 26, 2010
Showing with 53 additions and 7 deletions.
  1. +4 −0 attributes/default.rb
  2. +4 −2 definitions/runit_service.rb
  3. +1 −1 metadata.rb
  4. +12 −4 recipes/default.rb
  5. +32 −0 templates/gentoo/runit-start.sh.erb
View
@@ -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
@@ -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
View
@@ -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
View
@@ -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
@@ -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")
@@ -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 },
@@ -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.