#! /bin/sh
# chkconfig: 345 56 56
# description: An OSPF routing engine for use with Zebra and IPv6
# processname: ospf6d
# config: /etc/sysconfig/ospf6d
# config: /etc/ospf6d.conf

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/network && [ "$NETWORKING" != no ] || exit

# Check ospfd config
[ -f /etc/zebra/ospf6d.conf ] || exit 0

RETVAL=0
LOCKFILE=/var/lock/subsys/ospf6d

start()
{
	echo -n "Starting OSPF6 routing services: "

	# start daemons
	daemon ospf6d --daemon

	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	echo
}	

stop()
{
	echo -n "Shutting down OSPF6 routing services: "
	
	# stop daemons
	killproc ospf6d
	
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	echo
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload)
	restart
	;;
  restart)
	restart
	;;
  condstop)
	# Stop the servce if it is already running
	if [ -e "$LOCKFILE" ]; then
	 stop
	fi
	;;
  condrestart|condreload)
	# Restart the servce if it is already running
	if [ -e "$LOCKFILE" ]; then
 	 restart
	fi
	;;
  status)
	# report the status of the daemons in free-form format
	status ospf6d
	RETVAL=$?
	;;
  *)
	echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
	RETVAL=1
esac

exit $RETVAL
