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