hotspot-to-wpa: use $ExitError to indicate unintentional error

This commit is contained in:
Christian Hesse 2024-12-06 10:31:52 +01:00
parent f7b96aa3e9
commit 8e12453058
3 changed files with 21 additions and 3 deletions

View file

@ -13,6 +13,7 @@
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local ExitOK false;
:do { :do {
:local ScriptName [ :jobname ]; :local ScriptName [ :jobname ];
@ -25,11 +26,13 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true;
:error false; :error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true;
:error false; :error false;
} }
@ -57,6 +60,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true;
:error true; :error true;
} }
@ -95,4 +99,6 @@
:delay 2s; :delay 2s;
/caps-man/access-list/set $Entry action=accept; /caps-man/access-list/set $Entry action=accept;
} on-error={ } } on-error={
:global ExitError; $ExitError $ExitOK [ :jobname ];
}

View file

@ -14,6 +14,7 @@
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local ExitOK false;
:do { :do {
:local ScriptName [ :jobname ]; :local ScriptName [ :jobname ];
@ -26,11 +27,13 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true;
:error false; :error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true;
:error false; :error false;
} }
@ -64,6 +67,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true;
:error true; :error true;
} }
@ -115,4 +119,6 @@
:delay 2s; :delay 2s;
/caps-man/access-list/set $Entry action=accept; /caps-man/access-list/set $Entry action=accept;
/interface/wifi/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept;
} on-error={ } } on-error={
:global ExitError; $ExitError $ExitOK [ :jobname ];
}

View file

@ -13,6 +13,7 @@
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local ExitOK false;
:do { :do {
:local ScriptName [ :jobname ]; :local ScriptName [ :jobname ];
@ -25,11 +26,13 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true;
:error false; :error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true;
:error false; :error false;
} }
@ -57,6 +60,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true;
:error true; :error true;
} }
@ -92,4 +96,6 @@
:delay 2s; :delay 2s;
/interface/wifi/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept;
} on-error={ } } on-error={
:global ExitError; $ExitError $ExitOK [ :jobname ];
}