aboutsummaryrefslogtreecommitdiffstats
path: root/update-tunnelbroker.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'update-tunnelbroker.rsc')
-rw-r--r--update-tunnelbroker.rsc31
1 files changed, 19 insertions, 12 deletions
diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc
index 67a5d30..9057e1e 100644
--- a/update-tunnelbroker.rsc
+++ b/update-tunnelbroker.rsc
@@ -1,19 +1,21 @@
#!rsc by RouterOS
# RouterOS script: update-tunnelbroker
-# Copyright (c) 2013-2024 Christian Hesse <mail@eworm.de>
+# Copyright (c) 2013-2025 Christian Hesse <mail@eworm.de>
# Michael Gisbers <michael@gisbers.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+# https://rsc.eworm.de/COPYING.md
#
# provides: ppp-on-up
-# requires RouterOS, version=7.14
+# requires RouterOS, version=7.15
+# requires device-mode, fetch
#
# update local address of tunnelbroker interface
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-tunnelbroker.md
+# https://rsc.eworm.de/doc/update-tunnelbroker.md
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:do {
+:local ExitOK false;
+:onerror Err {
+ :global GlobalConfigReady; :global GlobalFunctionsReady;
+ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
+ do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global CertificateAvailable;
@@ -22,11 +24,13 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
:if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" ] = false) do={
$LogPrint error $ScriptName ("Downloading required certificate failed.");
+ :set ExitOK true;
:error false;
}
@@ -37,12 +41,12 @@
:for I from=2 to=0 do={
:if ($Data = false) do={
- :do {
+ :onerror Err {
:set Data ([ /tool/fetch check-certificate=yes-without-crl \
("https://ipv4.tunnelbroker.net/nic/update?hostname=" . $Comment->"id") \
user=($Comment->"user") password=($Comment->"pass") output=user as-value ]->"data");
- } on-error={
- $LogPrint debug $ScriptName ("Failed downloading, " . $I . " retries pending.");
+ } do={
+ $LogPrint debug $ScriptName ("Failed downloading: " . $Err . " - " . $I . " retries pending.");
:delay 2s;
}
}
@@ -50,6 +54,7 @@
:if (!($Data ~ "^(good|nochg) ")) do={
$LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!");
+ :set ExitOK true;
:error false;
}
@@ -64,4 +69,6 @@
/interface/6to4/set $Interface local-address=$PublicAddress;
}
}
-} on-error={ }
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
+}