#! /bin/sh
# /etc/init.d/routed
#
#
# 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/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

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

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

start()
{
	echo -n "Starting routed: "
	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 "$LOCKFILE"
	echo
}	

stop()
{
	echo -n "Shutting down routed: "
	# stop daemons, perhaps with the killproc function, for example:
	killproc routed
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	echo
}

restart()
{
	stop
	start
}

reload()
{
	stop
	start
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		# report the status of the daemons in free-form format,
		# perhaps with the status function, for example:
		status routed
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL

