2007-09-26 19:20:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: dhcrelay
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# 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).
|
2004-09-09 04:11:53 +00:00
|
|
|
#
|
|
|
|
# chkconfig: - 66 34
|
|
|
|
# description: dhcrelay provides a relay for Dynamic Host Control Protocol.
|
2007-09-26 19:20:47 +00:00
|
|
|
# processname: dhcrelay
|
|
|
|
# # pidfile: /var/run/dhcrelay.pid
|
2004-09-09 04:11:53 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
. /etc/init.d/functions
|
2004-09-09 04:11:53 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
2007-09-26 19:20:47 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
prog=dhcrelay
|
|
|
|
dhcrelay=/usr/sbin/dhcrelay
|
|
|
|
lockfile=/var/lock/subsys/dhcrelay
|
2007-09-26 19:20:47 +00:00
|
|
|
pidfile=/var/run/dhcrelay.pid
|
|
|
|
conf=/etc/sysconfig/dhcrelay
|
2004-09-09 04:11:53 +00:00
|
|
|
|
2007-09-26 19:20:47 +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() {
|
2007-04-26 19:01:43 +00:00
|
|
|
[ -x $dhcrelay ] || exit 5
|
2007-09-26 19:20:47 +00:00
|
|
|
[ -f $conf ] || exit 6
|
2007-04-26 19:01:43 +00:00
|
|
|
[ -z "$DHCPSERVERS" ] && exit 6
|
2007-09-26 19:20:47 +00:00
|
|
|
RETVAL=0
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
[ -x $dhcrelay ] || exit 5
|
|
|
|
[ -f $conf ] || exit 6
|
|
|
|
|
|
|
|
pidofproc $prog >/dev/null 2>&1
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && return $RETVAL
|
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
echo -n $"Starting $prog: "
|
2007-09-26 19:20:47 +00:00
|
|
|
daemon $dhcrelay $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
|
2007-04-26 19:01:43 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL -eq 0 ] && touch $lockfile
|
|
|
|
return $RETVAL
|
2004-09-09 04:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2007-09-26 19:20:47 +00:00
|
|
|
pidofproc $prog >/dev/null 2>&1
|
2007-10-08 17:58:17 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2007-09-26 19:20:47 +00:00
|
|
|
RETVAL=7
|
|
|
|
return $RETVAL
|
|
|
|
fi
|
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
echo -n $"Shutting down $prog: "
|
|
|
|
killproc $prog -TERM
|
|
|
|
RETVAL=$?
|
2007-09-26 19:20:47 +00:00
|
|
|
|
|
|
|
[ $RETVAL = 0 ] && success || failure
|
2007-04-26 19:01:43 +00:00
|
|
|
echo
|
2007-09-26 19:20:47 +00:00
|
|
|
[ $RETVAL = 0 ] && rm -f $lockfile
|
2007-04-26 19:01:43 +00:00
|
|
|
return $RETVAL
|
2004-09-09 04:11:53 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 19:20:47 +00:00
|
|
|
if [ ! -x $dhcrelay ]; then
|
|
|
|
RETVAL=5
|
|
|
|
exit $RETVAL
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
RETVAL=2
|
|
|
|
exit $RETVAL
|
|
|
|
fi
|
|
|
|
|
2004-09-09 04:11:53 +00:00
|
|
|
case "$1" in
|
2007-04-26 19:01:43 +00:00
|
|
|
start)
|
|
|
|
start
|
2007-09-26 19:20:47 +00:00
|
|
|
RETVAL=$?
|
2007-04-26 19:01:43 +00:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
2007-09-26 19:20:47 +00:00
|
|
|
RETVAL=$?
|
2007-04-26 19:01:43 +00:00
|
|
|
;;
|
2007-09-26 19:20:47 +00:00
|
|
|
restart|force-reload)
|
|
|
|
stop && start
|
|
|
|
RETVAL=$?
|
2007-04-26 19:01:43 +00:00
|
|
|
;;
|
2007-09-26 19:20:47 +00:00
|
|
|
try-restart|reload)
|
|
|
|
RETVAL=3
|
2007-04-26 19:01:43 +00:00
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
if [ -f $lockfile ]; then
|
2007-09-26 19:20:47 +00:00
|
|
|
stop && start
|
|
|
|
RETVAL=$?
|
2007-04-26 19:01:43 +00:00
|
|
|
fi
|
|
|
|
;;
|
2007-09-26 19:20:47 +00:00
|
|
|
configtest)
|
|
|
|
configtest
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2007-04-26 19:01:43 +00:00
|
|
|
status)
|
|
|
|
status $prog
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
*)
|
2007-09-26 19:20:47 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
|
2007-04-26 19:01:43 +00:00
|
|
|
RETVAL=3
|
|
|
|
;;
|
2004-09-09 04:11:53 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|