#! /bin/sh
### BEGIN INIT INFO
# Provides:          batmand
# Required-Start:    networking ifupdown $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: /etc/init.d/batmand: start batmand
### END INIT INFO

#		Based on skeleton script written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian 
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#		Modified for olsrd
#		by Holger Levsen <debian@layer-acht.org>
#		Modified for batmand
#		by Wesley Tsai <wesleyboy42@gmail.com>
# 
# Version:	21-Dec-2006
# modified:	18-Sep-2007

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/batmand
NAME=batmand
DESC=batmand

test -x $DAEMON || exit 0

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

set -e

case "$1" in
  debug)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS &
	echo "$NAME."
	;;
  start)
	if [ "$START_BATMAND" != "YES" ] ; then exit 0 ; fi
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS &
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	killall -q $DAEMON || true
	echo "$NAME."
	;;
  restart|force-reload)
	echo -n "Restarting $DESC: "
	killall -q $DAEMON || true
	sleep 1
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {debug|start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
