File openstack-trove-guestagent.init of Package openstack-trove-doc

#!/bin/sh

### BEGIN INIT INFO
# Provides:          openstack-trove-__NAME__
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      mysql postgresql rabbitmq-server
# Should-Stop:       mysql postgresql rabbitmq-server
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: OpenStack Orchestration (Trove) - __NAME__
# Description:       OpenStack Orchestration (Trove) - __NAME__
### END INIT INFO

DAEMON="guestagent"
USER="trove"
CONFIGFILE="/etc/trove/trove-guestagent.conf"
GUESTINFO="/etc/guest_info"
RUNDIR="/var/run/trove"

# $RUNDIR can be tmpfs, thus we have to create/own it here:
mkdir -p $RUNDIR && chown $USER. $RUNDIR

. /etc/rc.status

case "$1" in
    start)
	echo -n "Starting trove-$DAEMON"
        if [ ! -f $GUESTINFO ]; then
            echo -en "\nThe Trove Guestagent requires the $GUESTINFO file to have been created via nova file injection."
            rc_failed 1; rc_status -v; rc_exit;
        fi
        # must be readable by the trove user, but this file is injected by nova
        # and it only knows how to make 660 files owned by root
        chmod +r $GUESTINFO

	/sbin/startproc -q -s -u $USER /usr/bin/trove-$DAEMON --config-file=$GUESTINFO --config-file=$CONFIGFILE
        rc_status -v
        ;;
    stop)
	echo -n "Shutting down trove-$DAEMON"
	/sbin/killproc /usr/bin/trove-$DAEMON
        rc_status -v
        ;;
    restart)
        $0 stop
	$0 start
	rc_status
        ;;
    force-reload)
        $0 try-restart
        rc_status
        ;;
    reload)
        echo -n "Reload service trove-$DAEMON"
        rc_failed 3
        rc_status -v
        ;;
    status)
        echo -n "Checking for service trove-$DAEMON"
	/sbin/checkproc /usr/bin/trove-$DAEMON
	rc_status -v
        ;;
    try-restart|condrestart)
        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 # Remember status and be quiet
        ;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
        exit 1
        ;;
esac
rc_exit
openSUSE Build Service is sponsored by