| 1 |
#!/bin/sh
|
| 2 |
#
|
| 3 |
### BEGIN INIT INFO
|
| 4 |
# Provides: dhcrelay
|
| 5 |
# Default-Start:
|
| 6 |
# Default-Stop:
|
| 7 |
# Should-Start:
|
| 8 |
# Required-Start: $network
|
| 9 |
# Required-Stop:
|
| 10 |
# Short-Description: Start and stop the DHCP relay server
|
| 11 |
# Description: dhcrelay provides the Dynamic Host Configuration Protocol (DHCP)
|
| 12 |
# relay server. This is required when your DHCP server is on
|
| 13 |
# another network segment from the clients.
|
| 14 |
### END INIT INFO
|
| 15 |
#
|
| 16 |
# The fields below are left around for legacy tools (will remove later).
|
| 17 |
#
|
| 18 |
# chkconfig: - 65 35
|
| 19 |
# description: dhcrelay provides a relay for Dynamic Host Control Protocol.
|
| 20 |
# processname: dhcrelay
|
| 21 |
# # pidfile: /var/run/dhcrelay.pid
|
| 22 |
|
| 23 |
. /etc/rc.d/init.d/functions
|
| 24 |
|
| 25 |
RETVAL=0
|
| 26 |
|
| 27 |
prog=dhcrelay
|
| 28 |
exec=/usr/sbin/dhcrelay
|
| 29 |
lockfile=/var/lock/subsys/dhcrelay
|
| 30 |
pidfile=/var/run/dhcrelay.pid
|
| 31 |
config=/etc/sysconfig/dhcrelay
|
| 32 |
|
| 33 |
# The dhcrelay daemon uses the sysconfig file for configuration information.
|
| 34 |
# There is no native configuration file for this program and you must specify
|
| 35 |
# its settings on the command line.
|
| 36 |
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay
|
| 37 |
|
| 38 |
configtest() {
|
| 39 |
[ -x $exec ] || exit 5
|
| 40 |
[ -f $config ] || exit 6
|
| 41 |
[ -z "$DHCPSERVERS" ] && exit 6
|
| 42 |
RETVAL=0
|
| 43 |
return $RETVAL
|
| 44 |
}
|
| 45 |
|
| 46 |
start() {
|
| 47 |
[ `id -u` -eq 0 ] || exit 4
|
| 48 |
[ -x $exec ] || exit 5
|
| 49 |
[ -f $config ] || exit 6
|
| 50 |
|
| 51 |
pidofproc $prog >/dev/null 2>&1
|
| 52 |
RETVAL=$?
|
| 53 |
[ $RETVAL -eq 0 ] && return $RETVAL
|
| 54 |
|
| 55 |
echo -n $"Starting $prog: "
|
| 56 |
daemon $exec $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
|
| 57 |
RETVAL=$?
|
| 58 |
echo
|
| 59 |
[ $RETVAL -eq 0 ] && touch $lockfile
|
| 60 |
return $RETVAL
|
| 61 |
}
|
| 62 |
|
| 63 |
stop() {
|
| 64 |
[ `id -u` -eq 0 ] || exit 4
|
| 65 |
|
| 66 |
pidofproc $prog >/dev/null 2>&1
|
| 67 |
if [ $? -ne 0 ]; then
|
| 68 |
RETVAL=0
|
| 69 |
return $RETVAL
|
| 70 |
fi
|
| 71 |
|
| 72 |
echo -n $"Shutting down $prog: "
|
| 73 |
killproc $prog -TERM
|
| 74 |
RETVAL=$?
|
| 75 |
|
| 76 |
echo
|
| 77 |
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
| 78 |
# killproc -TERM doesn't remove pidfile, remove it manually
|
| 79 |
[ $RETVAL -eq 0 ] && rm -f $pidfile
|
| 80 |
return $RETVAL
|
| 81 |
}
|
| 82 |
|
| 83 |
usage() {
|
| 84 |
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
|
| 85 |
}
|
| 86 |
|
| 87 |
if [ ! -x $exec ]; then
|
| 88 |
RETVAL=5
|
| 89 |
exit $RETVAL
|
| 90 |
fi
|
| 91 |
|
| 92 |
if [ $# -gt 1 ]; then
|
| 93 |
RETVAL=2
|
| 94 |
exit $RETVAL
|
| 95 |
fi
|
| 96 |
|
| 97 |
case "$1" in
|
| 98 |
start)
|
| 99 |
start
|
| 100 |
RETVAL=$?
|
| 101 |
;;
|
| 102 |
stop)
|
| 103 |
stop
|
| 104 |
RETVAL=$?
|
| 105 |
;;
|
| 106 |
restart|force-reload)
|
| 107 |
stop && start
|
| 108 |
RETVAL=$?
|
| 109 |
;;
|
| 110 |
condrestart|try-restart)
|
| 111 |
if [ -f $lockfile ]; then
|
| 112 |
stop && start
|
| 113 |
RETVAL=$?
|
| 114 |
fi
|
| 115 |
;;
|
| 116 |
reload)
|
| 117 |
usage
|
| 118 |
# unimplemented feature
|
| 119 |
RETVAL=3
|
| 120 |
;;
|
| 121 |
configtest)
|
| 122 |
configtest
|
| 123 |
RETVAL=$?
|
| 124 |
;;
|
| 125 |
status)
|
| 126 |
status $prog
|
| 127 |
RETVAL=$?
|
| 128 |
;;
|
| 129 |
*)
|
| 130 |
usage
|
| 131 |
RETVAL=2
|
| 132 |
;;
|
| 133 |
esac
|
| 134 |
|
| 135 |
exit $RETVAL
|