aboutsummaryrefslogtreecommitdiffstats
path: root/hotspot-to-wpa-cleanup.template.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'hotspot-to-wpa-cleanup.template.rsc')
-rw-r--r--hotspot-to-wpa-cleanup.template.rsc28
1 files changed, 17 insertions, 11 deletions
diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc
index 7ac996c..d51e1d0 100644
--- a/hotspot-to-wpa-cleanup.template.rsc
+++ b/hotspot-to-wpa-cleanup.template.rsc
@@ -1,21 +1,23 @@
#!rsc by RouterOS
# RouterOS script: hotspot-to-wpa-cleanup%TEMPL%
-# Copyright (c) 2021-2024 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+# Copyright (c) 2021-2025 Christian Hesse <mail@eworm.de>
+# https://rsc.eworm.de/COPYING.md
#
# provides: lease-script, order=80
-# requires RouterOS, version=7.13
+# requires RouterOS, version=7.15
+# requires device-mode, hotspot
#
# manage and clean up private WPA passphrase after hotspot login
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/hotspot-to-wpa.md
+# https://rsc.eworm.de/doc/hotspot-to-wpa.md
#
# !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered.
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:do {
+:local ExitOK false;
+: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 EitherOr;
@@ -24,6 +26,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -54,7 +57,7 @@
:foreach Client in=[ /caps-man/access-list/find where comment~"^hotspot-to-wpa:" \
:foreach Client in=[ /interface/wifi/access-list/find where comment~"^hotspot-to-wpa:" \
- !(comment~[ /system/clock/get date ]) ] do={
+ !(comment~[ /system/clock/get date ]) mac-address ] do={
:local ClientVal [ /caps-man/access-list/get $Client ];
:local ClientVal [ /interface/wifi/access-list/get $Client ];
:if ([ :len [ /ip/dhcp-server/lease/find where !dynamic comment~"^hotspot-to-wpa:" \
@@ -67,8 +70,9 @@
}
:foreach Server,Timeout in=$DHCPServers do={
+ :local TimeoutExtra ($Timeout + [ /system/clock/get time ]);
:foreach Lease in=[ /ip/dhcp-server/lease/find where !dynamic status="waiting" \
- server=$Server last-seen>$Timeout comment~"^hotspot-to-wpa:" ] do={
+ server=$Server last-seen>$TimeoutExtra comment~"^hotspot-to-wpa:" ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
$LogPrint info $ScriptName ("Client with mac address " . ($LeaseVal->"mac-address") . \
" was not seen for " . ($LeaseVal->"last-seen") . ", removing.");
@@ -78,4 +82,6 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-} on-error={ }
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
+}