diff options
author | Christian Hesse <mail@eworm.de> | 2018-08-17 09:01:52 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2018-08-17 09:01:52 +0200 |
commit | 8c2c738ec5ae7c6e1266319763f16559d6360d0e (patch) | |
tree | b775679a2c29cfed0105037e04f1f2ae67168473 | |
parent | 81a125471aab78eebe63994779e011593e706796 (diff) |
email-daily-psk: send for active interfaces only
... and handle missing interface for accesslist entry.
-rw-r--r-- | email-daily-psk | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/email-daily-psk b/email-daily-psk index 62c50c0..5bbf7eb 100644 --- a/email-daily-psk +++ b/email-daily-psk @@ -8,20 +8,31 @@ :global "email-general-cc"; :global "daily-psk-match-comment"; -:local "seen-ssids" { "" }; +:local seen { "" }; :foreach acclist in=[ / interface wireless access-list find where comment~$"daily-psk-match-comment" ] do={ - :local interface [ / interface wireless access-list get $acclist interface ]; - :local ssid [ / interface wireless get $interface ssid ]; + :local skip 0; + :local intname [ / interface wireless access-list get $acclist interface ]; :local psk [ / interface wireless access-list get $acclist private-pre-shared-key ]; + :local interface [ / interface wireless find where name=$intname disabled=no ]; + :local ssid; + + :if ([ :len $interface ] = 1) do={ + :set ssid [ / interface wireless get $interface ssid ]; + } else={ + :log debug "Missing active interface for access list entry, skipping."; + :set skip 1; + } - :local seen 0; - :foreach "seen-ssid" in=$"seen-ssids" do={ - :if ($"seen-ssid" = $ssid) do={ :set seen 1; } + :foreach "seen-ssid" in=$seen do={ + :if ($"seen-ssid" = $ssid) do={ + :log debug ("Already sent a mail for SSID " . $ssid . ", skipping."); + :set skip 1; + } } - :if ($seen = 0) do={ - :set $"seen-ssids" { $"seen-ssids"; $ssid }; + :if ($skip = 0) do={ + :set $seen { $seen; $ssid }; :local host "www.eworm.de" :local srcpath ("/cgi-bin/cqrlogo-wifi.cgi" . \ |