diff options
author | Christian Hesse <mail@eworm.de> | 2018-07-05 15:29:26 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2018-07-05 15:34:08 +0200 |
commit | e1f134ead584c7b2e9ed406f5520d7f1a23294aa (patch) | |
tree | 929660280fb0acc183401d7e59a40f1cd7e8992c /email-daily-psk | |
parent | 1d99dc38ff1f583d6e46adc5d1ba3455114d53c1 (diff) |
add scripts
Diffstat (limited to 'email-daily-psk')
-rw-r--r-- | email-daily-psk | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/email-daily-psk b/email-daily-psk new file mode 100644 index 0000000..af991ca --- /dev/null +++ b/email-daily-psk @@ -0,0 +1,47 @@ +# RouterOS script: email-daily-psk +# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de> +# +# email daily PSK (pre shared key) + +:global "identity"; +:global "email-general-to"; +:global "email-general-cc"; +:global "daily-psk-match-comment"; + +:local "seen-ssids" { "" }; + +: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 psk [ / interface wireless access-list get $acclist private-pre-shared-key ]; + + :local seen 0; + :foreach "seen-ssid" in=$"seen-ssids" do={ + :if ($"seen-ssid" = $ssid) do={ + :set seen 1; + } + } + + :if ($seen = 0) do={ + :set $"seen-ssids" { $"seen-ssids"; $ssid }; + + :local host "www.eworm.de" + :local srcpath ("/cgi-bin/cqrlogo-wifi.cgi" . \ + "?scale=8" . \ + "&level=1" . \ + "&ssid=" . $ssid . \ + "&pass=" . $psk); + + / tool fetch mode=https check-certificate=yes-without-crl address=$host host=$host \ + src-path=$srcpath dst-path=qrcode-daily.png; + + / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \ + subject=("[" . $identity . "] daily PSK " . $ssid) \ + body=("This is the daily PSK on " . $identity . ":\n\n" . \ + "SSID: " . $ssid . "\n" . \ + "PSK: " . $psk . "\n" . \ + "Date: " . [ / system clock get date ] . "\n\n" . \ + "https://" . $host . $srcpath) \ + file=qrcode-daily.png; + } +} |