#!/bin/bash
#
# chkconfig: 345 95 05
# description: The dhcp-forward agent relays DHCP messages between two \
#              networks
# processname: dhcp-fwd
# config: /etc/dhcp-fwd.conf
# pidfile: /var/run/dhcp-fwd.pid

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

# Get config.
. /etc/sysconfig/network

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

RETVAL=0
prog="dhcp-fwd"

start () {
	gprintf "Starting %s: " "$prog"
	daemon dhcp-fwd -c /etc/dhcp-fwd.conf
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcp-fwd
	return $RETVAL
}

stop () {
	gprintf "Stopping %s: " "$prog"
	killproc dhcp-fwd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcp-fwd
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status dhcp-fwd
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	[ -f /var/lock/subsys/dhcp-fwd ] && restart || :
	;;
  *)
	gprintf "Usage: %s {start|stop|status|restart|reload|condrestart}\n" "$0"
	exit 1
esac

exit $?
