#! /bin/sh
#
# If you want to use Juman server, copy this script to /etc/init.d/
# and call update-rc.d to install the links of the copied script.
#

### BEGIN INIT INFO
# Provides:          juman
# Required-Start:    $local_fs $network $syslog
# Required-Stop:     $local_fs $network $syslog
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Juman init script
# Description:       Init script for Juman server
### END INIT INFO

NAME=juman
DAEMON="/usr/bin/$NAME"
DESC="Juman server"

test -f $DAEMON || exit 0

PARAMS="-S"

case "$1" in
    start)
	check_for_no_start
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --background --exec $DAEMON -- $PARAMS
	echo "$NAME."
	;;
    stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
	echo "$NAME."
	;;
    restart|force-reload)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
	sleep 1
	start-stop-daemon --start --quiet --background --exec $DAEMON -- $PARAMS
	echo "$NAME."
	;;
    *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
