#!/bin/sh
# Start/stop the Packet Ship Capture daemon.

### BEGIN INIT INFO
# Provides: ps-captured
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Packet Ship IPTV Capture
### END INIT INFO

set -e
test -f /usr/sbin/ps-captured || exit 0

case "$1" in
start)	
        echo -n "Starting Packet Ship IPTV capture daemon: ps-captured"
        start-stop-daemon --start --quiet --pidfile /var/run/ps-captured.pid --name ps-captured --startas /usr/sbin/ps-captured
        echo "." 
	;;

stop)	
        echo -n "Stopping Packet Ship IPTV capture daemon: ps-captured"
        start-stop-daemon --stop --retry 5 --oknodo --quiet --pidfile /var/run/ps-captured.pid --name ps-captured 
        echo "."
        ;;

restart|force-reload) 
        echo -n "Restarting Packet Ship IPTV capture daemon: ps-captured"
        start-stop-daemon --stop --retry 5 --oknodo --quiet --pidfile /var/run/ps-captured.pid --name ps-captured
	sleep 2
        start-stop-daemon --start --quiet --pidfile /var/run/ps-captured.pid --name ps-captured --startas /usr/sbin/ps-captured
        echo "."
        ;;

*)	echo "Usage: /etc/init.d/ps-captured start|stop|restart|force-reload"
        exit 1 
        ;;
esac
exit 0
