#!/bin/sh
#
# /etc/init.d script for whiteboard

### BEGIN INIT INFO
# Provides:          whiteboard
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start and stop whiteboard
# Description:       whiteboard is a collaborative web editor
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Whiteboard daemon"
NAME=whiteboard
DAEMON=/var/lib/whiteboard/rundaemon.py
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

do_start()
{
	start-stop-daemon --start --exec $DAEMON --pidfile $PIDFILE -m \
		-c www-data -d /var/lib/whiteboard -b
}

do_stop()
{
	start-stop-daemon --stop --pidfile $PIDFILE
}

case "$1" in
  start)
	log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	log_end_msg 0
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	do_stop
	log_end_msg 0
	;;
  status)
       ;;
  restart|force-reload)
	#
	# If the "reload" option is implemented then remove the
	# 'force-reload' alias
	#
	log_daemon_msg "Restarting $DESC" "$NAME"
	do_stop
	do_start
	log_end_msg 0
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
	exit 3
	;;
esac

:
