From e860e0293f3074baa399cd7d6f3af5463ce1f4f2 Mon Sep 17 00:00:00 2001 From: Benjamin Doherty Date: Thu, 19 Jul 2018 12:39:30 -0500 Subject: [PATCH] Add init.d script for Amazon Linux. --- libraries/provider_runit_service.rb | 2 +- templates/amazon/init.d.erb | 64 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 templates/amazon/init.d.erb diff --git a/libraries/provider_runit_service.rb b/libraries/provider_runit_service.rb index 3ed1661..3186ebe 100644 --- a/libraries/provider_runit_service.rb +++ b/libraries/provider_runit_service.rb @@ -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}") } diff --git a/templates/amazon/init.d.erb b/templates/amazon/init.d.erb new file mode 100755 index 0000000..85b508d --- /dev/null +++ b/templates/amazon/init.d.erb @@ -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. + +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 + +: +