#! /bin/sh
### BEGIN INIT INFO
# Provides:          boss-testparticipant
# Required-Start:    $remote_fs rabbitmq
# Required-Stop:     $null
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: testparticipant service.
# Description:       BOSS participant testparticipant.
### END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="testparticipant service"
NAME=$0
SCRIPTNAME=/etc/init.d/$NAME
CONF=/etc/boss/boss-participant-testparticipant
PNAME=testparticipant

#
#       Function that starts the daemon/service.
#
d_start()
{
        if [ -f /var/run/$PNAME.pid ]; then
            echo -n " already running"
        else
            startproc /usr/bin/$PNAME.py -c $CONF
        fi
}

#
#       Function that stops the daemon/service.
#
d_stop() {
        killproc /usr/bin/$PNAME.py \
                          || echo -n " not running"
        if [ -f /var/run/$PNAME.pid ]; then
           rm /var/run/$PNAME.pid
        fi
}

ACTION="$1"
case "$ACTION" in
    start)
        echo -n "Starting $DESC "
        d_start
        echo "."
        ;;

    stop)
        echo -n "Stopping $DESC "
        d_stop
        echo "."
        ;;

    restart|force-reload)
        echo -n "Restarting $DESC "
        d_stop
        sleep 1
        d_start
        echo "."
        ;;
    status)
        checkproc -p /var/run/$PNAME.pid /usr/bin/$PNAME.py
        rc_status -v
        ;;
    *)
        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0

