mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-14 15:08:39 +02:00
hotspot-to-wpa: drop main function, use :do with on-error
This commit is contained in:
parent
b622f47d65
commit
54638924e4
3 changed files with 27 additions and 30 deletions
|
@ -13,21 +13,22 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Main do={
|
:do {
|
||||||
:local ScriptName [ :tostr $1 ];
|
:local ScriptName [ :jobname ];
|
||||||
:local MacAddress [ :tostr $2 ];
|
|
||||||
:local UserName [ :tostr $3 ];
|
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
|
||||||
|
:local MacAddress $"mac-address";
|
||||||
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:return false;
|
:error false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
|
||||||
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
|
|
||||||
:if ($Template->"action" = "reject") do={
|
:if ($Template->"action" = "reject") do={
|
||||||
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
||||||
:return true;
|
:error true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
@ -93,6 +94,4 @@
|
||||||
|
|
||||||
:delay 2s;
|
:delay 2s;
|
||||||
/caps-man/access-list/set $Entry action=accept;
|
/caps-man/access-list/set $Entry action=accept;
|
||||||
}
|
} on-error={ }
|
||||||
|
|
||||||
$Main [ :jobname ] $"mac-address" $username;
|
|
||||||
|
|
|
@ -14,21 +14,22 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Main do={
|
:do {
|
||||||
:local ScriptName [ :tostr $1 ];
|
:local ScriptName [ :jobname ];
|
||||||
:local MacAddress [ :tostr $2 ];
|
|
||||||
:local UserName [ :tostr $3 ];
|
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
|
||||||
|
:local MacAddress $"mac-address";
|
||||||
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:return false;
|
:error false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
|
||||||
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
|
|
||||||
:if ($Template->"action" = "reject") do={
|
:if ($Template->"action" = "reject") do={
|
||||||
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
||||||
:return true;
|
:error true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
@ -113,6 +114,4 @@
|
||||||
: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={ }
|
||||||
|
|
||||||
$Main [ :jobname ] $"mac-address" $username;
|
|
||||||
|
|
|
@ -13,21 +13,22 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Main do={
|
:do {
|
||||||
:local ScriptName [ :tostr $1 ];
|
:local ScriptName [ :jobname ];
|
||||||
:local MacAddress [ :tostr $2 ];
|
|
||||||
:local UserName [ :tostr $3 ];
|
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
|
||||||
|
:local MacAddress $"mac-address";
|
||||||
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:return false;
|
:error false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
|
||||||
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
|
|
||||||
:if ($Template->"action" = "reject") do={
|
:if ($Template->"action" = "reject") do={
|
||||||
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
|
||||||
:return true;
|
:error true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
@ -90,6 +91,4 @@
|
||||||
|
|
||||||
:delay 2s;
|
:delay 2s;
|
||||||
/interface/wifi/access-list/set $Entry action=accept;
|
/interface/wifi/access-list/set $Entry action=accept;
|
||||||
}
|
} on-error={ }
|
||||||
|
|
||||||
$Main [ :jobname ] $"mac-address" $username;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue