mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-16 18:19:36 +00:00
hotspot-to-wpa: early exit with :exit
This commit is contained in:
parent
a59d32e3d8
commit
7d41c38bc5
4 changed files with 16 additions and 28 deletions
|
|
@ -4,7 +4,7 @@ Use WPA network with hotspot credentials
|
||||||
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||||
[](https://mikrotik.com/download/changelogs/)
|
[](https://mikrotik.com/download/changelogs/)
|
||||||
[](https://t.me/routeros_scripts)
|
[](https://t.me/routeros_scripts)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.19
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, hotspot
|
# requires device-mode, hotspot
|
||||||
#
|
#
|
||||||
# add private WPA passphrase after hotspot login
|
# add private WPA passphrase after hotspot login
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
: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) \
|
||||||
|
|
@ -27,14 +26,12 @@
|
||||||
:local UserName $username;
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
: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;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Date [ /system/clock/get date ];
|
:local Date [ /system/clock/get date ];
|
||||||
|
|
@ -61,8 +58,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;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
|
@ -101,5 +97,5 @@
|
||||||
:delay 2s;
|
:delay 2s;
|
||||||
/caps-man/access-list/set $Entry action=accept;
|
/caps-man/access-list/set $Entry action=accept;
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.19
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, hotspot
|
# requires device-mode, hotspot
|
||||||
#
|
#
|
||||||
# add private WPA passphrase after hotspot login
|
# add private WPA passphrase after hotspot login
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
# !! This is just a template to generate the real script!
|
# !! This is just a template to generate the real script!
|
||||||
# !! Pattern '%TEMPL%' is replaced, paths are filtered.
|
# !! Pattern '%TEMPL%' is replaced, paths are filtered.
|
||||||
|
|
||||||
: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) \
|
||||||
|
|
@ -28,14 +27,12 @@
|
||||||
:local UserName $username;
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
: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;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Date [ /system/clock/get date ];
|
:local Date [ /system/clock/get date ];
|
||||||
|
|
@ -68,8 +65,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;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
|
@ -121,5 +117,5 @@
|
||||||
/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;
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2019-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.19
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, hotspot
|
# requires device-mode, hotspot
|
||||||
#
|
#
|
||||||
# add private WPA passphrase after hotspot login
|
# add private WPA passphrase after hotspot login
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
: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) \
|
||||||
|
|
@ -27,14 +26,12 @@
|
||||||
:local UserName $username;
|
:local UserName $username;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
: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;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Date [ /system/clock/get date ];
|
:local Date [ /system/clock/get date ];
|
||||||
|
|
@ -61,8 +58,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;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# allow login page to load
|
# allow login page to load
|
||||||
|
|
@ -98,5 +94,5 @@
|
||||||
:delay 2s;
|
:delay 2s;
|
||||||
/interface/wifi/access-list/set $Entry action=accept;
|
/interface/wifi/access-list/set $Entry action=accept;
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue