#!/bin/sh
# /etc/init.d/omxremote
### BEGIN INIT INFO
# Provides:          omxremote
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Should-Start:      $network
# Should-Stop:       $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop the omxremote server daemon
# Description:       Controls the main omxremote server daemon
### END INIT INFO
DAEMON=/usr/bin/env
ARGS="python /usr/lib/omxremote/code.py 55555"
PIDFILE="/var/run/omxremote"
WD=/usr/lib/omxremote
. /lib/lsb/init-functions
case "$1" in
  start)
    echo "Starting omxremote ..." >&2
    #/sbin/start-stop-daemon --start --pidfile $PIDFILE --chdir $WD -b --make-pidfile --exec $DAEMON $ARGS &> /var/log/omxremote.log
    /sbin/start-stop-daemon --start --pidfile $PIDFILE --chdir $WD -b --make-pidfile --exec $DAEMON $ARGS 
    ;;
  stop)
    echo "Stopping omxremote ..." >&2
    /sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose
    ;;
  restart)
    echo "Restarting omxremote ..." >&2
    /sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose
    #/sbin/start-stop-daemon --start --pidfile $PIDFILE --chdir $WD -b --make-pidfile --exec $DAEMON $ARGS &> /var/log/omxremote.log
    /sbin/start-stop-daemon --start --pidfile $PIDFILE --chdir $WD -b --make-pidfile --exec $DAEMON $ARGS
    ;;
  *)
    echo "Usage: /etc/init.d/omxremote {start|stop|restart}" >&2
    exit 1
    ;;
esac
exit 0

