#! /bin/sh
#
# messagewall	This script handles messagewall startup/shutdown.
#		Written by Andres Salomon <dilinger@voxel.net>.
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/messagewall
NAME=messagewall
DESC=messagewall
PIDF=/var/run/messagewall/mwall.0.pid

test -x $DAEMON || exit 0

case "$1" in
  start)
  	cp -ra /etc/messagewall/* /var/run/messagewall
	echo -n "Starting $DESC: $NAME"
	start-stop-daemon --quiet --start --background --exec $DAEMON \
			--startas /bin/sh -- -c "$DAEMON 2>&1 | /usr/bin/logger -i -t $NAME -p daemon.notice"
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC: $NAME"
	start-stop-daemon --quiet --stop --pidfile $PIDF --exec $DAEMON
	echo "."
	;;
  reload|force-reload)
	echo -n "Reloading $DESC configuration files"
	start-stop-daemon --quiet --stop --signal 1 --pidfile $PIDF \
			--exec $DAEMON
	echo "."
  ;;
  restart)
	echo -n "Restarting $DESC: $NAME"
	$0 stop
	sleep 1
	$0 start
	echo "."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
