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