Skip to content

Commit f470817

Browse files
committed
Add init.d script for Amazon Linux.
Signed-off-by: Benjamin Doherty <[email protected]>
1 parent b3c3adc commit f470817

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

libraries/provider_runit_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def whyrun_supported?
224224
end
225225

226226
# lsb_init
227-
if node['platform'] == 'debian' || node['platform'] == 'ubuntu'
227+
if node['platform'] == 'debian' || node['platform'] == 'ubuntu' || node['platform'] == 'amazon'
228228
ruby_block "unlink #{parsed_lsb_init_dir}/#{new_resource.service_name}" do
229229
block { ::File.unlink("#{parsed_lsb_init_dir}/#{new_resource.service_name}") }
230230
only_if { ::File.symlink?("#{parsed_lsb_init_dir}/#{new_resource.service_name}") }

templates/amazon/init.d.erb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: <%= @name %>
4+
# Required-Start:
5+
# Required-Stop:
6+
# Default-Start:
7+
# Default-Stop:
8+
# Short-Description: initscript for runit-managed <%= @name %> service
9+
### END INIT INFO
10+
11+
# Author: Chef Software, Inc. <[email protected]>
12+
13+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
14+
DESC="runit-managed <%= @name %>"
15+
NAME=<%= @name %>
16+
RUNIT=<%= @sv_bin %>
17+
RUNIT_ARGS="<%= @sv_args %>"
18+
SCRIPTNAME=<%= @init_dir %>$NAME
19+
20+
# Exit if runit is not installed
21+
[ -x $RUNIT ] || exit 0
22+
23+
case "$1" in
24+
start)
25+
$RUNIT $RUNIT_ARGS start $NAME
26+
;;
27+
stop)
28+
$RUNIT $RUNIT_ARGS stop $NAME
29+
;;
30+
status)
31+
$RUNIT $RUNIT_ARGS status $NAME && exit 0 || exit $?
32+
;;
33+
reload)
34+
$RUNIT $RUNIT_ARGS reload $NAME
35+
;;
36+
force-reload)
37+
$RUNIT $RUNIT_ARGS force-reload $NAME
38+
;;
39+
force-stop)
40+
$RUNIT $RUNIT_ARGS force-stop $NAME
41+
;;
42+
force-restart)
43+
$RUNIT $RUNIT_ARGS force-restart $NAME
44+
;;
45+
force-shutdown)
46+
$RUNIT $RUNIT_ARGS force-shutdown $NAME
47+
;;
48+
restart)
49+
$RUNIT $RUNIT_ARGS restart $NAME
50+
;;
51+
shutdown)
52+
$RUNIT $RUNIT_ARGS shutdown $NAME
53+
;;
54+
try-restart)
55+
$RUNIT $RUNIT_ARGS try-restart $NAME
56+
;;
57+
*)
58+
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|force-restart|force-shutdown|force-stop|restart|shutdown|try-restart}" >&2
59+
exit 3
60+
;;
61+
esac
62+
63+
:
64+

0 commit comments

Comments
 (0)