templates/etc/init.d/init.erb
#!/bin/sh
#
# ************************************
# Managed by Puppet AEM Module
# ************************************
#
#
# aem-<%= @name %>
#
# chkconfig 345 90 10
# description: Starts & Stops an AEM Instance configured/managed by Puppet.
#
### BEGIN INIT INFO
# Provides: AEM-<%= @name %>
# Required-Start: $network $named
# Required-Stop: $network $named
# Should-Start: AEM-<%= @name %>
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: This service manages an AEM instance.
### END INIT INFO
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
#
# init.d / servicectl compatibility (openSUSE)
#
if [ -f /etc/rc.status ]; then
. /etc/rc.status
rc_reset
fi
START="<%= @home %>/crx-quickstart/bin/start"
STOP="<%= @home %>/crx-quickstart/bin/stop"
STATUS="<%= @home %>/crx-quickstart/bin/status"
PROG="aem-<%= @name %>"
RETVAL=0
case "$1" in
start)
if [ -f $START ]; then
logger -s "Starting $PROG: "
/bin/su -l <%= @user %> -c $START
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${PROG}
fi
;;
stop)
if [ -f $STOP ]; then
logger -s "Stopping $PROG: "
/bin/su -l <%= @user %> -c $STOP
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${PROG}
fi
;;
restart)
$0 stop
$0 start
;;
status)
if [ -f $STATUS ]; then
logger -s "Checking status of $PROG: "
/bin/su -l <%= @user %> -c $STATUS
RETVAL=$?
[ $RETVAL -eq 0 ] && echo "$PROG is running"
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
;;
esac
exit $RETVAL