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
|
|
|
|
|
2009-09-24 09:29:34 +00:00
|
|
|
. /etc/rc.d/init.d/functions
|
2008-01-11 00:19:03 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
|
|
|
|
|
|
|
prog=dhcrelay
|
2009-09-24 09:29:34 +00:00
|
|
|
exec=/usr/sbin/dhcrelay
|
2008-01-11 00:19:03 +00:00
|
|
|
lockfile=/var/lock/subsys/dhcrelay
|
|
|
|
pidfile=/var/run/dhcrelay.pid
|
2009-09-24 09:29:34 +00:00
|
|
|
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() {
|
2009-09-24 09:29:34 +00:00
|
|
|
[ -x $exec ] || exit 5
|
|
|
|
[ -f $config ] || exit 6
|
2008-01-11 00:19:03 +00:00
|
|
|
[ -z "$DHCPSERVERS" ] && exit 6
|
2010-01-15 12:52:28 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status() {
|
|
|
|
status $exec
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status_q() {
|
|
|
|
rh_status >/dev/null 2>&1
|
2008-01-11 00:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2009-09-24 09:29:34 +00:00
|
|
|
[ `id -u` -eq 0 ] || exit 4
|
|
|
|
[ -x $exec ] || exit 5
|
|
|
|
[ -f $config ] || exit 6
|
2008-01-11 00:19:03 +00:00
|
|
|
|
2010-01-15 12:52:28 +00:00
|
|
|
rh_status_q && return 0
|
2008-01-11 00:19:03 +00:00
|
|
|
|
|
|
|
echo -n $"Starting $prog: "
|
2010-12-07 14:02:57 +00:00
|
|
|
daemon $exec $DHCRELAYARGS 2>/dev/null
|
2008-01-11 00:19:03 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL -eq 0 ] && touch $lockfile
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2009-09-24 09:29:34 +00:00
|
|
|
[ `id -u` -eq 0 ] || exit 4
|
|
|
|
|
2010-01-15 12:52:28 +00:00
|
|
|
rh_status_q || return 0
|
2008-01-11 00:19:03 +00:00
|
|
|
|
|
|
|
echo -n $"Shutting down $prog: "
|
2010-01-18 09:13:37 +00:00
|
|
|
killproc $prog
|
2008-01-11 00:19:03 +00:00
|
|
|
RETVAL=$?
|
|
|
|
|
|
|
|
echo
|
2009-09-24 09:29:34 +00:00
|
|
|
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
2008-01-11 00:19:03 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
2009-09-24 09:29:34 +00:00
|
|
|
usage() {
|
|
|
|
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
|
|
|
|
}
|
|
|
|
|
2008-01-11 00:19:03 +00:00
|
|
|
if [ $# -gt 1 ]; then
|
2010-01-15 12:52:28 +00:00
|
|
|
exit 2
|
2008-01-11 00:19:03 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart|force-reload)
|
2010-01-15 12:52:28 +00:00
|
|
|
stop ; start
|
2008-01-11 00:19:03 +00:00
|
|
|
;;
|
2009-09-24 09:29:34 +00:00
|
|
|
condrestart|try-restart)
|
2010-01-15 12:52:28 +00:00
|
|
|
rh_status_q || exit 0
|
|
|
|
stop ; start
|
2008-01-11 00:19:03 +00:00
|
|
|
;;
|
2009-09-24 09:29:34 +00:00
|
|
|
reload)
|
|
|
|
usage
|
|
|
|
# unimplemented feature
|
2010-01-15 12:52:28 +00:00
|
|
|
exit 3
|
2009-09-24 09:29:34 +00:00
|
|
|
;;
|
2008-01-11 00:19:03 +00:00
|
|
|
configtest)
|
|
|
|
configtest
|
|
|
|
;;
|
|
|
|
status)
|
2010-01-15 12:52:28 +00:00
|
|
|
rh_status
|
2008-01-11 00:19:03 +00:00
|
|
|
;;
|
|
|
|
*)
|
2009-09-24 09:29:34 +00:00
|
|
|
usage
|
2010-01-15 12:52:28 +00:00
|
|
|
exit 2
|
2008-01-11 00:19:03 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-01-15 12:52:28 +00:00
|
|
|
exit $?
|