#! /bin/sh
#
# This file is based on skeleton script from Miquel van Smoorenburg 
# <miquels@cistron.nl> 

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

test -r /etc/default/$NAME && . /etc/default/$NAME
test ! -z $START || exit 0

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet \
		--chuid slimp3 --exec $DAEMON -- --daemon \
		--pidfile /var/run/$NAME/$NAME.pid \
		$PARAMETERS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --oknodo --quiet \
		--pidfile /var/run/$NAME/$NAME.pid 
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --quiet --pidfile \
		/var/run/$NAME/$NAME.pid
  ;;
  restart|force)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --oknodo --quiet \
		--pidfile /var/run/$NAME/$NAME.pid 
	sleep 1
	start-stop-daemon --start --quiet \
		--chuid slimp3 --exec $DAEMON -- --daemon \
		--pidfile /var/run/$NAME/$NAME.pid \
		$PARAMETERS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
