From 2b9ee69f100719755fa8460e553d1b413b260f54 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 20 Apr 2018 08:05:45 +0200 Subject: [PATCH] rc: IPv6 is trigger-happy, we only need this once The unique file id was used to prevent overwrites from different interfaces but we can just use the argument in the file so that everything is rewritten in place causing the renewals to boil down to one. See a previous run with a WAN-only setup: >>> Invoking start script 'newwanip' Reconfiguring IPv4: OK Reconfiguring IPv6: OK Reconfiguring IPv6: OK Reconfiguring IPv6: OK Reconfiguring IPv6: OK Reconfiguring IPv6: OK >>> Invoking start script 'freebsd' While here, also display the interface for clarity now: >>> Invoking start script 'newwanip' Reconfiguring IPv4 on em0: OK Reconfiguring IPv6 on em0: OK >>> Invoking start script 'freebsd' --- src/etc/rc.newwanip | 2 +- src/etc/rc.newwanipv6 | 2 +- src/etc/rc.syshook.d/10-newwanip.start | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/etc/rc.newwanip b/src/etc/rc.newwanip index ef2ab0f86..acffa370a 100755 --- a/src/etc/rc.newwanip +++ b/src/etc/rc.newwanip @@ -42,7 +42,7 @@ $argument = isset($argv[1]) ? trim($argv[1]) : ''; if (file_exists('/var/run/booting')) { log_error("IP renewal deferred during boot on '{$argument}'"); - file_put_contents('/tmp/newwanip_' . uniqid(), $argument); + file_put_contents('/tmp/newwanip_' . $argument, $argument); return; } diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index 602e4c050..dff78c83b 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -42,7 +42,7 @@ $argument = isset($argv[1]) ? trim($argv[1]) : ''; if (file_exists('/var/run/booting')) { log_error("IP renewal deferred during boot on '{$argument}'"); - file_put_contents('/tmp/newwanipv6_' . uniqid(), $argument); + file_put_contents('/tmp/newwanipv6_' . $argument, $argument); return; } diff --git a/src/etc/rc.syshook.d/10-newwanip.start b/src/etc/rc.syshook.d/10-newwanip.start index c83b0fd47..ecd64b7e5 100755 --- a/src/etc/rc.syshook.d/10-newwanip.start +++ b/src/etc/rc.syshook.d/10-newwanip.start @@ -1,13 +1,17 @@ #!/bin/sh for IPV4 in $(find /tmp -type f -name "newwanip_*"); do - echo -n "Reconfiguring IPv4: " - /usr/local/opnsense/service/configd_ctl.py interface newip $(cat "${IPV4}") + INTERFACE=$(cat "${IPV4}") rm "${IPV4}" + + echo -n "Reconfiguring IPv4 on ${INTERFACE}: " + /usr/local/opnsense/service/configd_ctl.py interface newip ${INTERFACE} done for IPV6 in $(find /tmp -type f -name "newwanipv6_*"); do - echo -n "Reconfiguring IPv6: " - /usr/local/opnsense/service/configd_ctl.py interface newipv6 $(cat "${IPV6}") + INTERFACE=$(cat "${IPV6}") rm "${IPV6}" + + echo -n "Reconfiguring IPv6 on ${INTERFACE}: " + /usr/local/opnsense/service/configd_ctl.py interface newipv6 ${INTERFACE} done