#!/bin/sh

CAMNAME="Gbox.net"

remove_tmp () {
	rm -rf /tmp/ecm.info /tmp/pid.info /tmp/*gbox*
}

case "$1" in
	start)
	echo "[SCRIPT] $1: $CAMNAME"
	remove_tmp
	/usr/bin/gbox.camd &
    sleep 3
    start-stop-daemon --start --quiet --background --exec /usr/bin/gbox
    ;;
	stop)
	echo "[SCRIPT] $1: $CAMNAME"
    touch /tmp/gbox.kill
    killall -9 gbox.camd
        sleep 3
	remove_tmp
	;;
	*)
	$0 stop
	exit 1
	;;
esac

exit 0




