From 483048b9e6daf148316c022a8bc8ba6781caee86 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 20 Jul 2022 14:23:54 +0200 Subject: [PATCH] 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. --- src/opnsense/scripts/dhcp/prefixes.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/opnsense/scripts/dhcp/prefixes.sh b/src/opnsense/scripts/dhcp/prefixes.sh index cc900470a..45318ad7f 100755 --- a/src/opnsense/scripts/dhcp/prefixes.sh +++ b/src/opnsense/scripts/dhcp/prefixes.sh @@ -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