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