mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
daily-psk: move code into function
This commit is contained in:
parent
e2b87c8634
commit
31da6b8bd5
5 changed files with 320 additions and 295 deletions
|
@ -11,10 +11,12 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
:local 0 [ :jobname ];
|
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:local Main do={
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global DailyPskMatchComment;
|
:global DailyPskMatchComment;
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $ScriptName;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
# return pseudo-random string for PSK
|
# return pseudo-random string for PSK
|
||||||
|
@ -64,16 +66,16 @@ $WaitFullyConnected;
|
||||||
:local Skip 0;
|
:local Skip 0;
|
||||||
|
|
||||||
:if ($NewPsk != $OldPsk) do={
|
:if ($NewPsk != $OldPsk) do={
|
||||||
$LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
$LogPrintExit2 info $ScriptName ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
||||||
/caps-man/access-list/set $AccList private-passphrase=$NewPsk;
|
/caps-man/access-list/set $AccList private-passphrase=$NewPsk;
|
||||||
|
|
||||||
:if ([ :len [ /caps-man/actual-interface-configuration/find where configuration.ssid=$Ssid !disabled ] ] > 0) do={
|
:if ([ :len [ /caps-man/actual-interface-configuration/find where configuration.ssid=$Ssid !disabled ] ] > 0) do={
|
||||||
:if ($Seen->$Ssid = 1) do={
|
:if ($Seen->$Ssid = 1) do={
|
||||||
$LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
$LogPrintExit2 debug $ScriptName ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Link ($DailyPskQrCodeUrl . \
|
:local Link ($DailyPskQrCodeUrl . \
|
||||||
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
||||||
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
||||||
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
|
@ -85,3 +87,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Main [ :jobname ];
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
:local 0 [ :jobname ];
|
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:local Main do={
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global DailyPskMatchComment;
|
:global DailyPskMatchComment;
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $ScriptName;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
# return pseudo-random string for PSK
|
# return pseudo-random string for PSK
|
||||||
|
@ -63,16 +65,16 @@ $WaitFullyConnected;
|
||||||
:local Skip 0;
|
:local Skip 0;
|
||||||
|
|
||||||
:if ($NewPsk != $OldPsk) do={
|
:if ($NewPsk != $OldPsk) do={
|
||||||
$LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
$LogPrintExit2 info $ScriptName ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
||||||
/interface/wireless/access-list/set $AccList private-pre-shared-key=$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 [ /interface/wireless/find where name=$IntName !disabled ] ] = 1) do={
|
||||||
:if ($Seen->$Ssid = 1) do={
|
:if ($Seen->$Ssid = 1) do={
|
||||||
$LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
$LogPrintExit2 debug $ScriptName ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Link ($DailyPskQrCodeUrl . \
|
:local Link ($DailyPskQrCodeUrl . \
|
||||||
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
||||||
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
||||||
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
|
@ -84,3 +86,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Main [ :jobname ];
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
# !! 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 0 [ :jobname ];
|
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:local Main do={
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global DailyPskMatchComment;
|
:global DailyPskMatchComment;
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -29,7 +31,7 @@
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $ScriptName;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
# return pseudo-random string for PSK
|
# return pseudo-random string for PSK
|
||||||
|
@ -80,7 +82,7 @@ $WaitFullyConnected;
|
||||||
:local Skip 0;
|
:local Skip 0;
|
||||||
|
|
||||||
:if ($NewPsk != $OldPsk) do={
|
:if ($NewPsk != $OldPsk) do={
|
||||||
$LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
$LogPrintExit2 info $ScriptName ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
||||||
/caps-man/access-list/set $AccList private-passphrase=$NewPsk;
|
/caps-man/access-list/set $AccList private-passphrase=$NewPsk;
|
||||||
/interface/wifi/access-list/set $AccList passphrase=$NewPsk;
|
/interface/wifi/access-list/set $AccList passphrase=$NewPsk;
|
||||||
/interface/wifiwave2/access-list/set $AccList passphrase=$NewPsk;
|
/interface/wifiwave2/access-list/set $AccList passphrase=$NewPsk;
|
||||||
|
@ -91,11 +93,11 @@ $WaitFullyConnected;
|
||||||
:if ([ :len [ /interface/wifiwave2/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
:if ([ :len [ /interface/wifiwave2/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
||||||
:if ([ :len [ /interface/wireless/find where name=$IntName !disabled ] ] = 1) do={
|
:if ([ :len [ /interface/wireless/find where name=$IntName !disabled ] ] = 1) do={
|
||||||
:if ($Seen->$Ssid = 1) do={
|
:if ($Seen->$Ssid = 1) do={
|
||||||
$LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
$LogPrintExit2 debug $ScriptName ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Link ($DailyPskQrCodeUrl . \
|
:local Link ($DailyPskQrCodeUrl . \
|
||||||
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
||||||
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
||||||
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
|
@ -107,3 +109,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Main [ :jobname ];
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
:local 0 [ :jobname ];
|
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:local Main do={
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global DailyPskMatchComment;
|
:global DailyPskMatchComment;
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $ScriptName;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
# return pseudo-random string for PSK
|
# return pseudo-random string for PSK
|
||||||
|
@ -64,16 +66,16 @@ $WaitFullyConnected;
|
||||||
:local Skip 0;
|
:local Skip 0;
|
||||||
|
|
||||||
:if ($NewPsk != $OldPsk) do={
|
:if ($NewPsk != $OldPsk) do={
|
||||||
$LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
$LogPrintExit2 info $ScriptName ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
||||||
/interface/wifi/access-list/set $AccList passphrase=$NewPsk;
|
/interface/wifi/access-list/set $AccList passphrase=$NewPsk;
|
||||||
|
|
||||||
:if ([ :len [ /interface/wifi/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
:if ([ :len [ /interface/wifi/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
||||||
:if ($Seen->$Ssid = 1) do={
|
:if ($Seen->$Ssid = 1) do={
|
||||||
$LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
$LogPrintExit2 debug $ScriptName ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Link ($DailyPskQrCodeUrl . \
|
:local Link ($DailyPskQrCodeUrl . \
|
||||||
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
||||||
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
||||||
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
|
@ -85,3 +87,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Main [ :jobname ];
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#
|
#
|
||||||
# !! Do not edit this file, it is generated from template!
|
# !! Do not edit this file, it is generated from template!
|
||||||
|
|
||||||
:local 0 [ :jobname ];
|
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:local Main do={
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global DailyPskMatchComment;
|
:global DailyPskMatchComment;
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $ScriptName;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
# return pseudo-random string for PSK
|
# return pseudo-random string for PSK
|
||||||
|
@ -64,16 +66,16 @@ $WaitFullyConnected;
|
||||||
:local Skip 0;
|
:local Skip 0;
|
||||||
|
|
||||||
:if ($NewPsk != $OldPsk) do={
|
:if ($NewPsk != $OldPsk) do={
|
||||||
$LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
$LogPrintExit2 info $ScriptName ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
|
||||||
/interface/wifiwave2/access-list/set $AccList passphrase=$NewPsk;
|
/interface/wifiwave2/access-list/set $AccList passphrase=$NewPsk;
|
||||||
|
|
||||||
:if ([ :len [ /interface/wifiwave2/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
:if ([ :len [ /interface/wifiwave2/actual-configuration/find where configuration.ssid=$Ssid ] ] > 0) do={
|
||||||
:if ($Seen->$Ssid = 1) do={
|
:if ($Seen->$Ssid = 1) do={
|
||||||
$LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
$LogPrintExit2 debug $ScriptName ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Link ($DailyPskQrCodeUrl . \
|
:local Link ($DailyPskQrCodeUrl . \
|
||||||
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
"?scale=8&level=1&ssid=" . [ $UrlEncode $Ssid ] . "&pass=" . [ $UrlEncode $NewPsk ]);
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
|
||||||
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
|
||||||
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
|
@ -85,3 +87,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Main [ :jobname ];
|
||||||
|
|
Loading…
Reference in a new issue