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