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