mirror of
https://abf.rosa.ru/djam/dhcp.git
synced 2025-02-23 13:32:48 +00:00
117 lines
2.8 KiB
Bash
117 lines
2.8 KiB
Bash
#!/bin/sh
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: dhcpd
|
|
# Default-Start:
|
|
# Default-Stop:
|
|
# Should-Start:
|
|
# Required-Start: $network
|
|
# Required-Stop:
|
|
# Short-Description: Start and stop the DHCPv6 server
|
|
# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6)
|
|
# server.
|
|
### END INIT INFO
|
|
#
|
|
# The fields below are left around for legacy tools (will remove later).
|
|
#
|
|
# chkconfig: - 65 35
|
|
# description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6) \
|
|
# server
|
|
# processname: dhcpd
|
|
# config: /etc/dhcpd6.conf
|
|
# config: /var/lib/dhcpd/dhcpd6.leases
|
|
# pidfile: /var/run/dhcpd6.pid
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
[ -x /usr/sbin/dhcpd ] || exit 0
|
|
|
|
# Which configuration file to use.
|
|
CONFIGFILE="/etc/dhcpd6.conf"
|
|
# Where to store the lease state information.
|
|
LEASEFILE="/var/lib/dhcp/dhcpd6.leases"
|
|
# Define INTERFACES to limit which network interfaces dhcpd listens on.
|
|
# The default null value causes dhcpd to listen on all interfaces.
|
|
INTERFACES=""
|
|
# Define OPTIONS with any other options to pass to the dhcpd server.
|
|
OPTIONS="-q"
|
|
|
|
# Values specified in this file override the defaults above.
|
|
[ -f /etc/sysconfig/dhcpd6 ] && . /etc/sysconfig/dhcpd6
|
|
|
|
[ -f $CONFIGFILE ] || exit 0
|
|
[ -f $LEASEFILE ] || exit 0
|
|
|
|
RETVAL=0
|
|
|
|
start() {
|
|
echo -n "Starting dhcpd (DHCPv6): "
|
|
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
|
|
OPTIONS="${OPTIONS} -chroot ${ROOTDIR}"
|
|
fi
|
|
daemon /usr/sbin/dhcpd -6 -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES
|
|
RETVAL=$?
|
|
echo
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd6
|
|
return $RETVAL
|
|
}
|
|
|
|
stop() {
|
|
echo -n "Shutting down dhcpd (DHCPv6): "
|
|
if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid ]; then
|
|
kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid`
|
|
RETVAL=$?
|
|
[ "$RETVAL" = 0 ] && success "stop" || failure "stop"
|
|
else
|
|
success "already stopped"
|
|
RETVAL=0
|
|
fi
|
|
[ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid
|
|
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd6
|
|
echo
|
|
return $RETVAL
|
|
}
|
|
|
|
configtest() {
|
|
/usr/sbin/dhcpd -q -t -6 -cf $CONFIGFILE
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 1 ]; then
|
|
/usr/sbin/dhcpd -t -6 -cf $CONFIGFILE
|
|
else
|
|
echo "Syntax: OK" >&2
|
|
fi
|
|
return $RETVAL
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|reload)
|
|
stop
|
|
start
|
|
RETVAL=$?
|
|
;;
|
|
condrestart)
|
|
if [ -f /var/lock/subsys/dhcpd6 ]; then
|
|
stop
|
|
start
|
|
RETVAL=$?
|
|
fi
|
|
;;
|
|
configtest)
|
|
configtest
|
|
;;
|
|
status)
|
|
status dhcpd
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo "Usage: dhcpd6 {start|stop|restart|condrestart|status}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $RETVAL
|