File openstack-skeleton.init of Package openstack-suse

#!/bin/sh

### BEGIN INIT INFO
# Provides:          openstack-__COMPONENT__-__DAEMON__
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      __SHOULD__
# Should-Stop:       __SHOULD__
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: __DESC__
# Description:       __DESC__
### END INIT INFO

USER="openstack-__COMPONENT__"
FLAGFILE="/etc/__COMPONENT__/__COMPONENT__.conf"
LOGFILE="/var/log/__COMPONENT__/__DAEMON__.log"

[ -e "/etc/sysconfig/__COMPONENT__-__DAEMON__" ] && . "/etc/sysconfig/__COMPONENT__-__DAEMON__"
[ -e $LOGFILE ] || touch $LOGFILE && chown $USER. $LOGFILE

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

case "$1" in
    start)
	echo -n "Starting __COMPONENT__-__DAEMON__"
	startproc -s -u $USER -t ${STARTUP_TIMEOUT:-5} -q /usr/bin/__COMPONENT__-__DAEMON__ --flagfile=$FLAGFILE --logfile=$LOGFILE
        rc_status -v
        ;;
    stop)
	echo -n "Shutting down __COMPONENT__-__DAEMON__"
	killproc /usr/bin/__COMPONENT__-__DAEMON__
        rc_status -v
        ;;
    restart)
        $0 stop
	$0 start
	rc_status
        ;;
    reload)
        ;;
    status)
        echo -n "Checking __COMPONENT__-__DAEMON__"
	/sbin/checkproc /usr/bin/__COMPONENT__-__DAEMON__
	rc_status -v
        ;;
    condrestart|try-restart)
	if test "$1" = "condrestart"; then
		echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
	fi
	$0 status
	if test $? = 0; then
		$0 restart
	else
		rc_reset	# Not running is not a failure.
	fi
	rc_status
	;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
        exit 2
esac
exit $?