#! /bin/sh
#
# jabber	init script to start jabber daemon
#
#		Created from Bernd Eckenfels <ecki@lina.inka.de>
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Sun, 21 May 2000 12:31:20 +0200

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/jabberd
NAME=jabberd
DESC=jabberd
CONF=/etc/jabber/jabber.xml
PID=/var/run/jabber/jabber.pid
CMDLINE=""

test -f $DAEMON -a -f $CONF || exit 0

# set some parameters like JABBER_HOSTNAME
if test -x /etc/jabber/jabber.cfg; then
 . /etc/jabber/jabber.cfg
fi

if [ x"$JABBER_HOSTNAME" != x"" ]; then
	CMDLINE="$CMDLINE -h $JABBER_HOSTNAME"
fi
if [ x"$JABBER_SPOOL" != x"" ]; then
	CMDLINE="$CMDLINE -s $JABBER_SPOOL"
fi

if [ x"$CMDLINE" != x"" ]; then
	CMDLINE="-- $CMDLINE"
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	cd /usr/lib/jabber/
	start-stop-daemon -b -c daemon --start --quiet --exec $DAEMON $CMDLINE || echo -n "<Failed> "
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --exec $DAEMON || echo -n "<Failed> "
	echo "$NAME."
	;;
  reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --quiet \
		--pidfile $PID --exec $DAEMON
  ;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	$0 stop
	sleep 1
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
