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
2ee6f6e
. /etc/rc.d/init.d/functions
8273327
8273327
RETVAL=0
8273327
8273327
prog=dhcrelay
2ee6f6e
exec=/usr/sbin/dhcrelay
8273327
lockfile=/var/lock/subsys/dhcrelay
8273327
pidfile=/var/run/dhcrelay.pid
2ee6f6e
config=/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() {
2ee6f6e
    [ -x $exec ] || exit 5
2ee6f6e
    [ -f $config ] || exit 6
8273327
    [ -z "$DHCPSERVERS" ] && exit 6
61e3778
    return 0
61e3778
}
61e3778
61e3778
rh_status() {
61e3778
    status $exec
61e3778
}
61e3778
61e3778
rh_status_q() {
61e3778
    rh_status >/dev/null 2>&1
8273327
}
8273327
8273327
start() {
2ee6f6e
    [ `id -u` -eq 0 ] || exit 4
2ee6f6e
    [ -x $exec ] || exit 5
2ee6f6e
    [ -f $config ] || exit 6
8273327
61e3778
    rh_status_q && return 0
8273327
8273327
    echo -n $"Starting $prog: "
2ee6f6e
    daemon $exec $([ -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() {
2ee6f6e
    [ `id -u` -eq 0 ] || exit 4
2ee6f6e
61e3778
    rh_status_q || return 0
8273327
8273327
    echo -n $"Shutting down $prog: "
16b016c
    killproc $prog
8273327
    RETVAL=$?
8273327
8273327
    echo
2ee6f6e
    [ $RETVAL -eq 0 ] && rm -f $lockfile
8273327
    return $RETVAL
8273327
}
8273327
2ee6f6e
usage() {
2ee6f6e
    echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
2ee6f6e
}
2ee6f6e
8273327
if [ $# -gt 1 ]; then
61e3778
    exit 2
8273327
fi
8273327
8273327
case "$1" in
8273327
    start)
8273327
        start
8273327
        ;;
8273327
    stop)
8273327
        stop
8273327
        ;;
8273327
    restart|force-reload)
61e3778
        stop ; start
8273327
        ;;
2ee6f6e
    condrestart|try-restart)
61e3778
        rh_status_q || exit 0
61e3778
        stop ; start
8273327
        ;;
2ee6f6e
    reload)
2ee6f6e
        usage
2ee6f6e
        # unimplemented feature
61e3778
        exit 3
2ee6f6e
        ;;
8273327
    configtest)
8273327
        configtest
8273327
        ;;
8273327
    status)
61e3778
        rh_status
8273327
        ;;
8273327
    *)
2ee6f6e
        usage
61e3778
        exit 2
8273327
        ;;
8273327
esac
8273327
61e3778
exit $?