mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
Merge branch 'FormatLine' into next
This commit is contained in:
commit
83e57e6aab
14 changed files with 120 additions and 89 deletions
|
@ -17,6 +17,7 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
|
@ -47,9 +48,9 @@ $WaitFullyConnected;
|
||||||
subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \
|
subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \
|
||||||
message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
|
message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Name: " . $Cloud->"name" . "\n" . \
|
[ $FormatLine "Name" ($Cloud->"name") ] . "\n" . \
|
||||||
"Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
|
[ $FormatLine "Size" ($Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)") ] . "\n" . \
|
||||||
"Download key: " . $Cloud->"secret-download-key"); silent=true });
|
[ $FormatLine "Download key" ($Cloud->"secret-download-key") ]); silent=true });
|
||||||
} on-error={
|
} on-error={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Cloud backup failed"); \
|
subject=([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Cloud backup failed"); \
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global MkDir;
|
:global MkDir;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
|
@ -91,9 +92,9 @@ $SendEMail2 ({ origin=$0; \
|
||||||
message=("See attached files for backup and config export for " . \
|
message=("See attached files for backup and config export for " . \
|
||||||
$Identity . ".\n\n" . \
|
$Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Backup file: " . $BackupFile . "\n" . \
|
[ $FormatLine "Backup file" $BackupFile ] . "\n" . \
|
||||||
"Export file: " . $ExportFile . "\n" . \
|
[ $FormatLine "Export file" $ExportFile ] . "\n" . \
|
||||||
"Config file: " . $ConfigFile); \
|
[ $FormatLine "Config file" $ConfigFile ]); \
|
||||||
attach=$Attach; remove-attach=true });
|
attach=$Attach; remove-attach=true });
|
||||||
|
|
||||||
# wait for the mail to be sent
|
# wait for the mail to be sent
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
|
:global FormatLine;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global MkDir;
|
:global MkDir;
|
||||||
|
@ -120,9 +121,9 @@ $SendNotification2 ({ origin=$0; \
|
||||||
([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \
|
([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \
|
||||||
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Backup file: " . $BackupFile . "\n" . \
|
[ $FormatLine "Backup file" $BackupFile ] . "\n" . \
|
||||||
"Export file: " . $ExportFile . "\n" . \
|
[ $FormatLine "Export file" $ExportFile ] . "\n" . \
|
||||||
"Config file: " . $ConfigFile); silent=true });
|
[ $FormatLine "Config file" $ConfigFile ]); silent=true });
|
||||||
|
|
||||||
:if ($Failed = 1) do={
|
:if ($Failed = 1) do={
|
||||||
:error "An error occured!";
|
:error "An error occured!";
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
:local FormatInfo do={
|
:local FormatInfo do={
|
||||||
:local CertVal $1;
|
:local CertVal $1;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
|
|
||||||
|
@ -84,25 +85,15 @@
|
||||||
:return [ $CharacterReplace [ $CharacterReplace [ :tostr $1 ] "w" "w " ] "d" "d " ];
|
:return [ $CharacterReplace [ $CharacterReplace [ :tostr $1 ] "w" "w " ] "d" "d " ];
|
||||||
}
|
}
|
||||||
|
|
||||||
:local FormatSANs do={
|
|
||||||
:local SANs $1;
|
|
||||||
:local Return "";
|
|
||||||
|
|
||||||
:foreach SAN in=$SANs do={
|
|
||||||
:set Return ($Return . "\n " . $SAN);
|
|
||||||
}
|
|
||||||
:return $Return;
|
|
||||||
}
|
|
||||||
|
|
||||||
:return ( \
|
:return ( \
|
||||||
"Name: " . ($CertVal->"name") . "\n" . \
|
[ $FormatLine "Name" ($CertVal->"name") ] . "\n" . \
|
||||||
[ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ("CommonName: " . ($CertVal->"common-name") . "\n") ] . \
|
[ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ([ $FormatLine "CommonName" ($CertVal->"common-name") ] . "\n") ] . \
|
||||||
[ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ("SubjectAltNames:" . [ $FormatSANs ($CertVal->"subject-alt-name") ] . "\n") ] . \
|
[ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ([ $FormatLine "SubjectAltNames" ($CertVal->"subject-alt-name") ] . "\n") ] . \
|
||||||
"Private key: " . [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] . "\n" . \
|
[ $FormatLine "Private key" [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] ] . "\n" . \
|
||||||
"Fingerprint: " . ($CertVal->"fingerprint") . "\n" . \
|
[ $FormatLine "Fingerprint" ($CertVal->"fingerprint") ] . "\n" . \
|
||||||
"Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \
|
[ $FormatLine "Issuer" ($CertVal->"ca" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN")) ] . "\n" . \
|
||||||
"Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \
|
[ $FormatLine "Validity" ($CertVal->"invalid-before" . " to " . $CertVal->"invalid-after") ] . "\n" . \
|
||||||
"Expires in: " . [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ]);
|
[ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
:global CheckHealthVoltagePercent;
|
:global CheckHealthVoltagePercent;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
@ -93,8 +94,8 @@ $ScriptLock $0;
|
||||||
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
||||||
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
||||||
"old value: " . ($CheckHealthLast->$Name) . " V\n" . \
|
[ $FormatLine "old value" ($CheckHealthLast->$Name . " V") ] . "\n" . \
|
||||||
"new value: " . $Value . " V") });
|
[ $FormatLine "new value" ($Value . " V") ]) });
|
||||||
} else={
|
} else={
|
||||||
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
:global SentLteFirmwareUpgradeNotification;
|
:global SentLteFirmwareUpgradeNotification;
|
||||||
|
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
|
@ -71,9 +72,9 @@
|
||||||
subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \
|
subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \
|
||||||
message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \
|
message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \
|
||||||
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
||||||
"Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
|
[ $FormatLine "Interface" [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] ] . "\n" . \
|
||||||
"Installed: " . ($Firmware->"installed") . "\n" . \
|
[ $FormatLine "Installed" ($Firmware->"installed") ] . "\n" . \
|
||||||
"Available: " . ($Firmware->"latest")); silent=true });
|
[ $FormatLine "Available" ($Firmware->"latest") ]); silent=true });
|
||||||
:set ($SentLteFirmwareUpgradeNotification->$IntName) ($Firmware->"latest");
|
:set ($SentLteFirmwareUpgradeNotification->$IntName) ($Firmware->"latest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
|
:global FormatLine;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
@ -69,15 +70,15 @@ $ScriptLock $0 false 10;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
||||||
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
||||||
"Controller: " . $Identity . "\n" . \
|
[ $FormatLine "Controller" $Identity ] . "\n" . \
|
||||||
"Interface: " . $RegVal->"interface" . "\n" . \
|
[ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
|
||||||
"SSID: " . $RegVal->"ssid" . "\n" . \
|
[ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
|
||||||
"MAC: " . $RegVal->"mac-address" . "\n" . \
|
[ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
|
||||||
"Vendor: " . $Vendor . "\n" . \
|
[ $FormatLine "Vendor" $Vendor ] . "\n" . \
|
||||||
"Hostname: " . $HostName . "\n" . \
|
[ $FormatLine "Hostname" $HostName ] . "\n" . \
|
||||||
"Address: " . $Address . "\n" . \
|
[ $FormatLine "Address" $Address ] . "\n" . \
|
||||||
"DNS name: " . $DnsName . "\n" . \
|
[ $FormatLine "DNS name" $DnsName ] . "\n" . \
|
||||||
"Date: " . $DateTime) });
|
[ $FormatLine "Date" $DateTime ]) });
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
|
:global FormatLine;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
@ -70,15 +71,15 @@ $ScriptLock $0 false 10;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
||||||
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
||||||
"Controller: " . $Identity . "\n" . \
|
[ $FormatLine "Controller" $Identity ] . "\n" . \
|
||||||
"Interface: " . $RegVal->"interface" . "\n" . \
|
[ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
|
||||||
"SSID: " . $RegVal->"ssid" . "\n" . \
|
[ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
|
||||||
"MAC: " . $RegVal->"mac-address" . "\n" . \
|
[ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
|
||||||
"Vendor: " . $Vendor . "\n" . \
|
[ $FormatLine "Vendor" $Vendor ] . "\n" . \
|
||||||
"Hostname: " . $HostName . "\n" . \
|
[ $FormatLine "Hostname" $HostName ] . "\n" . \
|
||||||
"Address: " . $Address . "\n" . \
|
[ $FormatLine "Address" $Address ] . "\n" . \
|
||||||
"DNS name: " . $DnsName . "\n" . \
|
[ $FormatLine "DNS name" $DnsName ] . "\n" . \
|
||||||
"Date: " . $DateTime) });
|
[ $FormatLine "Date" $DateTime ]) });
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
|
:global FormatLine;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
@ -71,15 +72,15 @@ $ScriptLock $0 false 10;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
|
||||||
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
|
||||||
"Controller: " . $Identity . "\n" . \
|
[ $FormatLine "Controller" $Identity ] . "\n" . \
|
||||||
"Interface: " . $RegVal->"interface" . "\n" . \
|
[ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
|
||||||
"SSID: " . $RegVal->"ssid" . "\n" . \
|
[ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
|
||||||
"MAC: " . $RegVal->"mac-address" . "\n" . \
|
[ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
|
||||||
"Vendor: " . $Vendor . "\n" . \
|
[ $FormatLine "Vendor" $Vendor ] . "\n" . \
|
||||||
"Hostname: " . $HostName . "\n" . \
|
[ $FormatLine "Hostname" $HostName ] . "\n" . \
|
||||||
"Address: " . $Address . "\n" . \
|
[ $FormatLine "Address" $Address ] . "\n" . \
|
||||||
"DNS name: " . $DnsName . "\n" . \
|
[ $FormatLine "DNS name" $DnsName ] . "\n" . \
|
||||||
"Date: " . $DateTime) });
|
[ $FormatLine "Date" $DateTime ]) });
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
|
@ -86,9 +87,9 @@ $WaitFullyConnected;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
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" . \
|
||||||
"SSID: " . $Ssid . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
[ $FormatLine "PSK" $NewPsk ] . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
[ $FormatLine "Date" $Date ] . "\n\n" . \
|
||||||
"A client device specific rule must not exist!"); link=$Link });
|
"A client device specific rule must not exist!"); link=$Link });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
|
@ -85,9 +86,9 @@ $WaitFullyConnected;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
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" . \
|
||||||
"SSID: " . $Ssid . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
[ $FormatLine "PSK" $NewPsk ] . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
[ $FormatLine "Date" $Date ] . "\n\n" . \
|
||||||
"A client device specific rule must not exist!"); link=$Link });
|
"A client device specific rule must not exist!"); link=$Link });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
:global DailyPskQrCodeUrl;
|
:global DailyPskQrCodeUrl;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
|
@ -93,9 +94,9 @@ $WaitFullyConnected;
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
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" . \
|
||||||
"SSID: " . $Ssid . "\n" . \
|
[ $FormatLine "SSID" $Ssid ] . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
[ $FormatLine "PSK" $NewPsk ] . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
[ $FormatLine "Date" $Date ] . "\n\n" . \
|
||||||
"A client device specific rule must not exist!"); link=$Link });
|
"A client device specific rule must not exist!"); link=$Link });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
:global DownloadPackage;
|
:global DownloadPackage;
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global EscapeForRegEx;
|
:global EscapeForRegEx;
|
||||||
|
:global FormatLine;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global GetRandom20CharAlNum;
|
:global GetRandom20CharAlNum;
|
||||||
:global GetRandom20CharHex;
|
:global GetRandom20CharHex;
|
||||||
|
@ -194,6 +195,7 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
|
:global FormatLine;
|
||||||
|
|
||||||
:local Resource [ /system/resource/get ];
|
:local Resource [ /system/resource/get ];
|
||||||
:local RouterBoard;
|
:local RouterBoard;
|
||||||
|
@ -204,27 +206,27 @@
|
||||||
:local Update [ /system/package/update/get ];
|
:local Update [ /system/package/update/get ];
|
||||||
|
|
||||||
:return ( \
|
:return ( \
|
||||||
"Hostname: " . $Identity . \
|
[ $FormatLine "Hostname" $Identity ] . "\n" . \
|
||||||
"\nBoard name: " . $Resource->"board-name" . \
|
[ $FormatLine "Board name" ($Resource->"board-name") ] . "\n" . \
|
||||||
"\nArchitecture: " . $Resource->"architecture-name" . \
|
[ $FormatLine "Architecture" ($Resource->"architecture-name") ] . "\n" . \
|
||||||
[ $IfThenElse ($RouterBoard->"routerboard" = true) \
|
[ $IfThenElse ($RouterBoard->"routerboard" = true) \
|
||||||
("\nModel: " . $RouterBoard->"model" . \
|
([ $FormatLine "Model" ($RouterBoard->"model") ] . \
|
||||||
[ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \
|
[ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \
|
||||||
(" " . $RouterBoard->"revision") ] . \
|
(" " . $RouterBoard->"revision") ] . "\n" . \
|
||||||
"\nSerial number: " . $RouterBoard->"serial-number") ] . \
|
[ $FormatLine "Serial number" ($RouterBoard->"serial-number") ] . "\n") ] . \
|
||||||
[ $IfThenElse ([ :len ($License->"level") ] > 0) \
|
[ $IfThenElse ([ :len ($License->"level") ] > 0) \
|
||||||
("\nLicense: " . $License->"level") ] . \
|
([ $FormatLine "License" ($License->"level") ] . "\n") ] . \
|
||||||
"\nRouterOS:" . \
|
"RouterOS:\n" . \
|
||||||
"\n Channel: " . $Update->"channel" . \
|
[ $FormatLine " Channel" ($Update->"channel") ] . "\n" . \
|
||||||
"\n Installed: " . $Update->"installed-version" . \
|
[ $FormatLine " Installed" ($Update->"installed-version") ] . "\n" . \
|
||||||
[ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
|
[ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
|
||||||
$Update->"installed-version" != $Update->"latest-version") \
|
$Update->"installed-version" != $Update->"latest-version") \
|
||||||
("\n Available: " . $Update->"latest-version") ] . \
|
([ $FormatLine " Available" ($Update->"latest-version") ] . "\n") ] . \
|
||||||
[ $IfThenElse ($RouterBoard->"routerboard" = true && \
|
[ $IfThenElse ($RouterBoard->"routerboard" = true && \
|
||||||
$RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \
|
$RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \
|
||||||
("\n Firmware: " . $RouterBoard->"current-firmware") ] . \
|
([ $FormatLine " Firmware" ($RouterBoard->"current-firmware") ] . "\n") ] . \
|
||||||
"\nRouterOS-Scripts:" . \
|
"RouterOS-Scripts:\n" . \
|
||||||
"\n Version: " . $ExpectedConfigVersion);
|
[ $FormatLine " Version" $ExpectedConfigVersion ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
# convert line endings, DOS -> UNIX
|
# convert line endings, DOS -> UNIX
|
||||||
|
@ -329,6 +331,32 @@
|
||||||
:return $Return;
|
:return $Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# format a line for output
|
||||||
|
:set FormatLine do={
|
||||||
|
:local Key [ :tostr $1 ];
|
||||||
|
:local Values [ :toarray $2 ];
|
||||||
|
:local Indent [ :tonum $3 ];
|
||||||
|
:local Spaces " ";
|
||||||
|
:local Return "";
|
||||||
|
|
||||||
|
:global EitherOr;
|
||||||
|
:global FormatLine;
|
||||||
|
|
||||||
|
:set Indent [ $EitherOr $Indent 16 ];
|
||||||
|
|
||||||
|
:if ([ :len $Key ] > 0) do={ :set Return ($Key . ":"); }
|
||||||
|
:if ([ :len $Key ] > ($Indent - 2)) do={
|
||||||
|
:set Return ($Return . "\n" . [ :pick $Spaces 0 $Indent ] . ($Values->0));
|
||||||
|
} else={
|
||||||
|
:set Return ($Return . [ :pick $Spaces 0 ($Indent - [ :len $Return ]) ] . ($Values->0));
|
||||||
|
}
|
||||||
|
:foreach Value in=[ :pick $Values 1 [ :len $Values ] ] do={
|
||||||
|
:set Return ($Return . "\n" . [ $FormatLine "" ({$Value}) $Indent ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
:return $Return;
|
||||||
|
}
|
||||||
|
|
||||||
# get MAC vendor
|
# get MAC vendor
|
||||||
:set GetMacVendor do={
|
:set GetMacVendor do={
|
||||||
:local Mac [ :tostr $1 ];
|
:local Mac [ :tostr $1 ];
|
||||||
|
|
|
@ -13,18 +13,19 @@
|
||||||
:set IPCalc do={
|
:set IPCalc do={
|
||||||
:local Input [ :tostr $1 ];
|
:local Input [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
:global IPCalcReturn;
|
:global IPCalcReturn;
|
||||||
:global PrettyPrint;
|
:global PrettyPrint;
|
||||||
|
|
||||||
:local Values [ $IPCalcReturn $1 ];
|
:local Values [ $IPCalcReturn $1 ];
|
||||||
|
|
||||||
$PrettyPrint ( \
|
$PrettyPrint ( \
|
||||||
"Address: " . $Values->"address" . "\n" . \
|
[ $FormatLine "Address" ($Values->"address") ] . "\n" . \
|
||||||
"Netmask: " . $Values->"netmask" . "\n" . \
|
[ $FormatLine "Netmask" ($Values->"netmask") ] . "\n" . \
|
||||||
"Network: " . $Values->"network" . "\n" . \
|
[ $FormatLine "Network" ($Values->"network") ] . "\n" . \
|
||||||
"HostMin: " . $Values->"hostmin" . "\n" . \
|
[ $FormatLine "HostMin" ($Values->"hostmin") ] . "\n" . \
|
||||||
"HostMax: " . $Values->"hostmax" . "\n" . \
|
[ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \
|
||||||
"Broadcast: " . $Values->"broadcast");
|
[ $FormatLine "Broadcast" ($Values->"broadcast") ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
# calculate and return netmask, network, min host, max host and broadcast
|
# calculate and return netmask, network, min host, max host and broadcast
|
||||||
|
|
Loading…
Reference in a new issue