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'
This commit is contained in:
Franco Fichtner 2018-04-20 08:05:45 +02:00
parent 9cff964f2c
commit 2b9ee69f10
3 changed files with 10 additions and 6 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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