#!/bin/sh
#
# chkconfig: - 55 55
# description:	The routed daemon allows for automatic IP router table \
#		updated via the RIP protocol. While RIP is widely used \
#		on small networks, more complex routing protocls are \
#		needed for complex networks.
# processname:	routed
# config:	/etc/sysconfig/routed
# config:	/etc/gateways

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

# Get config.
. /etc/sysconfig/network

# 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 routed
		exit 1
	fi
else
	exit 0
fi

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

RETVAL=0
# See how we were called.
case "$1" in
  start)
	if [ ! -f /var/lock/subsys/routed ]; then
		msg_starting "routed (RIP)"
		case $SILENT in
		  true|yes)
			silent=-q
			;;
		  *)
			silent=
			;;
		esac
		case $EXPORT_GATEWAY in
		  true|yes)
			export=-g
			;;
		  *)
			export=
			;;
		esac
		daemon routed $silent $export
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/routed
	else
		msg_already_running routed
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/routed ]; then
		msg_stopping "routed (RIP)"
		killproc routed
		rm -f /var/lock/subsys/routed >/dev/null 2>&1
	else
		msg_not_running routed
	fi
	;;
  status)
	status routed
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
