#! /bin/sh
#
# ices2
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/ices2
NAME=ices2
DESC=ices2

test -x $DAEMON || exit 0

# Defaults
#line-in recorder
CONFIGFILE="/etc/ices2/reboot.fm_enc0der.xml"
#backup recording on decoder
#CONFIGFILE="/etc/ices2/reboot.fm_decoder_backup.xml"

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
		--background --exec $DAEMON -- $CONFIGFILE
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
	;;
  restart)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
		--background --exec $DAEMON -- -c $CONFIGFILE
	echo "$NAME."
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
