#!/bin/sh
#
# ripngd		Starts the Dynamic Route Daemon
#
# chkconfig:	345 15 84
#
# description:	Dynamic Route Daemon for IPv4 and IPv6 routers
#
# processname:	ripngd
# config:	/etc/ripngd/ripngd.conf


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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/ripngd ] && . /etc/sysconfig/ripngd

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down ripngd
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the services are already running?
	if [ ! -f /var/lock/subsys/ripngd ]; then
		FLAGS="--daemon"
		is_yes "$RETAIN_ROUTES" && FLAGS="$FLAGS --retain"
                [ -n "$VTY_ADDR" ] && FLAGS="$FLAGS --vty_addr $VTY_ADDR"
                [ -n "$VTY_PORT" ] && FLAGS="$FLAGS --vty_port $VTY_PORT"
		msg_starting ripngd
		daemon ripngd $FLAGS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ripngd
	else
		msg_already_running "ripngd"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/ripngd ]; then
		# Stop daemons.
 		msg_stopping "ripngd"
		killproc ripngd
		rm -f /var/lock/subsys/ripngd
	else
		msg_not_running ripngd
	fi
	;;
  status)
	status ripngd
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
