-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jens Vehlhaber
committed
Jan 26, 2021
1 parent
1f4be87
commit 99d83de
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
/etc/init.d/dhcpd stop | ||
|
||
ln -sf /config/user-data/dhcp/sbin/dhcpd /usr/sbin/dhcpd | ||
cp -f /config/user-data/dhcp/init.d/dhcpd /etc/init.d/dhcpd | ||
|
||
/etc/init.d/dhcpd start | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: dhcpd | ||
# Required-Start: $syslog $remote_fs $network | ||
# Required-Stop: $syslog $remote_fs $network | ||
# Default-Start: | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Stops dhcpd (start is done by vyatta cli) | ||
# Description: Stops dhcpd daemon | ||
### END INIT INFO | ||
|
||
. /lib/lsb/init-functions | ||
|
||
LEASES=dhcpd.leases | ||
LEASEFILE=/var/run/$LEASES | ||
LEASEFILEBAK=/config/$LEASES | ||
CONFIGFILE=/opt/vyatta/etc/dhcpd.conf | ||
PIDFILE=/var/run/dhcpd.pid | ||
UNUSEDPIDFILE=/var/run/dhcpd-unused.pid | ||
CRONFILE=dhcpd-cron | ||
CRONSRC=/opt/vyatta/sbin/$CRONFILE | ||
CRONDEST=/etc/cron.hourly/$CRONFILE | ||
|
||
start() { | ||
if [ ! -f "$CONFIGFILE" ]; then | ||
log_failure_msg "Cannot start the DHCP server because configuration file $CONFIGFILE is absent." | ||
exit 1 | ||
fi | ||
|
||
echo "Starting DHCP server daemon..." | ||
|
||
if [ ! -f $LEASEFILE ]; then | ||
if [ -e $LEASEFILEBAK ]; then | ||
cp $LEASEFILEBAK $LEASEFILE | ||
else | ||
touch $LEASEFILE | ||
fi | ||
fi | ||
|
||
OUTPUT=`start-stop-daemon --start --make-pidfile --pidfile $PIDFILE -b --exec /usr/sbin/dhcpd \ | ||
-- -f -pf $UNUSEDPIDFILE -cf $CONFIGFILE -lf $LEASEFILE 2>&1` | ||
PID=`cat $PIDFILE 2>/dev/null` | ||
if [ ! -d "/proc/$PID" ]; then | ||
if [ "$OUTPUT" == "" ]; then | ||
# this can happen under high load due to some sort of a race condition | ||
sleep 1 | ||
start | ||
else | ||
log_failure_msg "$OUTPUT" | ||
exit 1 | ||
fi | ||
fi | ||
cp $CRONSRC $CRONDEST | ||
} | ||
|
||
stop() { | ||
if [ -f "$PIDFILE" ]; then | ||
PID=`cat $PIDFILE` | ||
if [ -n "$PID" ]; then | ||
echo "Stopping DHCP server daemon..." | ||
OUTPUT=`start-stop-daemon -q --stop --pidfile $PIDFILE 2>&1` | ||
|
||
# Commenting out verification loop for now. Process goes into zombie state only on | ||
# system startup. This causes a loop greater that 20 seconds which forces rtrmgr | ||
# to commit suicide. | ||
# while [ -d "/proc/$PID" ]; do | ||
# sleep 1 | ||
# done | ||
fi | ||
rm -f $PIDFILE | ||
rm -f $UNUSEDPIDFILE | ||
if [ -e $LEASEFILE ]; then | ||
mv $LEASEFILE $LEASEFILEBAK | ||
fi | ||
rm -f $CRONDEST | ||
fi | ||
} | ||
|
||
restart () { | ||
if [ -f "$PIDFILE" ]; then | ||
PID=`cat $PIDFILE` | ||
fi | ||
|
||
if [ -n "$PID" ] && [ -d "/proc/$PID" ]; then | ||
OUTPUT=`kill -HUP $PID` | ||
else | ||
start | ||
fi | ||
} | ||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
restart) | ||
stop | ||
start | ||
# note I am disabling restart because no sig will cause dnsmasq to re-read it's config file. | ||
# this is not good since I think it loses it's cache file on complete restart. | ||
# maybe we can fix this when we shift away from dnsmasq. Hence I leave the original code | ||
# in this file | ||
# restart | ||
;; | ||
*) | ||
log_failure_msg "usage: $0 {start|stop|restart} configfile interface" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
Binary file not shown.