Skip to content

Commit

Permalink
rc: defer newwanip not exectued during boot
Browse files Browse the repository at this point in the history
PR: https://forum.opnsense.org/index.php?topic=6891.0

(cherry picked from commit 3869385)
(cherry picked from commit c371155)
  • Loading branch information
fichtner committed Jan 17, 2018
1 parent 7e6f2c5 commit f2d600f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions plist
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
/usr/local/etc/rc.syshook.d/05-beep.stop
/usr/local/etc/rc.syshook.d/05-update.early
/usr/local/etc/rc.syshook.d/10-configd.early
/usr/local/etc/rc.syshook.d/10-newwanip.start
/usr/local/etc/rc.syshook.d/15-php.early
/usr/local/etc/rc.syshook.d/20-backup.early
/usr/local/etc/rc.syshook.d/20-freebsd.start
Expand Down
3 changes: 2 additions & 1 deletion src/etc/rc.newwanip
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ require_once("interfaces.inc");
$argument = isset($argv[1]) ? trim($argv[1]) : '';

if (file_exists('/var/run/booting')) {
log_error("IP renewal ignored during boot on '{$argument}'");
log_error("IP renewal deferred during boot on '{$argument}'");
file_put_contents('/tmp/newwanip_' . uniqid(), $argument);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/etc/rc.newwanipv6
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ require_once("interfaces.inc");
$argument = isset($argv[1]) ? trim($argv[1]) : '';

if (file_exists('/var/run/booting')) {
log_error("IP renewal ignored during boot on '{$argument}'");
log_error("IP renewal deferred during boot on '{$argument}'");
file_put_contents('/tmp/newwanipv6_' . uniqid(), $argument);
return;
}

Expand Down
13 changes: 13 additions & 0 deletions src/etc/rc.syshook.d/10-newwanip.start
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/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}")
rm "${IPV4}"
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}")
rm "${IPV6}"
done

0 comments on commit f2d600f

Please sign in to comment.