#!/bin/sh
#
# gated		This script is used to start/stop the gated routing
#		daemon
#
# chkconfig: - 32 75
# description: Starts and stops gated (routing daemon). GateD is a modular \
#	software program consisting of core services, a routing database, \
#	and protocol modules supporting multiple routing protocols (RIP \
#	versions 1 and 2, DCN HELLO, OSPF version 2, EGP version 2 and BGP \
#	version 2 through 4)

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

# Source networking configuration.
. /etc/sysconfig/network

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

[ -f /etc/gated.conf ] || exit 0
[ -f /usr/bin/gdc ] || exit 0
[ -f /usr/sbin/gated ] || exit 0

PATH=$PATH:/usr/bin:/usr/sbin

# See how we were called.
case "$1" in
  start)
	echo -n "Starting gated: "
	if ! gdc running >& /dev/null; then
	    daemon gated
	fi
	echo
	touch /var/lock/subsys/gated
	;;
  stop)
	echo -n "Stopping gated: "
	if gdc running >& /dev/null; then
	    gdc stop >& /dev/null
	    echo -n "gated "
	fi
	rm -f /var/run/gated.version
	echo "done "
	rm -f /var/lock/subsys/gated
	;;
  status)
        gdc status
	;;
  restart)
        gdc restart
        ;;
  *)
	echo "Usage: $0 {start|stop|restart|status}"
	exit 1
esac

exit 0

