#! /bin/sh
#
# preload init.d script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/preload
NAME=preload
DESC=preload
DAEMON_OPTS="-s /var/lib/preload/preload.state $DAEMON_OPTS"

test -x $DAEMON || exit 0

# Include preload defaults if available
if [ -f /etc/default/preload ] ; then
	. /etc/default/preload
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet -u 0 --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet -u 0 --exec $DAEMON
	echo "$NAME."

	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 0 --quiet -u 0 --exec $DAEMON
  	;;
  restart)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet -u 0 --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet -u 0 --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
