From cb338c76a8eb19a3ed1a73df330c3ddf638c7c39 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:15:04 +0200 Subject: global-functions: introduce $FormatLine --- global-functions.rsc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index e682edc..501ea92 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -29,6 +29,7 @@ :global DownloadPackage; :global EitherOr; :global EscapeForRegEx; +:global FormatLine; :global GetMacVendor; :global GetRandom20CharAlNum; :global GetRandom20CharHex; @@ -329,6 +330,32 @@ :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 :set GetMacVendor do={ :local Mac [ :tostr $1 ]; -- cgit v1.2.3-54-g00ecf From fb12aabf3e8685aaa21185b145caf431ca44b0d4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:44:56 +0200 Subject: global-functions: $DeviceInfo: use $FormatLine --- global-functions.rsc | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 501ea92..45fda9f 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -195,6 +195,7 @@ :global Identity; :global IfThenElse; + :global FormatLine; :local Resource [ /system/resource/get ]; :local RouterBoard; @@ -205,27 +206,27 @@ :local Update [ /system/package/update/get ]; :return ( \ - "Hostname: " . $Identity . \ - "\nBoard name: " . $Resource->"board-name" . \ - "\nArchitecture: " . $Resource->"architecture-name" . \ + [ $FormatLine "Hostname" $Identity ] . "\n" . \ + [ $FormatLine "Board name" ($Resource->"board-name") ] . "\n" . \ + [ $FormatLine "Architecture" ($Resource->"architecture-name") ] . "\n" . \ [ $IfThenElse ($RouterBoard->"routerboard" = true) \ - ("\nModel: " . $RouterBoard->"model" . \ - [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \ - (" " . $RouterBoard->"revision") ] . \ - "\nSerial number: " . $RouterBoard->"serial-number") ] . \ + ([ $FormatLine "Model" ($RouterBoard->"model") ] . \ + [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \ + (" " . $RouterBoard->"revision") ] . "\n" . \ + [ $FormatLine "Serial number" ($RouterBoard->"serial-number") ] . "\n") ] . \ [ $IfThenElse ([ :len ($License->"level") ] > 0) \ - ("\nLicense: " . $License->"level") ] . \ - "\nRouterOS:" . \ - "\n Channel: " . $Update->"channel" . \ - "\n Installed: " . $Update->"installed-version" . \ + ([ $FormatLine "License" ($License->"level") ] . "\n") ] . \ + "RouterOS:\n" . \ + [ $FormatLine " Channel" ($Update->"channel") ] . "\n" . \ + [ $FormatLine " Installed" ($Update->"installed-version") ] . "\n" . \ [ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \ $Update->"installed-version" != $Update->"latest-version") \ - ("\n Available: " . $Update->"latest-version") ] . \ + ([ $FormatLine " Available" ($Update->"latest-version") ] . "\n") ] . \ [ $IfThenElse ($RouterBoard->"routerboard" = true && \ $RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \ - ("\n Firmware: " . $RouterBoard->"current-firmware") ] . \ - "\nRouterOS-Scripts:" . \ - "\n Version: " . $ExpectedConfigVersion); + ([ $FormatLine " Firmware" ($RouterBoard->"current-firmware") ] . "\n") ] . \ + "RouterOS-Scripts:\n" . \ + [ $FormatLine " Version" $ExpectedConfigVersion ]); } # convert line endings, DOS -> UNIX -- cgit v1.2.3-54-g00ecf From 31553f86a6bbdf1ba8c46548763eb7ad6e6c74f5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:18:51 +0200 Subject: backup-cloud: use $FormatLine --- backup-cloud.rsc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backup-cloud.rsc b/backup-cloud.rsc index b75d5cb..b6f6025 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -17,6 +17,7 @@ :global Identity; :global DeviceInfo; +:global FormatLine; :global LogPrintExit2; :global RandomDelay; :global ScriptFromTerminal; @@ -47,9 +48,9 @@ $WaitFullyConnected; subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \ message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \ [ $DeviceInfo ] . "\n\n" . \ - "Name: " . $Cloud->"name" . "\n" . \ - "Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \ - "Download key: " . $Cloud->"secret-download-key"); silent=true }); + [ $FormatLine "Name" ($Cloud->"name") ] . "\n" . \ + [ $FormatLine "Size" ($Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)") ] . "\n" . \ + [ $FormatLine "Download key" ($Cloud->"secret-download-key") ]); silent=true }); } on-error={ $SendNotification2 ({ origin=$0; \ subject=([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Cloud backup failed"); \ -- cgit v1.2.3-54-g00ecf From 637b5e21daa17b369c07667be993b1e125470e3f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:47:37 +0200 Subject: backup-email: use $FormatLine --- backup-email.rsc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index ba12494..e8837a0 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -22,6 +22,7 @@ :global CharacterReplace; :global DeviceInfo; +:global FormatLine; :global LogPrintExit2; :global MkDir; :global RandomDelay; @@ -91,9 +92,9 @@ $SendEMail2 ({ origin=$0; \ message=("See attached files for backup and config export for " . \ $Identity . ".\n\n" . \ [ $DeviceInfo ] . "\n\n" . \ - "Backup file: " . $BackupFile . "\n" . \ - "Export file: " . $ExportFile . "\n" . \ - "Config file: " . $ConfigFile); \ + [ $FormatLine "Backup file" $BackupFile ] . "\n" . \ + [ $FormatLine "Export file" $ExportFile ] . "\n" . \ + [ $FormatLine "Config file" $ConfigFile ]); \ attach=$Attach; remove-attach=true }); # wait for the mail to be sent -- cgit v1.2.3-54-g00ecf From bac6a72d519a6aead5a3920773da6365c260092a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:48:56 +0200 Subject: backup-upload: use $FormatLine --- backup-upload.rsc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 4c09d4a..9fb35d8 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -25,6 +25,7 @@ :global CharacterReplace; :global DeviceInfo; +:global FormatLine; :global IfThenElse; :global LogPrintExit2; :global MkDir; @@ -120,9 +121,9 @@ $SendNotification2 ({ origin=$0; \ ([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \ message=("Backup and config export upload for " . $Identity . ".\n\n" . \ [ $DeviceInfo ] . "\n\n" . \ - "Backup file: " . $BackupFile . "\n" . \ - "Export file: " . $ExportFile . "\n" . \ - "Config file: " . $ConfigFile); silent=true }); + [ $FormatLine "Backup file" $BackupFile ] . "\n" . \ + [ $FormatLine "Export file" $ExportFile ] . "\n" . \ + [ $FormatLine "Config file" $ConfigFile ]); silent=true }); :if ($Failed = 1) do={ :error "An error occured!"; -- cgit v1.2.3-54-g00ecf From 7ed70bdb2631afe0b9a480ea7b1cc14438dea532 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:55:03 +0200 Subject: check-certificates: use $FormatLine --- check-certificates.rsc | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 2b76873..7e9fbe2 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -76,6 +76,7 @@ :local FormatInfo do={ :local CertVal $1; + :global FormatLine; :global IfThenElse; :global ParseKeyValueStore; @@ -84,25 +85,15 @@ :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 ( \ - "Name: " . ($CertVal->"name") . "\n" . \ - [ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ("CommonName: " . ($CertVal->"common-name") . "\n") ] . \ - [ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ("SubjectAltNames:" . [ $FormatSANs ($CertVal->"subject-alt-name") ] . "\n") ] . \ - "Private key: " . [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] . "\n" . \ - "Fingerprint: " . ($CertVal->"fingerprint") . "\n" . \ - "Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \ - "Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \ - "Expires in: " . [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ]); + [ $FormatLine "Name" ($CertVal->"name") ] . "\n" . \ + [ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ([ $FormatLine "CommonName" ($CertVal->"common-name") ] . "\n") ] . \ + [ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ([ $FormatLine "SubjectAltNames" ($CertVal->"subject-alt-name") ] . "\n") ] . \ + [ $FormatLine "Private key" [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] ] . "\n" . \ + [ $FormatLine "Fingerprint" ($CertVal->"fingerprint") ] . "\n" . \ + [ $FormatLine "Issuer" ($CertVal->"ca" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN")) ] . "\n" . \ + [ $FormatLine "Validity" ($CertVal->"invalid-before" . " to " . $CertVal->"invalid-after") ] . "\n" . \ + [ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]); } $WaitFullyConnected; -- cgit v1.2.3-54-g00ecf From b1cb4cb10f74be294fd234459e864cbf2762bae0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:58:24 +0200 Subject: check-health: use $FormatLine --- check-health.rsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index e208bac..af0d70b 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -21,6 +21,7 @@ :global CheckHealthVoltagePercent; :global Identity; +:global FormatLine; :global IfThenElse; :global LogPrintExit2; :global ScriptLock; @@ -93,8 +94,8 @@ $ScriptLock $0; subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \ $NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \ message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \ - "old value: " . ($CheckHealthLast->$Name) . " V\n" . \ - "new value: " . $Value . " V") }); + [ $FormatLine "old value" ($CheckHealthLast->$Name . " V") ] . "\n" . \ + [ $FormatLine "new value" ($Value . " V") ]) }); } else={ :if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={ $SendNotification2 ({ origin=$0; \ -- cgit v1.2.3-54-g00ecf From 3f9480f9f2c89ab80cacdc7f8b850707d757ab43 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 21 Apr 2023 00:01:06 +0200 Subject: check-lte-firmware-upgrade: use $FormatLine --- check-lte-firmware-upgrade.rsc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index 02e864b..81bdf9b 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -23,6 +23,7 @@ :global SentLteFirmwareUpgradeNotification; :global CharacterReplace; + :global FormatLine; :global LogPrintExit2; :global ScriptFromTerminal; :global SendNotification2; @@ -71,9 +72,9 @@ subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \ message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \ "LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \ - "Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \ - "Installed: " . ($Firmware->"installed") . "\n" . \ - "Available: " . ($Firmware->"latest")); silent=true }); + [ $FormatLine "Interface" [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] ] . "\n" . \ + [ $FormatLine "Installed" ($Firmware->"installed") ] . "\n" . \ + [ $FormatLine "Available" ($Firmware->"latest") ]); silent=true }); :set ($SentLteFirmwareUpgradeNotification->$IntName) ($Firmware->"latest"); } -- cgit v1.2.3-54-g00ecf From b705ceae591205b5eba54ee2f6a1ffb9066f2779 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 21 Apr 2023 00:03:55 +0200 Subject: collect-wireless-mac: use $FormatLine --- collect-wireless-mac.capsman.rsc | 19 ++++++++++--------- collect-wireless-mac.local.rsc | 19 ++++++++++--------- collect-wireless-mac.template.rsc | 19 ++++++++++--------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index e814fa9..094ffc0 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -17,6 +17,7 @@ :global Identity; :global EitherOr; +:global FormatLine; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -69,15 +70,15 @@ $ScriptLock $0 false 10; $SendNotification2 ({ origin=$0; \ 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" . \ - "Controller: " . $Identity . "\n" . \ - "Interface: " . $RegVal->"interface" . "\n" . \ - "SSID: " . $RegVal->"ssid" . "\n" . \ - "MAC: " . $RegVal->"mac-address" . "\n" . \ - "Vendor: " . $Vendor . "\n" . \ - "Hostname: " . $HostName . "\n" . \ - "Address: " . $Address . "\n" . \ - "DNS name: " . $DnsName . "\n" . \ - "Date: " . $DateTime) }); + [ $FormatLine "Controller" $Identity ] . "\n" . \ + [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \ + [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \ + [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \ + [ $FormatLine "Vendor" $Vendor ] . "\n" . \ + [ $FormatLine "Hostname" $HostName ] . "\n" . \ + [ $FormatLine "Address" $Address ] . "\n" . \ + [ $FormatLine "DNS name" $DnsName ] . "\n" . \ + [ $FormatLine "Date" $DateTime ]) }); } } else={ $LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false; diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index ee07f54..23eb9fa 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -17,6 +17,7 @@ :global Identity; :global EitherOr; +:global FormatLine; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -70,15 +71,15 @@ $ScriptLock $0 false 10; $SendNotification2 ({ origin=$0; \ 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" . \ - "Controller: " . $Identity . "\n" . \ - "Interface: " . $RegVal->"interface" . "\n" . \ - "SSID: " . $RegVal->"ssid" . "\n" . \ - "MAC: " . $RegVal->"mac-address" . "\n" . \ - "Vendor: " . $Vendor . "\n" . \ - "Hostname: " . $HostName . "\n" . \ - "Address: " . $Address . "\n" . \ - "DNS name: " . $DnsName . "\n" . \ - "Date: " . $DateTime) }); + [ $FormatLine "Controller" $Identity ] . "\n" . \ + [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \ + [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \ + [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \ + [ $FormatLine "Vendor" $Vendor ] . "\n" . \ + [ $FormatLine "Hostname" $HostName ] . "\n" . \ + [ $FormatLine "Address" $Address ] . "\n" . \ + [ $FormatLine "DNS name" $DnsName ] . "\n" . \ + [ $FormatLine "Date" $DateTime ]) }); } } else={ $LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false; diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index c315385..a8983d9 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -18,6 +18,7 @@ :global Identity; :global EitherOr; +:global FormatLine; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -71,15 +72,15 @@ $ScriptLock $0 false 10; $SendNotification2 ({ origin=$0; \ 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" . \ - "Controller: " . $Identity . "\n" . \ - "Interface: " . $RegVal->"interface" . "\n" . \ - "SSID: " . $RegVal->"ssid" . "\n" . \ - "MAC: " . $RegVal->"mac-address" . "\n" . \ - "Vendor: " . $Vendor . "\n" . \ - "Hostname: " . $HostName . "\n" . \ - "Address: " . $Address . "\n" . \ - "DNS name: " . $DnsName . "\n" . \ - "Date: " . $DateTime) }); + [ $FormatLine "Controller" $Identity ] . "\n" . \ + [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \ + [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \ + [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \ + [ $FormatLine "Vendor" $Vendor ] . "\n" . \ + [ $FormatLine "Hostname" $HostName ] . "\n" . \ + [ $FormatLine "Address" $Address ] . "\n" . \ + [ $FormatLine "DNS name" $DnsName ] . "\n" . \ + [ $FormatLine "Date" $DateTime ]) }); } } else={ $LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false; -- cgit v1.2.3-54-g00ecf From 944b2f58649835dbc6abe83bab6d4500dd046fd8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 21 Apr 2023 00:05:46 +0200 Subject: daily-psk: use $FormatLine --- daily-psk.capsman.rsc | 7 ++++--- daily-psk.local.rsc | 7 ++++--- daily-psk.template.rsc | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index 17a09e1..e589991 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -17,6 +17,7 @@ :global DailyPskQrCodeUrl; :global Identity; +:global FormatLine; :global LogPrintExit2; :global SendNotification2; :global SymbolForNotification; @@ -86,9 +87,9 @@ $WaitFullyConnected; $SendNotification2 ({ origin=$0; \ subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \ message=("This is the daily PSK on " . $Identity . ":\n\n" . \ - "SSID: " . $Ssid . "\n" . \ - "PSK: " . $NewPsk . "\n" . \ - "Date: " . $Date . "\n\n" . \ + [ $FormatLine "SSID" $Ssid ] . "\n" . \ + [ $FormatLine "PSK" $NewPsk ] . "\n" . \ + [ $FormatLine "Date" $Date ] . "\n\n" . \ "A client device specific rule must not exist!"); link=$Link }); } } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index 17a60f7..df17173 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -17,6 +17,7 @@ :global DailyPskQrCodeUrl; :global Identity; +:global FormatLine; :global LogPrintExit2; :global SendNotification2; :global SymbolForNotification; @@ -85,9 +86,9 @@ $WaitFullyConnected; $SendNotification2 ({ origin=$0; \ subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \ message=("This is the daily PSK on " . $Identity . ":\n\n" . \ - "SSID: " . $Ssid . "\n" . \ - "PSK: " . $NewPsk . "\n" . \ - "Date: " . $Date . "\n\n" . \ + [ $FormatLine "SSID" $Ssid ] . "\n" . \ + [ $FormatLine "PSK" $NewPsk ] . "\n" . \ + [ $FormatLine "Date" $Date ] . "\n\n" . \ "A client device specific rule must not exist!"); link=$Link }); } } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 7e41a1f..5f30ce3 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -18,6 +18,7 @@ :global DailyPskQrCodeUrl; :global Identity; +:global FormatLine; :global LogPrintExit2; :global SendNotification2; :global SymbolForNotification; @@ -93,9 +94,9 @@ $WaitFullyConnected; $SendNotification2 ({ origin=$0; \ subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \ message=("This is the daily PSK on " . $Identity . ":\n\n" . \ - "SSID: " . $Ssid . "\n" . \ - "PSK: " . $NewPsk . "\n" . \ - "Date: " . $Date . "\n\n" . \ + [ $FormatLine "SSID" $Ssid ] . "\n" . \ + [ $FormatLine "PSK" $NewPsk ] . "\n" . \ + [ $FormatLine "Date" $Date ] . "\n\n" . \ "A client device specific rule must not exist!"); link=$Link }); } } -- cgit v1.2.3-54-g00ecf From 82b5ae174ac15bb6c2b7180980da12c1908de7df Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 21 Apr 2023 00:12:31 +0200 Subject: mod/ipcalc: use $FormatLine --- mod/ipcalc.rsc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc index ee78378..eaa5c97 100644 --- a/mod/ipcalc.rsc +++ b/mod/ipcalc.rsc @@ -13,18 +13,19 @@ :set IPCalc do={ :local Input [ :tostr $1 ]; + :global FormatLine; :global IPCalcReturn; :global PrettyPrint; :local Values [ $IPCalcReturn $1 ]; $PrettyPrint ( \ - "Address: " . $Values->"address" . "\n" . \ - "Netmask: " . $Values->"netmask" . "\n" . \ - "Network: " . $Values->"network" . "\n" . \ - "HostMin: " . $Values->"hostmin" . "\n" . \ - "HostMax: " . $Values->"hostmax" . "\n" . \ - "Broadcast: " . $Values->"broadcast"); + [ $FormatLine "Address" ($Values->"address") ] . "\n" . \ + [ $FormatLine "Netmask" ($Values->"netmask") ] . "\n" . \ + [ $FormatLine "Network" ($Values->"network") ] . "\n" . \ + [ $FormatLine "HostMin" ($Values->"hostmin") ] . "\n" . \ + [ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \ + [ $FormatLine "Broadcast" ($Values->"broadcast") ]); } # calculate and return netmask, network, min host, max host and broadcast -- cgit v1.2.3-54-g00ecf