Updated refresh-dhcpdconf script
At the heart of NetReg is a script that examines the NetReg user registrations and restarts dhcpd to pick up any new entries. This script gets run by cron every minute, so during peak user registration periods (like after all registrations have been cleared during a holiday break) it may stop and start dhcpd many times in a row.
I changed this script for a few reasons.
- I believe it contained a bug from much older versions of NetReg in the loop logic that checks a certain number of times to make sure dhcpd restarted correctly.
- I wanted it to mail someone when something bad happened.
- The original version would leave a bad registration file in place and not restart the dhcpd server. I wanted it to replace the last good copy and keep on chugging. Since file locking was introduced into NetReg, bad registration files have not really shown up. They were mostly a product of concurrent writes clobbering each other.
- I wanted it to preserve a copy of the registrations and dhcpd lease logs when we choose to clear out everything. That way, we’d have something to go back and look at in case we needed to audit who had what IP when something caught our attention.
- Most things in NetReg are laid out for installation on Fedora Core, but this script survived a long time without being changed to match.
Here is the entire script as I have changed it:
refresh-dhcpdconf
During really heavy registration times, we have seen the dhcpd server not restart. The only thing logged about it is the basic message "dhcpd: dhcpd startup failed". I have recently increased the sleep duration between stopping and starting dhcpd, thinking maybe the server or its listening socket didn’t have time to clean up before starting again, thus causing it some problem. However, the loop with the grep/awk that looks for the server to be running succeeds. We never get mail about the problem, just complaints that registrations are not working. Maybe we need to be checking the return from starting the service.