update-tunnelbroker: early exit with :exit

This commit is contained in:
Christian Hesse 2026-01-19 15:26:36 +01:00
parent 6ea74adcef
commit 0bb63d4465
2 changed files with 6 additions and 10 deletions

View file

@ -4,7 +4,7 @@ Update tunnelbroker configuration
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) [![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) [![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) [![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.19-yellow?style=flat)](https://mikrotik.com/download/changelogs/) [![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) [![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) [![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)

View file

@ -5,13 +5,12 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# provides: ppp-on-up # provides: ppp-on-up
# requires RouterOS, version=7.19 # requires RouterOS, version=7.22
# requires device-mode, fetch # requires device-mode, fetch
# #
# update local address of tunnelbroker interface # update local address of tunnelbroker interface
# https://rsc.eworm.de/doc/update-tunnelbroker.md # https://rsc.eworm.de/doc/update-tunnelbroker.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -24,14 +23,12 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={ :if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={
$LogPrint error $ScriptName ("Downloading required certificate failed."); $LogPrint error $ScriptName ("Downloading required certificate failed.");
:set ExitOK true; :exit;
:error false;
} }
:foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={ :foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={
@ -54,8 +51,7 @@
:if (!($Data ~ "^(good|nochg) ")) do={ :if (!($Data ~ "^(good|nochg) ")) do={
$LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!"); $LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!");
:set ExitOK true; :exit;
:error false;
} }
:local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ]; :local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ];
@ -70,5 +66,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitOnError; $ExitOnError [ :jobname ] $Err;
} }