#!/bin/sh

DESC="CCU Framework Watchdog"
DAEMON=/usr/bin/pluginmanager_watchdog

PID_FILE=/var/run/pluginmanager_watchdog.pid

TESTFILE=/tmp/testsoftwareEnabled

# Make sure the progam exists
[ -f $DAEMON ] || exit 0

start() {
    if [ -f $TESTFILE ];
    then
        echo "$DESC; do nothing"
    else
        echo -n "Starting $DESC: "
        start-stop-daemon -S -q -p $PID_FILE -m -b -x $DAEMON
        echo "done"
    fi
}
stop() {
    echo -n "Stopping $DESC: "
    start-stop-daemon -K -q -p $PID_FILE
    echo "done"
}
restart() {
    stop
    sleep 1
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|reload)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?
