aboutsummaryrefslogtreecommitdiffstats
path: root/update-tunnelbroker.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'update-tunnelbroker.rsc')
-rw-r--r--update-tunnelbroker.rsc27
1 files changed, 14 insertions, 13 deletions
diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc
index dd43c64..9057e1e 100644
--- a/update-tunnelbroker.rsc
+++ b/update-tunnelbroker.rsc
@@ -1,20 +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
-
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+# https://rsc.eworm.de/doc/update-tunnelbroker.md
:local ExitOK false;
-:do {
+: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;
@@ -40,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;
}
}
@@ -68,6 +69,6 @@
/interface/6to4/set $Interface local-address=$PublicAddress;
}
}
-} on-error={
- :global ExitError; $ExitError $ExitOK [ :jobname ];
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
}