Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add init.d script for Amazon Linux. #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/provider_runit_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def whyrun_supported?
end

# lsb_init
if node['platform'] == 'debian' || node['platform'] == 'ubuntu'
if node['platform'] == 'debian' || node['platform'] == 'ubuntu' || node['platform'] == 'amazon'
ruby_block "unlink #{parsed_lsb_init_dir}/#{new_resource.service_name}" do
block { ::File.unlink("#{parsed_lsb_init_dir}/#{new_resource.service_name}") }
only_if { ::File.symlink?("#{parsed_lsb_init_dir}/#{new_resource.service_name}") }
Expand Down
64 changes: 64 additions & 0 deletions templates/amazon/init.d.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: <%= @name %>
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: initscript for runit-managed <%= @name %> service
### END INIT INFO

# Author: Chef Software, Inc. <[email protected]>

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="runit-managed <%= @name %>"
NAME=<%= @name %>
RUNIT=<%= @sv_bin %>
RUNIT_ARGS="<%= @sv_args %>"
SCRIPTNAME=<%= @init_dir %>$NAME

# Exit if runit is not installed
[ -x $RUNIT ] || exit 0

case "$1" in
start)
$RUNIT $RUNIT_ARGS start $NAME
;;
stop)
$RUNIT $RUNIT_ARGS stop $NAME
;;
status)
$RUNIT $RUNIT_ARGS status $NAME && exit 0 || exit $?
;;
reload)
$RUNIT $RUNIT_ARGS reload $NAME
;;
force-reload)
$RUNIT $RUNIT_ARGS force-reload $NAME
;;
force-stop)
$RUNIT $RUNIT_ARGS force-stop $NAME
;;
force-restart)
$RUNIT $RUNIT_ARGS force-restart $NAME
;;
force-shutdown)
$RUNIT $RUNIT_ARGS force-shutdown $NAME
;;
restart)
$RUNIT $RUNIT_ARGS restart $NAME
;;
shutdown)
$RUNIT $RUNIT_ARGS shutdown $NAME
;;
try-restart)
$RUNIT $RUNIT_ARGS try-restart $NAME
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|force-restart|force-shutdown|force-stop|restart|shutdown|try-restart}" >&2
exit 3
;;
esac

: