#!/bin/sh

### BEGIN INIT INFO
# Provides:          watchdog
# Short-Description: Start software watchdog daemon
# Required-Start:    $all
# Required-Stop:     $all
# Should-Start:      
# Should-Stop:       
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

DAEMON_USER=root
DAEMON_NAME=tm_server
DAEMON=/opt/tm_cpps/bin/$DAEMON_NAME
CMD="$1"

RETVAL=0

run()
{
  su - $DAEMON_USER -c "$DAEMON $1"
  RETVAL=$?
  return $RETVAL
}

case "$CMD" in
  start)
    run start
    ;;
  stop)
    run stop
    ;;
  restart|reload)
    start restart
    ;;
  *)
    echo "${0##*/} {start|stop|restart}"
    RETVAL=1
esac
exit $RETVAL
