Skip to content

Commit

Permalink
fix for #34
Browse files Browse the repository at this point in the history
better error checking for DHCPD files
Apparently DSM 7 may not always have a dhcpd-leases.log file
  • Loading branch information
gclayburg committed Jul 21, 2021
1 parent cb796db commit 35d5680
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions poll-dhcp-changes.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#!/bin/sh

while true; do
ATIME=`stat /etc/dhcpd/dhcpd-leases.log | grep Modify`

if [[ "$ATIME" != "$LTIME" ]]; then
date
echo "dhcp leases changed - reloading DNS"
/var/services/homes/admin/diskstation_dns_modify.sh
LTIME=$ATIME
fi
sleep 5
while true; do
reload_dns=false
if [ -r /etc/dhcpd/dhcpd-leases.log ]; then
LOGATIME=`stat /etc/dhcpd/dhcpd-leases.log | grep Modify`
if [ "$LOGATIME" != "$LOGLASTATIME" ]; then
date
LOGLASTATIME=$LOGATIME
reload_dns=true
fi
elif [ -r /etc/dhcpd/dhcpd.conf.leases ]; then
LEASEATIME=`stat /etc/dhcpd/dhcpd.conf.leases | grep Modify`
if [ "$LEASEATIME" != "$LEASELASTATIME" ]; then
date
LEASELASTATIME=$LEASEATIME
reload_dns=true
fi
else
echo "ERROR - No dhcp lease files found. Is something misconfigured?"
exit 1
fi
if "$reload_dns"; then
echo "dhcp leases changed - reloading DNS"
/var/services/homes/admin/diskstation_dns_modify.sh
fi
sleep 5
done


0 comments on commit 35d5680

Please sign in to comment.