dhcp/dhcrelay.init

136 lines
2.8 KiB
Plaintext
Raw Normal View History

2008-01-11 00:19:03 +00:00
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: dhcrelay
# Default-Start:
# Default-Stop:
# Should-Start:
# Required-Start: $network
# Required-Stop:
# Short-Description: Start and stop the DHCP relay server
# Description: dhcrelay provides the Dynamic Host Configuration Protocol (DHCP)
# relay server. This is required when your DHCP server is on
# another network segment from the clients.
### END INIT INFO
#
# The fields below are left around for legacy tools (will remove later).
#
# chkconfig: - 65 35
# description: dhcrelay provides a relay for Dynamic Host Control Protocol.
# processname: dhcrelay
# # pidfile: /var/run/dhcrelay.pid
. /etc/rc.d/init.d/functions
2008-01-11 00:19:03 +00:00
RETVAL=0
prog=dhcrelay
exec=/usr/sbin/dhcrelay
2008-01-11 00:19:03 +00:00
lockfile=/var/lock/subsys/dhcrelay
pidfile=/var/run/dhcrelay.pid
config=/etc/sysconfig/dhcrelay
2008-01-11 00:19:03 +00:00
# The dhcrelay daemon uses the sysconfig file for configuration information.
# There is no native configuration file for this program and you must specify
# its settings on the command line.
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay
configtest() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
2008-01-11 00:19:03 +00:00
[ -z "$DHCPSERVERS" ] && exit 6
RETVAL=0
return $RETVAL
}
start() {
[ `id -u` -eq 0 ] || exit 4
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
2008-01-11 00:19:03 +00:00
pidofproc $prog >/dev/null 2>&1
RETVAL=$?
[ $RETVAL -eq 0 ] && return $RETVAL
echo -n $"Starting $prog: "
daemon $exec $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
2008-01-11 00:19:03 +00:00
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop() {
[ `id -u` -eq 0 ] || exit 4
2008-01-11 00:19:03 +00:00
pidofproc $prog >/dev/null 2>&1
if [ $? -ne 0 ]; then
RETVAL=0
2008-01-11 00:19:03 +00:00
return $RETVAL
fi
echo -n $"Shutting down $prog: "
killproc $prog -TERM
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
# killproc -TERM doesn't remove pidfile, remove it manually
[ $RETVAL -eq 0 ] && rm -f $pidfile
2008-01-11 00:19:03 +00:00
return $RETVAL
}
usage() {
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
}
if [ ! -x $exec ]; then
2008-01-11 00:19:03 +00:00
RETVAL=5
exit $RETVAL
fi
if [ $# -gt 1 ]; then
RETVAL=2
exit $RETVAL
fi
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
stop && start
RETVAL=$?
;;
condrestart|try-restart)
2008-01-11 00:19:03 +00:00
if [ -f $lockfile ]; then
stop && start
RETVAL=$?
fi
;;
reload)
usage
# unimplemented feature
RETVAL=3
;;
2008-01-11 00:19:03 +00:00
configtest)
configtest
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
usage
RETVAL=2
2008-01-11 00:19:03 +00:00
;;
esac
exit $RETVAL