lib/ruby_init_script/initscript.erb
#! /bin/sh -e
<%
require 'shellwords'
%>
### BEGIN INIT INFO
# Provides: <%= _name %>
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: <%= short_description %>
### END INIT INFO
<% for key, value in _env %>
export <%= key %>=<%= Shellwords.escape(value) %>
<% end %>
<%
command = [Shellwords.escape(_ruby_path), Shellwords.escape(_executable_path), "$1"].join(' ')
if _user != 'root'
command = "su -c \"#{command}\" #{_user}"
end
%>
case "$1" in
start|stop|restart|status)
cd <%= Shellwords.escape(_working_dir) %>
<%= command %>
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0