dhcp: upgrade the prefix watcher to production level #5876

Just make a MD5 sum of the file and change polling to 20 seconds.
Call backend on first run as well without waiting.  Interval could
be lower still, but as said earlier it doesn't matter much all
things considered.
This commit is contained in:
Franco Fichtner 2022-07-20 14:23:54 +02:00
parent 643328486b
commit 483048b9e6

View File

@ -24,9 +24,17 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
INTERVAL=${1:-60}
CHECKSUM="md5 -q"
INTERVAL=${1:-20}
LEASES="/var/dhcpd/var/db/dhcpd6.leases"
PREVIOUS=
while :; do
CURRENT=$(${CHECKSUM} ${LEASES})
if [ "${CURRENT}" != "${PREVIOUS}" ]; then
configctl dhcpd update prefixes
PREVIOUS=${CURRENT}
fi
sleep "${INTERVAL}"
configctl dhcpd update prefixes
done