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