diff options
author | Christian Hesse <mail@eworm.de> | 2023-08-07 14:37:52 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-08-07 22:10:44 +0200 |
commit | 1b947f445bfffb099b0f0fdc2011672ae716aa51 (patch) | |
tree | 26089caffb01073a386bb6498b3781268de2c596 /daily-psk.template.rsc | |
parent | c37739c2f6b050c965e0fa734309e1ecbed90add (diff) |
Makefile: drop path rewriting, use pattern to filter
Diffstat (limited to 'daily-psk.template.rsc')
-rw-r--r-- | daily-psk.template.rsc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 777f6c0..ea0fb46 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -7,8 +7,8 @@ # update daily PSK (pre shared key) # https://git.eworm.de/cgit/routeros-scripts/about/doc/daily-psk.md # -# !! This is just a template! Replace '%PATH%' with 'caps-man' -# !! or 'interface wireless'! +# !! This is just a template to generate the real script! +# !! Pattern '%TEMPL%' is replaced, paths are filtered. :local 0 "daily-psk%TEMPL%"; :global GlobalFunctionsReady; @@ -55,24 +55,25 @@ $WaitFullyConnected; :local Date [ /system/clock/get date ]; :local NewPsk [ $GeneratePSK $Date ]; -:foreach AccList in=[ /%PATH%/access-list/find where comment~$DailyPskMatchComment ] do={ - :local IntName [ /interface/wireless/access-list/get $AccList interface ]; - :local Ssid [ /interface/wireless/get $IntName ssid ]; - :local OldPsk [ /interface/wireless/access-list/get $AccList private-pre-shared-key ]; - # /interface/wireless above - /caps-man below +:foreach AccList in=[ /caps-man/access-list/find where comment~$DailyPskMatchComment ] do={ +:foreach AccList in=[ /interface/wireless/access-list/find where comment~$DailyPskMatchComment ] do={ :local SsidRegExp [ /caps-man/access-list/get $AccList ssid-regexp ]; :local Configuration ([ /caps-man/configuration/find where ssid~$SsidRegExp ]->0); :local Ssid [ /caps-man/configuration/get $Configuration ssid ]; :local OldPsk [ /caps-man/access-list/get $AccList private-passphrase ]; + # /caps-man above - /interface/wireless below + :local IntName [ /interface/wireless/access-list/get $AccList interface ]; + :local Ssid [ /interface/wireless/get $IntName ssid ]; + :local OldPsk [ /interface/wireless/access-list/get $AccList private-pre-shared-key ]; :local Skip 0; :if ($NewPsk != $OldPsk) do={ $LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false; - /interface/wireless/access-list/set $AccList private-pre-shared-key=$NewPsk; /caps-man/access-list/set $AccList private-passphrase=$NewPsk; + /interface/wireless/access-list/set $AccList private-pre-shared-key=$NewPsk; - :if ([ :len [ /interface/wireless/find where name=$IntName !disabled ] ] = 1) do={ :if ([ :len [ /caps-man/actual-interface-configuration/find where configuration.ssid=$Ssid !disabled ] ] > 0) do={ + :if ([ :len [ /interface/wireless/find where name=$IntName !disabled ] ] = 1) do={ :foreach SeenSsid in=$Seen do={ :if ($SeenSsid = $Ssid) do={ $LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false; |