#!/bin/bash
#
# chkconfig: - 95 05
# description: The dhcp-forward agent relays DHCP messages between two \
#              networks

# Copyright (C) 2004, 2008, 2014
#               Enrico Scholz <enrico.scholz@ensc.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.

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

# Get config.
test -e /etc/sysconfig/network && . /etc/sysconfig/network

# Check that networking is up.
test "$NETWORKING" != "no" || exit 0


DHCPFWD_CFGFILE=/etc/dhcp-fwd.conf
DHCPFWD_OPTIONS=
test -e /etc/sysconfig/dhcp-fwd && . /etc/sysconfig/dhcp-fwd

prog="dhcp-fwd"
lockfile=/var/lock/subsys/dhcp-fwd

start () {
	echo -n $"Starting $prog: "
	daemon dhcp-fwd -c ${DHCPFWD_CFGFILE} ${DHCPFWD_OPTIONS}
	retval=$?
	echo
	test $retval -eq 0 && touch $lockfile
	return $retval
}

stop () {
	echo -n $"Stopping $prog: "
	killproc dhcp-fwd
	retval=$?
	echo
	test $retval -eq 0 && rm -f $lockfile
	return $retval
}

restart () {
	stop
	start
}

# See how we were called.
case "$1" in
  start|stop|restart)	$1 ;;
  reload)		restart ;;
  status)
	status dhcp-fwd
	;;
  condrestart)
	test ! -f $lockfile || restart
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
	exit 2
esac
