aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-02-22 15:14:10 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-02-24 21:51:54 +0100
commitf46db918453dcb8878b9a0de6e122fb0ea2224d9 (patch)
tree31544a450651d0705ecdea0c3d35e650ef784d67
parentb0e52aa2d1baa78fc9d025c0671fea8babba0ec2 (diff)
global: give script or function name in log messages
-rw-r--r--accesslist-duplicates.capsman1
-rw-r--r--accesslist-duplicates.local1
-rw-r--r--accesslist-duplicates.template1
-rw-r--r--bridge-port-to-default11
-rw-r--r--bridge-port-toggle1
-rw-r--r--capsman-download-packages9
-rw-r--r--capsman-rolling-upgrade5
-rw-r--r--certificate-renew-issued9
-rw-r--r--check-certificates25
-rw-r--r--check-health7
-rw-r--r--check-lte-firmware-upgrade7
-rw-r--r--check-routeros-update21
-rw-r--r--cloud-backup5
-rw-r--r--collect-wireless-mac.capsman9
-rw-r--r--collect-wireless-mac.local9
-rw-r--r--collect-wireless-mac.template9
-rw-r--r--daily-psk.capsman7
-rw-r--r--daily-psk.local7
-rw-r--r--daily-psk.template7
-rw-r--r--dhcp-lease-comment.capsman5
-rw-r--r--dhcp-lease-comment.local5
-rw-r--r--dhcp-lease-comment.template5
-rw-r--r--dhcp-to-dns15
-rw-r--r--early-errors4
-rw-r--r--email-backup7
-rw-r--r--global-functions130
-rw-r--r--global-wait4
-rw-r--r--gps-track7
-rw-r--r--hotspot-to-wpa7
-rw-r--r--ipv6-update5
-rw-r--r--lease-script5
-rw-r--r--log-forward5
-rw-r--r--mode-button13
-rw-r--r--mode-button-event4
-rw-r--r--mode-button-scheduler4
-rw-r--r--netwatch-notify11
-rw-r--r--ospf-to-leds5
-rw-r--r--packages-update27
-rw-r--r--ppp-on-up5
-rw-r--r--rotate-ntp9
-rw-r--r--script-updates4
-rw-r--r--sms-action5
-rw-r--r--sms-forward7
-rw-r--r--update-gre-address5
-rw-r--r--update-tunnelbroker11
-rw-r--r--upload-backup9
46 files changed, 262 insertions, 212 deletions
diff --git a/accesslist-duplicates.capsman b/accesslist-duplicates.capsman
index 54271c3..5fcf6ae 100644
--- a/accesslist-duplicates.capsman
+++ b/accesslist-duplicates.capsman
@@ -8,6 +8,7 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "accesslist-duplicates.capsman";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
diff --git a/accesslist-duplicates.local b/accesslist-duplicates.local
index 3f783a4..4d058d4 100644
--- a/accesslist-duplicates.local
+++ b/accesslist-duplicates.local
@@ -8,6 +8,7 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "accesslist-duplicates.local";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
diff --git a/accesslist-duplicates.template b/accesslist-duplicates.template
index c14b630..8878bcc 100644
--- a/accesslist-duplicates.template
+++ b/accesslist-duplicates.template
@@ -9,6 +9,7 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
+:local 0 "accesslist-duplicates%TEMPL%";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
diff --git a/bridge-port-to-default b/bridge-port-to-default
index 60e3112..b8503df 100644
--- a/bridge-port-to-default
+++ b/bridge-port-to-default
@@ -6,13 +6,14 @@
# reset bridge ports to default bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
+:local 0 "bridge-port-to-default";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BridgePortTo;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={
@@ -23,19 +24,19 @@
:if ($BridgeDefault = "dhcp-client") do={
:if ([ :len $DHCPClient ] != 1) do={
- $LogPrintExit warning ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
+ $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
" dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
}
:local DHCPClientDisabled [ / ip dhcp-client get $DHCPClient disabled ];
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={
- $LogPrintExit info ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
+ $LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
/ interface bridge port disable $BridgePort;
/ ip dhcp-client enable $DHCPClient;
}
} else={
:if ($BridgePortVal->"disabled" = true || $BridgeDefault != $BridgePortVal->"bridge") do={
- $LogPrintExit info ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \
+ $LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \
" bridge " . $BridgeDefault . ", disabling dhcp client.") false;
:if ([ :len $DHCPClient ] = 1) do={
/ ip dhcp-client disable $DHCPClient;
@@ -43,7 +44,7 @@
}
/ interface bridge port set disabled=no bridge=$BridgeDefault $BridgePort;
} else={
- $LogPrintExit debug ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
+ $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
" bridge " . $BridgeDefault . ".") false;
}
}
diff --git a/bridge-port-toggle b/bridge-port-toggle
index 9ad38cb..9eeab35 100644
--- a/bridge-port-toggle
+++ b/bridge-port-toggle
@@ -6,6 +6,7 @@
# toggle bridge ports between default and alt bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
+:local 0 "bridge-port-toggle";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
diff --git a/capsman-download-packages b/capsman-download-packages
index a9ef529..37e2658 100644
--- a/capsman-download-packages
+++ b/capsman-download-packages
@@ -7,12 +7,13 @@
# download and cleanup packages for CAP installation from CAPsMAN
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-download-packages.md
+:local 0 "capsman-download-packages";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CleanFilePath;
:global DownloadPackage;
-:global LogPrintExit;
+:global LogPrintExit2;
:global MkDir;
:global ScriptLock;
:global WaitFullyConnected;
@@ -25,15 +26,15 @@ $WaitFullyConnected;
:local Updated false;
:if ([ :len $PackagePath ] = 0) do={
- $LogPrintExit warning ("The CAPsMAN package path is not defined, can not download packages.") true;
+ $LogPrintExit2 warning $0 ("The CAPsMAN package path is not defined, can not download packages.") true;
}
:if ([ :len [ / file find where name=$PackagePath type="directory" ] ] = 0) do={
:if ([ $MkDir $PackagePath ] = false) do={
- $LogPrintExit warning ("Creating directory at CAPsMAN package path (" . \
+ $LogPrintExit2 warning $0 ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!") true;
}
- $LogPrintExit info ("Created directory at CAPsMAN package path (" . $PackagePath . \
+ $LogPrintExit2 info $0 ("Created directory at CAPsMAN package path (" . $PackagePath . \
"). Please place your packages!") false;
}
diff --git a/capsman-rolling-upgrade b/capsman-rolling-upgrade
index a765fb5..fe4410a 100644
--- a/capsman-rolling-upgrade
+++ b/capsman-rolling-upgrade
@@ -7,10 +7,11 @@
# upgrade CAPs one after another
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-rolling-upgrade.md
+:local 0 "capsman-rolling-upgrade";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
$ScriptLock "capsman-rolling-upgrade";
@@ -23,7 +24,7 @@ $ScriptLock "capsman-rolling-upgrade";
:if ($Delay > 120) do={ :set Delay 120; }
:foreach RemoteCap in=[ / caps-man remote-cap find where version!=$InstalledVersion ] do={
:local RemoteCapVal [ / caps-man remote-cap get $RemoteCap ];
- $LogPrintExit info ("Starting upgrade for " . $RemoteCapVal->"name" . \
+ $LogPrintExit2 info $0 ("Starting upgrade for " . $RemoteCapVal->"name" . \
" (" . $RemoteCapVal->"identity" . ")...") false;
/ caps-man remote-cap upgrade [ find where name=$RemoteCapVal->"name" ];
:delay ($Delay . "s");
diff --git a/certificate-renew-issued b/certificate-renew-issued
index 2345f30..c8ce4ae 100644
--- a/certificate-renew-issued
+++ b/certificate-renew-issued
@@ -6,12 +6,13 @@
# renew locally issued certificates
# https://git.eworm.de/cgit/routeros-scripts/about/doc/certificate-renew-issued.md
+:local 0 "certificate-renew-issued";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertIssuedExportPass;
-:global LogPrintExit;
+:global LogPrintExit2;
:global MkDir;
:foreach Cert in=[ / certificate find where issued expires-after<3w ] do={
@@ -26,12 +27,12 @@
/ certificate export-certificate ($CertVal->"name") type=pkcs12 \
file-name=("cert-issued/" . $CertVal->"common-name") \
export-passphrase=($CertIssuedExportPass->($CertVal->"common-name"));
- $LogPrintExit info ("Issued a new certificate for \"" . $CertVal->"common-name" . \
+ $LogPrintExit2 info $0 ("Issued a new certificate for \"" . $CertVal->"common-name" . \
"\", exported to \"cert-issued/" . $CertVal->"common-name" . ".p12\".") false;
} else={
- $LogPrintExit warning ("Failed creating directory, not exporting certificate.") false;
+ $LogPrintExit2 warning $0 ("Failed creating directory, not exporting certificate.") false;
}
} else={
- $LogPrintExit info ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false;
+ $LogPrintExit2 info $0 ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false;
}
}
diff --git a/check-certificates b/check-certificates
index 94ccc99..5946a86 100644
--- a/check-certificates
+++ b/check-certificates
@@ -6,6 +6,7 @@
# check for certificate validity
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-certificates.md
+:local 0 "check-certificates";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -17,7 +18,7 @@
:global CertificateAvailable
:global CertificateNameByCN;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:global SendNotification;
:global SymbolForNotification;
@@ -37,7 +38,7 @@ $WaitFullyConnected;
:do {
:if ([ :len $CertRenewUrl ] = 0) do={
- $LogPrintExit info ("No CertRenewUrl given.") true;
+ $LogPrintExit2 info $0 ("No CertRenewUrl given.") true;
}
:foreach Type in={ ".pem"; ".p12" } do={
@@ -55,7 +56,7 @@ $WaitFullyConnected;
$CertificateNameByCN [ / certificate get $CertInChain common-name ];
}
} on-error={
- $LogPrintExit debug ("Could not download certificate file " . $CertFileName) false;
+ $LogPrintExit2 debug $0 ("Could not download certificate file " . $CertFileName) false;
}
}
@@ -63,15 +64,15 @@ $WaitFullyConnected;
:local CertNewVal [ / certificate get $CertNew ];
:if ([ $CertificateAvailable ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") ] = false) do={
- $LogPrintExit warning ("The certificate chain is not available!") false;
+ $LogPrintExit2 warning $0 ("The certificate chain is not available!") false;
}
:if ($Cert != $CertNew) do={
- $LogPrintExit debug ("Certificate '" . $CertVal->"name" . "' was not updated, but replaced.") false;
+ $LogPrintExit2 debug $0 ("Certificate '" . $CertVal->"name" . "' was not updated, but replaced.") false;
:if (($CertVal->"private-key") = true && ($CertVal->"private-key") != ($CertNewVal->"private-key")) do={
/ certificate remove $CertNew;
- $LogPrintExit warning ("Old certificate '" . ($CertVal->"name") . "' has a private key, new certificate does not. Aborting renew.") true;
+ $LogPrintExit2 warning $0 ("Old certificate '" . ($CertVal->"name") . "' has a private key, new certificate does not. Aborting renew.") true;
}
/ ip service set certificate=($CertNewVal->"name") [ find where certificate=($CertVal->"name") ];
@@ -80,13 +81,13 @@ $WaitFullyConnected;
/ ip ipsec identity set certificate=($CertNewVal->"name") [ / ip ipsec identity find where certificate=($CertVal->"name") ];
/ ip ipsec identity set remote-certificate=($CertNewVal->"name") [ / ip ipsec identity find where remote-certificate=($CertVal->"name") ];
} on-error={
- $LogPrintExit debug ("Setting IPSEC certificates failed. Package 'security' not installed?") false;
+ $LogPrintExit2 debug $0 ("Setting IPSEC certificates failed. Package 'security' not installed?") false;
}
:do {
/ ip hotspot profile set ssl-certificate=($CertNewVal->"name") [ / ip hotspot profile find where ssl-certificate=($CertVal->"name") ];
} on-error={
- $LogPrintExit debug ("Setting hotspot certificates failed. Package 'hotspot' not installed?") false;
+ $LogPrintExit2 debug $0 ("Setting hotspot certificates failed. Package 'hotspot' not installed?") false;
}
/ certificate remove $Cert;
@@ -102,9 +103,9 @@ $WaitFullyConnected;
"Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \
"Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \
"Expires in: " . [ $FormatExpire ($CertNewVal->"expires-after") ]) "" "true";
- $LogPrintExit info ("The certificate " . ($CertVal->"name") . " has been renewed.") false;
+ $LogPrintExit2 info $0 ("The certificate " . ($CertVal->"name") . " has been renewed.") false;
} on-error={
- $LogPrintExit debug ("Could not renew certificate " . ($CertVal->"name") . ".") false;
+ $LogPrintExit2 debug $0 ("Could not renew certificate " . ($CertVal->"name") . ".") false;
}
}
@@ -112,7 +113,7 @@ $WaitFullyConnected;
:local CertVal [ / certificate get $Cert ];
:if ([ :len [ / certificate scep-server find where ca-cert=($CertVal->"ca") ] ] > 0) do={
- $LogPrintExit debug ("Certificate \"" . ($CertVal->"name") . "\" is handled by SCEP, skipping.") false;
+ $LogPrintExit2 debug $0 ("Certificate \"" . ($CertVal->"name") . "\" is handled by SCEP, skipping.") false;
} else={
:local State [ $IfThenElse (($CertVal->"expired") = true) "expired" "is about to expire" ];
@@ -125,7 +126,7 @@ $WaitFullyConnected;
"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") ] ]);
- $LogPrintExit info ("The certificate " . ($CertVal->"name") . " " . $State . \
+ $LogPrintExit2 info $0 ("The certificate " . ($CertVal->"name") . " " . $State . \
", it is invalid after " . ($CertVal->"invalid-after") . ".") false;
}
}
diff --git a/check-health b/check-health
index 8cb2cf3..761a72f 100644
--- a/check-health
+++ b/check-health
@@ -6,6 +6,7 @@
# check for RouterOS health state
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-health.md
+:local 0 "check-health";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -16,7 +17,7 @@
:global CheckHealthVoltagePercent;
:global Identity;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
@@ -28,7 +29,7 @@
:local CheckHealthCurrent [ / system health get ];
:if ([ :len $CheckHealthCurrent ] = 0) do={
- $LogPrintExit error ("Your device does not provide any health values.") true;
+ $LogPrintExit2 error $0 ("Your device does not provide any health values.") true;
}
:if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
@@ -70,7 +71,7 @@
:if ($Name ~ "temperature" && \
[ :typeof $Temperature ] = "num") do={
:if ([ :typeof ($CheckHealthTemperature->$Name) ] != "num" ) do={
- $LogPrintExit info ("No threshold given for " . $Name . ", assuming 50C.") false;
+ $LogPrintExit2 info $0 ("No threshold given for " . $Name . ", assuming 50C.") false;
:set ($CheckHealthTemperature->$Name) 50;
}
:local Validate [ / system health get $Name ];
diff --git a/check-lte-firmware-upgrade b/check-lte-firmware-upgrade
index ed3cb98..f55ec5f 100644
--- a/check-lte-firmware-upgrade
+++ b/check-lte-firmware-upgrade
@@ -6,6 +6,7 @@
# check for LTE firmware upgrade, send notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-lte-firmware-upgrade.md
+:local 0 "check-lte-firmware-upgrade";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -13,7 +14,7 @@
:global SentLteFirmwareUpgradeNotification;
:global CharacterReplace;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
@@ -23,7 +24,7 @@
:local Firmware [ / interface lte firmware-upgrade $Interface once as-value ];
:if ($SentLteFirmwareUpgradeNotification = ($Firmware->"latest")) do={
- $LogPrintExit debug ("Already sent the LTE firmware upgrade notification for version " . \
+ $LogPrintExit2 debug $0 ("Already sent the LTE firmware upgrade notification for version " . \
($Firmware->"latest") . ".") false;
} else={
:if (($Firmware->"installed") != ($Firmware->"latest")) do={
@@ -38,7 +39,7 @@
}
}
} on-error={
- $LogPrintExit debug ("Could not get latest LTE firmware version for interface " . \
+ $LogPrintExit2 debug $0 ("Could not get latest LTE firmware version for interface " . \
$IntName . ".") false;
}
}
diff --git a/check-routeros-update b/check-routeros-update
index c641e04..fe87d9c 100644
--- a/check-routeros-update
+++ b/check-routeros-update
@@ -6,6 +6,7 @@
# check for RouterOS update, send notification and/or install
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-routeros-update.md
+:local 0 "check-routeros-update";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -16,7 +17,7 @@
:global SentRouterosUpdateNotification;
:global DeviceInfo;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptFromTerminal;
:global SendNotification;
:global SymbolForNotification;
@@ -37,7 +38,7 @@ $WaitFullyConnected;
:if ([ :len [ / system package find where name="wireless" disabled=no ] ] > 0) do={
:if ([ / interface wireless cap get enabled ] = true && \
[ / caps-man manager get enabled ] = false) do={
- $LogPrintExit error "System is managed by CAPsMAN, not checking for RouterOS version." true;
+ $LogPrintExit2 error $0 ("System is managed by CAPsMAN, not checking for RouterOS version.") true;
}
}
@@ -49,7 +50,7 @@ $WaitFullyConnected;
:local Update [ / system package update get ];
:if ([ :len ($Update->"latest-version") ] = 0) do={
- $LogPrintExit info "An empty string is not a valid version." true;
+ $LogPrintExit2 info $0 ("An empty string is not a valid version.") true;
}
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@@ -58,7 +59,7 @@ $WaitFullyConnected;
:if ($NumInstalled < $NumLatest) do={
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
- $LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
+ $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true";
@@ -67,7 +68,7 @@ $WaitFullyConnected;
:if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \
version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={
- $LogPrintExit info ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
+ $LogPrintExit2 info $0 ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true";
@@ -81,10 +82,10 @@ $WaitFullyConnected;
($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \
"&latest=" . $Update->"latest-version") output=user as-value ];
} on-error={
- $LogPrintExit warning ("Failed receiving safe version for " . $Update->"channel" . ".") false;
+ $LogPrintExit2 warning $0 ("Failed receiving safe version for " . $Update->"channel" . ".") false;
}
:if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={
- $LogPrintExit info ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
+ $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true";
@@ -102,7 +103,7 @@ $WaitFullyConnected;
}
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
- $LogPrintExit info ("Already sent the RouterOS update notification for version " . \
+ $LogPrintExit2 info $0 ("Already sent the RouterOS update notification for version " . \
$Update->"latest-version" . ".") true;
}
@@ -115,7 +116,7 @@ $WaitFullyConnected;
:if ($NumInstalled > $NumLatest) do={
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
- $LogPrintExit info ("Already sent the RouterOS downgrade notification for version " . \
+ $LogPrintExit2 info $0 ("Already sent the RouterOS downgrade notification for version " . \
$Update->"latest-version" . ".") true;
}
@@ -123,7 +124,7 @@ $WaitFullyConnected;
("A different RouterOS version " . ($Update->"latest-version") . \
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \
[ $DeviceInfo ]) $Link "true";
- $LogPrintExit info ("A different RouterOS version " . ($Update->"latest-version") . \
+ $LogPrintExit2 info $0 ("A different RouterOS version " . ($Update->"latest-version") . \
" is available for downgrade.") false;
:set SentRouterosUpdateNotification ($Update->"latest-version");
}
diff --git a/cloud-backup b/cloud-backup
index e4e527b..598a500 100644
--- a/cloud-backup
+++ b/cloud-backup
@@ -6,6 +6,7 @@
# upload backup to MikroTik cloud
# https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md
+:local 0 "cloud-backup";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -13,7 +14,7 @@
:global Identity;
:global DeviceInfo;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
:global WaitFullyConnected;
@@ -42,5 +43,5 @@ $WaitFullyConnected;
} on-error={
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \
("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]);
- $LogPrintExit error ("Failed uploading backup for " . $Identity . " to cloud!") true;
+ $LogPrintExit2 error $0 ("Failed uploading backup for " . $Identity . " to cloud!") true;
}
diff --git a/collect-wireless-mac.capsman b/collect-wireless-mac.capsman
index bf8e691..248a14d 100644
--- a/collect-wireless-mac.capsman
+++ b/collect-wireless-mac.capsman
@@ -8,13 +8,14 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "collect-wireless-mac.capsman";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
:global SendNotification;
:global SymbolForNotification;
@@ -23,7 +24,7 @@ $ScriptLock "collect-wireless-mac.capsman";
:if ([ :len [ / caps-man access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ caps-man access-list add comment="--- collected above ---" disabled=yes;
- $LogPrintExit warning "Added disabled access-list entry with comment '--- collected above ---'." false;
+ $LogPrintExit2 warning $0 ("Added disabled access-list entry with comment '--- collected above ---'.") false;
}
:local PlaceBefore ([ / caps-man access-list find where comment="--- collected above ---" disabled ]->0);
@@ -53,7 +54,7 @@ $ScriptLock "collect-wireless-mac.capsman";
:local Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
- $LogPrintExit info $Message false;
+ $LogPrintExit2 info $0 $Message false;
/ caps-man access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
@@ -67,7 +68,7 @@ $ScriptLock "collect-wireless-mac.capsman";
"DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime);
} else={
- $LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
+ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / caps-man access-list get $AccessList comment ]) false;
}
}
diff --git a/collect-wireless-mac.local b/collect-wireless-mac.local
index 15c0c9a..20a5f83 100644
--- a/collect-wireless-mac.local
+++ b/collect-wireless-mac.local
@@ -8,13 +8,14 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "collect-wireless-mac.local";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
:global SendNotification;
:global SymbolForNotification;
@@ -23,7 +24,7 @@ $ScriptLock "collect-wireless-mac.local";
:if ([ :len [ / interface wireless access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ interface wireless access-list add comment="--- collected above ---" disabled=yes;
- $LogPrintExit warning "Added disabled access-list entry with comment '--- collected above ---'." false;
+ $LogPrintExit2 warning $0 ("Added disabled access-list entry with comment '--- collected above ---'.") false;
}
:local PlaceBefore ([ / interface wireless access-list find where comment="--- collected above ---" disabled ]->0);
@@ -53,7 +54,7 @@ $ScriptLock "collect-wireless-mac.local";
:local Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
- $LogPrintExit info $Message false;
+ $LogPrintExit2 info $0 $Message false;
/ interface wireless access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
@@ -67,7 +68,7 @@ $ScriptLock "collect-wireless-mac.local";
"DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime);
} else={
- $LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
+ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / interface wireless access-list get $AccessList comment ]) false;
}
}
diff --git a/collect-wireless-mac.template b/collect-wireless-mac.template
index 2198136..fe84287 100644
--- a/collect-wireless-mac.template
+++ b/collect-wireless-mac.template
@@ -9,13 +9,14 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
+:local 0 "collect-wireless-mac%TEMPL%";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
:global SendNotification;
:global SymbolForNotification;
@@ -24,7 +25,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
:if ([ :len [ / %PATH% access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ %PATH% access-list add comment="--- collected above ---" disabled=yes;
- $LogPrintExit warning "Added disabled access-list entry with comment '--- collected above ---'." false;
+ $LogPrintExit2 warning $0 ("Added disabled access-list entry with comment '--- collected above ---'.") false;
}
:local PlaceBefore ([ / %PATH% access-list find where comment="--- collected above ---" disabled ]->0);
@@ -55,7 +56,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
:local Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
- $LogPrintExit info $Message false;
+ $LogPrintExit2 info $0 $Message false;
/ %PATH% access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
@@ -69,7 +70,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
"DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime);
} else={
- $LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
+ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / %PATH% access-list get $AccessList comment ]) false;
}
}
diff --git a/daily-psk.capsman b/daily-psk.capsman
index b66b750..7d2c2ae 100644
--- a/daily-psk.capsman
+++ b/daily-psk.capsman
@@ -9,13 +9,14 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "daily-psk.capsman";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
:global UrlEncode;
@@ -65,13 +66,13 @@ $WaitFullyConnected;
:local Skip 0;
:if ($NewPsk != $OldPsk) do={
- $LogPrintExit info ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
+ $LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
/ caps-man access-list set $AccList private-passphrase=$NewPsk;
:if ([ :len [ / caps-man interface find where configuration=$Configuration ] ] > 0) do={
:foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) do={
- $LogPrintExit debug ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
+ $LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
:set Skip 1;
}
}
diff --git a/daily-psk.local b/daily-psk.local
index e7f908f..6186ddc 100644
--- a/daily-psk.local
+++ b/daily-psk.local
@@ -9,13 +9,14 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "daily-psk.local";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
:global UrlEncode;
@@ -65,13 +66,13 @@ $WaitFullyConnected;
:local Skip 0;
:if ($NewPsk != $OldPsk) do={
- $LogPrintExit info ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
+ $LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
/ interface wireless access-list set $AccList private-pre-shared-key=$NewPsk;
:if ([ :len [ / interface wireless find where name=$IntName disabled=no ] ] = 1) do={
:foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) do={
- $LogPrintExit debug ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
+ $LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
:set Skip 1;
}
}
diff --git a/daily-psk.template b/daily-psk.template
index 8cf08e0..42abba5 100644
--- a/daily-psk.template
+++ b/daily-psk.template
@@ -10,13 +10,14 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
+:local 0 "daily-psk%TEMPL%";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
:global UrlEncode;
@@ -69,7 +70,7 @@ $WaitFullyConnected;
:local Skip 0;
:if ($NewPsk != $OldPsk) do={
- $LogPrintExit info ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
+ $LogPrintExit2 info $0 ("Updating daily PSK for " . $Ssid . " to " . $NewPsk . " (was " . $OldPsk . ")") false;
/ interface wireless access-list set $AccList private-pre-shared-key=$NewPsk;
/ caps-man access-list set $AccList private-passphrase=$NewPsk;
@@ -77,7 +78,7 @@ $WaitFullyConnected;
:if ([ :len [ / caps-man interface find where configuration=$Configuration ] ] > 0) do={
:foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) do={
- $LogPrintExit debug ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
+ $LogPrintExit2 debug $0 ("Already sent a mail for SSID " . $Ssid . ", skipping.") false;
:set Skip 1;
}
}
diff --git a/dhcp-lease-comment.capsman b/dhcp-lease-comment.capsman
index 3c0b9e9..96b1741 100644
--- a/dhcp-lease-comment.capsman
+++ b/dhcp-lease-comment.capsman
@@ -8,10 +8,11 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "dhcp-lease-comment.capsman";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
@@ -21,7 +22,7 @@
:set NewComment [ / caps-man access-list get $AccessList comment ];
}
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={
- $LogPrintExit info ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
+ $LogPrintExit2 info $0 ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
/ ip dhcp-server lease set comment=$NewComment $Lease;
}
}
diff --git a/dhcp-lease-comment.local b/dhcp-lease-comment.local
index dc2f708..74de2c8 100644
--- a/dhcp-lease-comment.local
+++ b/dhcp-lease-comment.local
@@ -8,10 +8,11 @@
#
# !! Do not edit this file, it is generated from template!
+:local 0 "dhcp-lease-comment.local";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
@@ -21,7 +22,7 @@
:set NewComment [ / interface wireless access-list get $AccessList comment ];
}
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={
- $LogPrintExit info ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
+ $LogPrintExit2 info $0 ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
/ ip dhcp-server lease set comment=$NewComment $Lease;
}
}
diff --git a/dhcp-lease-comment.template b/dhcp-lease-comment.template
index e3ca6d0..0e31007 100644
--- a/dhcp-lease-comment.template
+++ b/dhcp-lease-comment.template
@@ -9,10 +9,11 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
+:local 0 "dhcp-lease-comment%TEMPL%";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
@@ -22,7 +23,7 @@
:set NewComment [ / %PATH% access-list get $AccessList comment ];
}
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={
- $LogPrintExit info ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
+ $LogPrintExit2 info $0 ("Updating comment for DHCP lease " . $LeaseVal->"mac-address" . ": " . $NewComment) false;
/ ip dhcp-server lease set comment=$NewComment $Lease;
}
}
diff --git a/dhcp-to-dns b/dhcp-to-dns
index 30ca63c..dfb438f 100644
--- a/dhcp-to-dns
+++ b/dhcp-to-dns
@@ -6,6 +6,7 @@
# check DHCP leases and add/remove/update DNS entries
# https://git.eworm.de/cgit/routeros-scripts/about/doc/dhcp-to-dns.md
+:local 0 "dhcp-to-dns";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -17,7 +18,7 @@
:global CharacterReplace;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:local Zone \
([ $IfThenElse ($PrefixInZone = true) "dhcp." ] . \
@@ -27,7 +28,7 @@
:if ([ :len [ / ip dns static find where comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled ] ] = 0) do={
/ ip dns static add comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled=yes;
- $LogPrintExit warning "Added disabled static dns record with comment '--- dhcp-to-dns above ---'." false;
+ $LogPrintExit2 warning $0 ("Added disabled static dns record with comment '--- dhcp-to-dns above ---'.") false;
}
:local PlaceBefore ([ / ip dns static find where comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled ]->0);
@@ -35,10 +36,10 @@
:local DnsRecordVal [ / ip dns static get $DnsRecord ];
:local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ];
:if ([ :len [ / ip dhcp-server lease find where mac-address=$MacAddress address=($DnsRecordVal->"address") status=bound ] ] > 0) do={
- $LogPrintExit debug ("Lease for " . $MacAddress . " (" . $DnsRecordVal->"name" . ") still exists. Not deleting DNS entry.") false;
+ $LogPrintExit2 debug $0 ("Lease for " . $MacAddress . " (" . $DnsRecordVal->"name" . ") still exists. Not deleting DNS entry.") false;
} else={
:local Found false;
- $LogPrintExit info ("Lease expired for " . $MacAddress . " (" . $DnsRecordVal->"name" . "), deleting DNS entry.") false;
+ $LogPrintExit2 info $0 ("Lease expired for " . $MacAddress . " (" . $DnsRecordVal->"name" . "), deleting DNS entry.") false;
/ ip dns static remove $DnsRecord;
}
}
@@ -65,13 +66,13 @@
}
:if ($DnsIp = $LeaseVal->"address") do={
- $LogPrintExit debug ("DNS entry for " . $Fqdn . " does not need updating.") false;
+ $LogPrintExit2 debug $0 ("DNS entry for " . $Fqdn . " does not need updating.") false;
} else={
- $LogPrintExit info ("Replacing DNS entry for " . $Fqdn . ", new address is " . $LeaseVal->"address" . ".") false;
+ $LogPrintExit2 info $0 ("Replacing DNS entry for " . $Fqdn . ", new address is " . $LeaseVal->"address" . ".") false;
/ ip dns static set name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord;
}
} else={
- $LogPrintExit info ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false;
+ $LogPrintExit2 info $0 ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false;
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
}
}
diff --git a/early-errors b/early-errors
index e6160e8..7c2e509 100644
--- a/early-errors
+++ b/early-errors
@@ -1,6 +1,6 @@
#!rsc by RouterOS
# RouterOS script: early-errors
-:global LogPrintExit;
+:global LogPrintExit2;
-$LogPrintExit warning ("This script has been replaced. Please migrate to 'log-forward'.") true;
+$LogPrintExit2 warning "early-errors" ("This script has been replaced. Please migrate to 'log-forward'.") true;
diff --git a/email-backup b/email-backup
index 7cd8222..129075a 100644
--- a/email-backup
+++ b/email-backup
@@ -6,6 +6,7 @@
# create and email backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/email-backup.md
+:local 0 "email-backup";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -19,7 +20,7 @@
:global CharacterReplace;
:global DeviceInfo;
-:global LogPrintExit;
+:global LogPrintExit2;
:global WaitForFile;
:global WaitFullyConnected;
@@ -27,11 +28,11 @@ $WaitFullyConnected;
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
- $LogPrintExit error ("Configured to send neither backup nor config export.") true;
+ $LogPrintExit2 error $0 ("Configured to send neither backup nor config export.") true;
}
:if ([ :len $EmailBackupTo ] = 0) do={
- $LogPrintExit error ("Configuration is missing recipient for e-mail backup.") true;
+ $LogPrintExit2 error $0 ("Configuration is missing recipient for e-mail backup.") true;
}
# filename based on identity
diff --git a/global-functions b/global-functions
index b6748f6..e958d74 100644
--- a/global-functions
+++ b/global-functions
@@ -32,6 +32,7 @@
:global IfThenElse;
:global IPCalc;
:global LogPrintExit;
+:global LogPrintExit2;
:global MkDir;
:global ParseKeyValueStore;
:global RandomDelay;
@@ -58,19 +59,19 @@
:local CommonName [ :tostr $1 ];
:global CertificateDownload;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global ParseKeyValueStore;
:global RequiredRouterOS;
:if ([ / system resource get free-hdd-space ] < 8388608 && \
[ / certificate settings get crl-download ] = true && \
[ / certificate settings get crl-store ] = "system") do={
- $LogPrintExit warning ("This system has low free flash space but " . \
+ $LogPrintExit2 warning $0 ("This system has low free flash space but " . \
"is configured to download certificate CRLs to system!") false;
}
:if ([ :len [ / certificate find where common-name=$CommonName ] ] = 0) do={
- $LogPrintExit info ("Certificate with CommonName \"" . $CommonName . "\" not available.") false;
+ $LogPrintExit2 info $0 ("Certificate with CommonName \"" . $CommonName . "\" not available.") false;
:if ([ $CertificateDownload $CommonName ] = false) do={
:return false;
}
@@ -83,7 +84,7 @@
:local CertVal [ / certificate get [ find where common-name=$CommonName ] ];
:do {
:if ([ :len [ / certificate find where skid=($CertVal->"akid") ] ] = 0) do={
- $LogPrintExit info ("Certificate chain for \"" . $CommonName . \
+ $LogPrintExit2 info $0 ("Certificate chain for \"" . $CommonName . \
"\" is incomplete, missing \"" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\".") false;
:if ([ $CertificateDownload $CommonName ] = false) do={
:return false;
@@ -102,11 +103,11 @@
:global ScriptUpdatesUrlSuffix;
:global CertificateNameByCN;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global UrlEncode;
:global WaitForFile;
- $LogPrintExit info ("Downloading and importing certificate with " . \
+ $LogPrintExit2 info $0 ("Downloading and importing certificate with " . \
"CommonName \"" . $CommonName . "\".") false;
:do {
:local LocalFileName ($CommonName . ".pem");
@@ -123,7 +124,7 @@
$CertificateNameByCN [ / certificate get $Cert common-name ];
}
} on-error={
- $LogPrintExit warning ("Failed importing certificate with " . \
+ $LogPrintExit2 warning $0 ("Failed importing certificate with " . \
"CommonName \"" . $CommonName . "\"!") false;
:return false;
}
@@ -242,7 +243,7 @@
:global CertificateAvailable;
:global CleanFilePath;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global WaitForFile;
:if ([ :len $PkgName ] = 0) do={ :return false; }
@@ -256,12 +257,12 @@
:local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
:if ([ :len [ / file find where name=$PkgDest type="package" ] ] > 0) do={
- $LogPrintExit info ("Package file alreasy exists.") false;
+ $LogPrintExit2 info $0 ("Package file alreasy exists.") false;
:return true;
}
:if ([ $CertificateAvailable "R3" ] = false) do={
- $LogPrintExit error ("Downloading required certificate failed.") true;
+ $LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
}
:local Retry 3;
@@ -276,7 +277,7 @@
:return true;
}
} on-error={
- $LogPrintExit debug ("Downloading package failed.") false;
+ $LogPrintExit2 debug $0 ("Downloading package failed.") false;
}
/ file remove [ find where name=$PkgDest ];
@@ -290,13 +291,13 @@
:set FlushEmailQueue do={
:global EmailQueue;
- :global LogPrintExit;
+ :global LogPrintExit2;
:local AllDone true;
:local QueueLen [ :len $EmailQueue ];
:if ([ :len [ / system scheduler find where name="FlushEmailQueue" ] ] > 0 && $QueueLen = 0) do={
- $LogPrintExit warning ("Flushing E-Mail messages from scheduler, but queue is empty.") false;
+ $LogPrintExit2 warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.") false;
}
/ system scheduler set interval=1m [ find where name="FlushEmailQueue" interval=1s ];
@@ -332,13 +333,13 @@
:global TelegramQueue;
:global TelegramTokenId;
- :global LogPrintExit;
+ :global LogPrintExit2;
:local AllDone true;
:local QueueLen [ :len $TelegramQueue ];
:if ([ :len [ / system scheduler find where name="FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={
- $LogPrintExit warning ("Flushing Telegram messages from scheduler, but queue is empty.") false;
+ $LogPrintExit2 warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.") false;
}
:foreach Id,Message in=$TelegramQueue do={
@@ -352,7 +353,7 @@
"&text=" . ($Message->"text"));
:set ($TelegramQueue->$Id);
} on-error={
- $LogPrintExit debug ("Sending queued Telegram message failed.") false;
+ $LogPrintExit2 debug $0 ("Sending queued Telegram message failed.") false;
:set AllDone false;
}
}
@@ -369,11 +370,11 @@
:local Mac [ :tostr $1 ];
:global CertificateAvailable;
- :global LogPrintExit;
+ :global LogPrintExit2;
:do {
:if ([ $CertificateAvailable "Cloudflare Inc ECC CA-3" ] = false) do={
- $LogPrintExit warning ("Downloading required certificate failed.") true;
+ $LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
}
:local Vendor ([ / tool fetch check-certificate=yes-without-crl \
("https://api.macvendors.com/" . [ :pick $Mac 0 8 ]) output=user as-value ]->"data");
@@ -449,11 +450,19 @@
:return $Return;
}
-# log and print with same text, optionally exit
+# deprecated compatibility wrapper
:set LogPrintExit do={
+ :global LogPrintExit2;
+
+ $LogPrintExit2 $1 "unknown" $2 $3;
+}
+
+# log and print with same text, optionally exit
+:set LogPrintExit2 do={
:local Severity [ :tostr $1 ];
- :local Message [ :tostr $2 ];
- :local Exit [ :tostr $3 ];
+ :local Name [ :tostr $2 ];
+ :local Message [ :tostr $3 ];
+ :local Exit [ :tostr $4 ];
:global PrintDebug;
@@ -468,12 +477,13 @@
:return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m");
}
+ :local Log ($Name . ": " . $Message);
:if ($Severity ~ "^(debug|error|info)\$") do={
- :if ($Severity = "debug") do={ :log debug $Message; }
- :if ($Severity = "error") do={ :log error $Message; }
- :if ($Severity = "info" ) do={ :log info $Message; }
+ :if ($Severity = "debug") do={ :log debug $Log; }
+ :if ($Severity = "error") do={ :log error $Log; }
+ :if ($Severity = "info" ) do={ :log info $Log; }
} else={
- :log warning $Message;
+ :log warning $Log;
:set Severity "warning";
}
@@ -545,11 +555,11 @@
:local Required [ :tostr $2 ];
:global IfThenElse;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global VersionToNum;
:if ([ $VersionToNum $Required ] > [ $VersionToNum [ / system package update get installed-version ] ]) do={
- $LogPrintExit warning ("This " . [ $IfThenElse ([ :pick $Caller 0 ] = "\$") "function" "script" ] . \
+ $LogPrintExit2 warning $0 ("This " . [ $IfThenElse ([ :pick $Caller 0 ] = "\$") "function" "script" ] . \
" '" . $Caller . "' (at least specific functionality) requires RouterOS " . $Required . ". Please update!") false;
:return false;
}
@@ -560,7 +570,7 @@
:set ScriptFromTerminal do={
:local Script [ :tostr $1 ];
- :global LogPrintExit;
+ :global LogPrintExit2;
:foreach Job in=[ / system script job find where script=$Script ] do={
:set Job [ / system script job get $Job ];
@@ -568,11 +578,11 @@
:set Job [ / system script job get [ find where .id=($Job->"parent") ] ];
}
:if (($Job->"type") = "login") do={
- $LogPrintExit debug ("Script " . $Script . " started from terminal.") false;
+ $LogPrintExit2 debug $0 ("Script " . $Script . " started from terminal.") false;
:return true;
}
}
- $LogPrintExit debug ("Script " . $Script . " NOT started from terminal.") false;
+ $LogPrintExit2 debug $0 ("Script " . $Script . " NOT started from terminal.") false;
:return false;
}
@@ -591,19 +601,19 @@
:global SentConfigChangesNotification;
:global CertificateAvailable;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptInstallUpdate;
:global SendNotification;
:global SymbolForNotification;
:if ([ $CertificateAvailable "R3" ] = false) do={
- $LogPrintExit warning ("Downloading certificate failed, trying without.") false;
+ $LogPrintExit2 warning $0 ("Downloading certificate failed, trying without.") false;
}
:foreach Script in=$Scripts do={
:if ([ :len [ / system script find where name=$Script ] ] = 0) do={
- $LogPrintExit info ("Adding new script: " . $Script) false;
+ $LogPrintExit2 info $0 ("Adding new script: " . $Script) false;
/ system script add name=$Script source="#!rsc by RouterOS\n";
}
}
@@ -622,7 +632,7 @@
:foreach Scheduler in=[ / system scheduler find where on-event~("\\b" . $ScriptVal->"name" . "\\b") ] do={
:local SchedulerVal [ / system scheduler get $Scheduler ];
:if ($ScriptVal->"policy" != $SchedulerVal->"policy") do={
- $LogPrintExit warning ("Policies differ for script " . $ScriptVal->"name" . \
+ $LogPrintExit2 warning $0 ("Policies differ for script " . $ScriptVal->"name" . \
" and its scheduler " . $SchedulerVal->"name" . "!") false;
}
}
@@ -630,7 +640,7 @@
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={
:local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ];
:if (!($Comment->"ignore" = true)) do={
- $LogPrintExit debug ("Fetching script from url: " . $ScriptVal->"name") false;
+ $LogPrintExit2 debug $0 ("Fetching script from url: " . $ScriptVal->"name") false;
:do {
:local BaseUrl $ScriptUpdatesBaseUrl;
:local UrlSuffix $ScriptUpdatesUrlSuffix;
@@ -643,7 +653,7 @@
:set SourceNew ($Result->"data");
}
} on-error={
- $LogPrintExit warning ("Failed fetching " . $ScriptVal->"name") false;
+ $LogPrintExit2 warning $0 ("Failed fetching " . $ScriptVal->"name") false;
}
}
}
@@ -653,34 +663,34 @@
:if ($SourceNew != $ScriptVal->"source") do={
:local DontRequirePermissions \
($SourceNew~"\n# requires: dont-require-permissions=yes\n");
- $LogPrintExit info ("Updating script: " . $ScriptVal->"name") false;
+ $LogPrintExit2 info $0 ("Updating script: " . $ScriptVal->"name") false;
/ system script set owner=($ScriptVal->"name") source=$SourceNew \
dont-require-permissions=$DontRequirePermissions $Script;
:if ($ScriptVal->"name" = "global-config" && \
[ :len [ / system script find where name="global-config-overlay" ] ] > 0) do={
- $LogPrintExit info ("Reloading global configuration and overlay.") false;
+ $LogPrintExit2 info $0 ("Reloading global configuration and overlay.") false;
:do {
/ system script { run global-config; run global-config-overlay; }
} on-error={
- $LogPrintExit error ("Reloading global configuration and overlay failed! Syntax error\?") false;
+ $LogPrintExit2 error $0 ("Reloading global configuration and overlay failed! Syntax error\?") false;
}
}
:if ($ScriptVal->"name" = "global-functions") do={
- $LogPrintExit info ("Reloading global functions.") false;
+ $LogPrintExit2 info $0 ("Reloading global functions.") false;
:do {
/ system script run global-functions;
} on-error={
- $LogPrintExit error ("Reloading global functions failed!") false;
+ $LogPrintExit2 error $0 ("Reloading global functions failed!") false;
}
}
} else={
- $LogPrintExit debug ("Script " . $ScriptVal->"name" . " did not change.") false;
+ $LogPrintExit2 debug $0 ("Script " . $ScriptVal->"name" . " did not change.") false;
}
} else={
- $LogPrintExit warning ("Looks like new script " . $ScriptVal->"name" . " is not valid. Ignoring!") false;
+ $LogPrintExit2 warning $0 ("Looks like new script " . $ScriptVal->"name" . " is not valid. Ignoring!") false;
}
} else={
- $LogPrintExit debug ("No update for script " . $ScriptVal->"name" . ".") false;
+ $LogPrintExit2 debug $0 ("No update for script " . $ScriptVal->"name" . ".") false;
}
}
@@ -697,9 +707,9 @@
" is out of date. Please update " . $ConfigScript . ", then increase " . \
"\$GlobalConfigVersion (currently " . $GlobalConfigVersion . \
") to " . $ExpectedConfigVersion . " and re-run " . $ConfigScript . ".");
- $LogPrintExit info ($NotificationMessage) false;
+ $LogPrintExit2 info $0 ($NotificationMessage) false;
- $LogPrintExit debug ("Fetching changelog.") false;
+ $LogPrintExit2 debug $0 ("Fetching changelog.") false;
:do {
:local Result [ / tool fetch check-certificate=yes-without-crl \
($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \
@@ -712,17 +722,17 @@
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
:local Migration ($GlobalConfigMigration->[ :tostr $I ]);
:if ([ :typeof $Migration ] = "str") do={
- $LogPrintExit info ("Applying migration: " . $Migration) false;
+ $LogPrintExit2 info $0 ("Applying migration: " . $Migration) false;
[ :parse $Migration ];
}
:set NotificationMessage ($NotificationMessage . \
"\n * " . $GlobalConfigChanges->[ :tostr $I ]);
- $LogPrintExit info ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
+ $LogPrintExit2 info $0 ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
}
:set GlobalConfigChanges;
:set GlobalConfigMigration;
} on-error={
- $LogPrintExit warning ("Failed fetching changes!") false;
+ $LogPrintExit2 warning $0 ("Failed fetching changes!") false;
:set NotificationMessage ($NotificationMessage . \
"\n\nChanges are not available.");
}
@@ -743,18 +753,18 @@
}
:if ($ScriptInstallUpdateBefore != [ :tostr $ScriptInstallUpdate ]) do={
- $LogPrintExit info ("This function '\$ScriptInstallUpdate' changed, you may want to re-run.") false;
+ $LogPrintExit2 info $0 ("This function changed, you may want to re-run.") false;
}
}
# lock script against multiple invocation
:set ScriptLock do={
- :global LogPrintExit;
+ :global LogPrintExit2;
:local Script [ :tostr $1 ];
:if ([ :len [ / system script job find where script=$Script ] ] > 1) do={
- $LogPrintExit info ("Script " . $Script . " started more than once... Aborting.") true;
+ $LogPrintExit2 info $0 ("Script " . $Script . " started more than once... Aborting.") true;
}
}
@@ -769,7 +779,7 @@
:global EmailGeneralCc;
:global EmailQueue;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global IfThenElse;
:if ([ :len $EmailGeneralTo ] = 0) do={
@@ -823,7 +833,7 @@
:global CertificateAvailable;
:global CharacterReplace;
:global IfThenElse;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global SymbolForNotification;
:global UrlEncode;
@@ -886,14 +896,14 @@
:do {
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
- $LogPrintExit warning ("Downloading required certificate failed.") true;
+ $LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
}
/ tool fetch check-certificate=yes-without-crl output=none http-method=post \
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
http-data=("chat_id=" . $ChatId . "&disable_notification=" . $Silent . \
"&disable_web_page_preview=true&parse_mode=" . $ParseMode . "&text=" . $Text);
} on-error={
- $LogPrintExit info ("Failed sending telegram notification! Queuing...") false;
+ $LogPrintExit2 info $0 ("Failed sending telegram notification! Queuing...") false;
:if ([ :typeof $TelegramQueue ] = "nothing") do={
:set TelegramQueue [ :toarray "" ];
@@ -950,7 +960,7 @@
# check if system time is sync
:set TimeIsSync do={
- :global LogPrintExit;
+ :global LogPrintExit2;
:if ([ / system ntp client get enabled ] = true) do={
:do {
@@ -972,7 +982,7 @@
:return false;
}
- $LogPrintExit debug ("No time source configured! Returning gracefully...") false;
+ $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
:return true;
}
@@ -1081,7 +1091,7 @@
# wait for time to become synced
:set WaitTimeSync do={
- :global LogPrintExit;
+ :global LogPrintExit2;
:global TimeIsSync;
:while ([ $TimeIsSync ] = false) do={
@@ -1090,7 +1100,7 @@
:do {
/ system script run rotate-ntp;
} on-error={
- $LogPrintExit debug ("Running rotate-ntp failed.") false;
+ $LogPrintExit2 debug $0 ("Running rotate-ntp failed.") false;
}
}
:delay 1s;
diff --git a/global-wait b/global-wait
index 18f2fb8..3ce6d27 100644
--- a/global-wait
+++ b/global-wait
@@ -6,6 +6,6 @@
:delay 500ms;
}
-:global LogPrintExit;
+:global LogPrintExit2;
-$LogPrintExit warning ("This script 'global-wait' is now useless, please remove it from configuration.") true;
+$LogPrintExit2 warning "global-wait" ("This script is now useless, please remove it from configuration.") true;
diff --git a/gps-track b/gps-track
index 31e12e9..bfab8de 100644
--- a/gps-track
+++ b/gps-track
@@ -6,13 +6,14 @@
# track gps data by sending json data to http server
# https://git.eworm.de/cgit/routeros-scripts/about/doc/gps-track.md
+:local 0 "gps-track";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global GpsTrackUrl;
:global Identity;
-:global LogPrintExit;
+:global LogPrintExit2;
:local CoordinateFormat [ / system gps get coordinate-format ];
:local Gps [ / system gps monitor once as-value ];
@@ -25,9 +26,9 @@
"\"lon\":\"" . ($Gps->"longitude") . "\"," . \
"\"identity\":\"" . $Identity . "\"" . \
"}");
- $LogPrintExit debug ("Sending GPS data in " . $CoordinateFormat . " format: " . \
+ $LogPrintExit2 debug $0 ("Sending GPS data in " . $CoordinateFormat . " format: " . \
"lat: " . ($Gps->"latitude") . " " . \
"lon: " . ($Gps->"longitude")) false;
} else={
- $LogPrintExit debug ("GPS data not valid.") false;
+ $LogPrintExit2 debug $0 ("GPS data not valid.") false;
}
diff --git a/hotspot-to-wpa b/hotspot-to-wpa
index 09283cf..68f887f 100644
--- a/hotspot-to-wpa
+++ b/hotspot-to-wpa
@@ -6,10 +6,11 @@
# add private WPA passphrase after hotspot login
# https://git.eworm.de/cgit/routeros-scripts/about/doc/hotspot-to-wpa.md
+:local 0 "hotspot-to-wpa";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:local MacAddress $"mac-address";
:local UserName $username;
@@ -18,11 +19,11 @@
:if ([ :len [ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ] ] = 0) do={
/ caps-man access-list add comment="--- hotspot-to-wpa above ---" disabled=yes;
- $LogPrintExit warning "Added disabled access-list entry with comment '--- hotspot-to-wpa above ---'." false;
+ $LogPrintExit2 warning $0 ("Added disabled access-list entry with comment '--- hotspot-to-wpa above ---'.") false;
}
:local PlaceBefore ([ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ]->0);
-$LogPrintExit info ("Adding/updating accesslist entry for mac address " . $MacAddress . \
+$LogPrintExit2 info $0 ("Adding/updating accesslist entry for mac address " . $MacAddress . \
" (user " . $UserName . ").") false;
/ caps-man access-list remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
diff --git a/ipv6-update b/ipv6-update
index 4f0812c..3223807 100644
--- a/ipv6-update
+++ b/ipv6-update
@@ -6,16 +6,17 @@
# update firewall and dns settings on IPv6 prefix change
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ipv6-update.md
+:local 0 "ipv6-update";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local PdPrefix $"pd-prefix";
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:if ([ :typeof $PdPrefix ] = "nothing") do={
- $LogPrintExit error "This script is supposed to run from ipv6 dhcp-client." true;
+ $LogPrintExit2 error $0 ("This script is supposed to run from ipv6 dhcp-client.") true;
}
:local Pool [ / ipv6 pool get [ find where prefix=$PdPrefix ] name ];
diff --git a/lease-script b/lease-script
index a39a874..28f9e20 100644
--- a/lease-script
+++ b/lease-script
@@ -6,16 +6,17 @@
# run scripts on DHCP lease
# https://git.eworm.de/cgit/routeros-scripts/about/doc/lease-script.md
+:local 0 "lease-script";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:if ([ :typeof $leaseActIP ] = "nothing" || \
[ :typeof $leaseActMAC ] = "nothing" || \
[ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={
- $LogPrintExit error "This script is supposed to run from ip dhcp-server." true;
+ $LogPrintExit2 error $0 ("This script is supposed to run from ip dhcp-server.") true;
}
:local Scripts;
diff --git a/log-forward b/log-forward
index c4458b2..e90e720 100644
--- a/log-forward
+++ b/log-forward
@@ -6,6 +6,7 @@
# forward log messages via notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/log-forward.md
+:local 0 "log-forward";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -16,7 +17,7 @@
:global LogForwardRateLimit;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
:global SendNotification;
:global SymbolForNotification;
@@ -30,7 +31,7 @@ $ScriptLock "log-forward";
:if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1);
- $LogPrintExit info ("Rate limit in action, not forwarding logs, if any!") true;
+ $LogPrintExit2 info $0 ("Rate limit in action, not forwarding logs, if any!") true;
}
$WaitFullyConnected;
diff --git a/mode-button b/mode-button
index cd94919..8d96fcd 100644
--- a/mode-button
+++ b/mode-button
@@ -6,23 +6,24 @@
# act on multiple mode and reset button presses
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
+:local 0 "mode-button";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global ModeButton;
-:global LogPrintExit;
+:global LogPrintExit2;
:set ($ModeButton->"count") ($ModeButton->"count" + 1);
:local Scheduler [ / system scheduler find where name="ModeButtonScheduler" ];
:if ([ :len $Scheduler ] = 0) do={
- $LogPrintExit info ("Creating scheduler ModeButtonScheduler, counting presses...") false;
+ $LogPrintExit2 info $0 ("Creating scheduler ModeButtonScheduler, counting presses...") false;
:global ModeButtonScheduler do={
:global ModeButton;
- :global LogPrintExit;
+ :global LogPrintExit2;
:global ModeButtonScheduler;
:local LEDInvert do={
@@ -45,7 +46,7 @@
/ system scheduler remove ModeButtonScheduler;
:if ([ :len $Code ] > 0) do={
- $LogPrintExit info ("Acting on " . $Count . " mode-button presses: " . $Code) false;
+ $LogPrintExit2 info $0 ("Acting on " . $Count . " mode-button presses: " . $Code) false;
:for I from=1 to=$Count do={
$LEDInvert;
@@ -59,12 +60,12 @@
[ :parse $Code ];
} else={
- $LogPrintExit info ("No action defined for " . $Count . " mode-button presses.") false;
+ $LogPrintExit2 info $0 ("No action defined for " . $Count . " mode-button presses.") false;
}
}
/ system scheduler add name="ModeButtonScheduler" \
on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s;
} else={
- $LogPrintExit debug ("Updating scheduler ModeButtonScheduler...") false;
+ $LogPrintExit2 debug $0 ("Updating scheduler ModeButtonScheduler...") false;
/ system scheduler set $Scheduler start-time=[ /system clock get time ];
}
diff --git a/mode-button-event b/mode-button-event
index b31ddc3..09c0283 100644
--- a/mode-button-event
+++ b/mode-button-event
@@ -1,6 +1,6 @@
#!rsc by RouterOS
# RouterOS script: mode-button-event
-:global LogPrintExit;
+:global LogPrintExit2;
-$LogPrintExit warning ("This script's functionality has been merged into 'mode-button'.") true;
+$LogPrintExit2 warning "mode-button-event" ("This script's functionality has been merged into 'mode-button'.") true;
diff --git a/mode-button-scheduler b/mode-button-scheduler
index 8844e49..f7045b2 100644
--- a/mode-button-scheduler
+++ b/mode-button-scheduler
@@ -1,6 +1,6 @@
#!rsc by RouterOS
# RouterOS script: mode-button-scheduler
-:global LogPrintExit;
+:global LogPrintExit2;
-$LogPrintExit warning ("This script's functionality has been merged into 'mode-button'.") true;
+$LogPrintExit2 warning "mode-button-scheduler" ("This script's functionality has been merged into 'mode-button'.") true;
diff --git a/netwatch-notify b/netwatch-notify
index d050b75..6bd8953 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -6,13 +6,14 @@
# monitor netwatch and send notifications
# https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-notify.md
+:local 0 "netwatch-notify";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NetwatchNotify;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:global SendNotification;
:global SymbolForNotification;
@@ -32,7 +33,7 @@
}
:if ($HostVal->"status" = "up") do={
- $LogPrintExit debug ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
+ $LogPrintExit2 debug $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
:local Count ($Metric->"count");
:set ($Metric->"count") 0;
:if ($Metric->"notified" = true) do={
@@ -40,7 +41,7 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
- $LogPrintExit info ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
+ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
[ :parse ($HostInfo->"up-hook") ];
}
}
@@ -65,7 +66,7 @@
:set Parent ($NetwatchNotify->$Parent->"parent");
}
}
- $LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
+ $LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
("parent host " . $Parent . " is down.") ]) false;
@@ -74,7 +75,7 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
:set ($Metric->"notified") true;
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
- $LogPrintExit info ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
+ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
[ :parse ($HostInfo->"down-hook") ];
}
}
diff --git a/ospf-to-leds b/ospf-to-leds
index 32027db..727f33b 100644
--- a/ospf-to-leds
+++ b/ospf-to-leds
@@ -6,10 +6,11 @@
# visualize ospf instance state via leds
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ospf-to-leds.md
+:local 0 "ospf-to-leds";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:foreach Instance in=[ / routing ospf instance find where comment~"^ospf-to-leds," ] do={
@@ -17,7 +18,7 @@
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
:local LEDType [ / system leds get [ find where leds=$LED ] type ];
- $LogPrintExit debug ("OSPF instance " . $InstanceVal->"name" . " is " . $InstanceVal->"state" . ".") false;
+ $LogPrintExit2 debug $0 ("OSPF instance " . $InstanceVal->"name" . " is " . $InstanceVal->"state" . ".") false;
:if ($InstanceVal->"state" = "running" && $LEDType = "off") do={
/ system leds set type=on [ find where leds=$LED ];
}
diff --git a/packages-update b/packages-update
index 4a2f418..d23be09 100644
--- a/packages-update
+++ b/packages-update
@@ -6,11 +6,12 @@
# download packages and reboot for installation
# https://git.eworm.de/cgit/routeros-scripts/about/doc/packages-update.md
+:local 0 "packages-update";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DownloadPackage;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptFromTerminal;
:global ScriptLock;
:global VersionToNum;
@@ -20,11 +21,11 @@ $ScriptLock "packages-update";
:local Update [ / system package update get ];
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
- $LogPrintExit warning "Latest version is not known." true;
+ $LogPrintExit2 warning $0 ("Latest version is not known.") true;
}
:if ($Update->"installed-version" = $Update->"latest-version") do={
- $LogPrintExit info ("Version " . $Update->"latest-version" . " is already installed.") true;
+ $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is already installed.") true;
}
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@@ -40,39 +41,39 @@ $ScriptLock "packages-update";
:put "Canceled...";
}
} else={
- $LogPrintExit warning ("Not installing downgrade automatically.") true;
+ $LogPrintExit2 warning $0 ("Not installing downgrade automatically.") true;
}
}
:foreach Package in=[ / system package find where !bundle ] do={
:local PkgName [ / system package get $Package name ];
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
- $LogPrintExit error ("Download for package " . $PkgName . " failed.") true;
+ $LogPrintExit2 error $0 ("Download for package " . $PkgName . " failed.") true;
}
}
:foreach Script in=[ / system script find where name~"^(cloud|email|upload)-backup\$" ] do={
:local ScriptName [ / system script get $Script name ];
:do {
- $LogPrintExit info ("Running backup script " . $ScriptName . " before update.") false;
+ $LogPrintExit2 info $0 ("Running backup script " . $ScriptName . " before update.") false;
/ system script run $Script;
} on-error={
- $LogPrintExit warning ("Running backup script " . $ScriptName . " before update failed!") false;
+ $LogPrintExit2 warning $0 ("Running backup script " . $ScriptName . " before update failed!") false;
:if ([ $ScriptFromTerminal "packages-update" ] = true) do={
:put "Do you want to continue anyway? [y/N]";
:if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
- $LogPrintExit info ("User requested to continue anyway.") false;
+ $LogPrintExit2 info $0 ("User requested to continue anyway.") false;
} else={
- $LogPrintExit info ("Canceled update...") true;
+ $LogPrintExit2 info $0 ("Canceled update...") true;
}
} else={
- $LogPrintExit info ("Canceled non-interactive update.") true;
+ $LogPrintExit2 info $0 ("Canceled non-interactive update.") true;
}
}
}
:if ($DoDowngrade = true) do={
- $LogPrintExit info ("Rebooting for downgrade.") false;
+ $LogPrintExit2 info $0 ("Rebooting for downgrade.") false;
:delay 1s;
/ system package downgrade;
}
@@ -83,10 +84,10 @@ $ScriptLock "packages-update";
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
"/ system scheduler remove reboot-for-update; / system reboot;");
- $LogPrintExit info ("Scheduled reboot for update between 03:00 and 04:00.") true;
+ $LogPrintExit2 info $0 ("Scheduled reboot for update between 03:00 and 04:00.") true;
}
}
-$LogPrintExit info ("Rebooting for update.") false;
+$LogPrintExit2 info $0 ("Rebooting for update.") false;
:delay 1s;
/ system reboot;
diff --git a/ppp-on-up b/ppp-on-up
index cf95e48..fe1492d 100644
--- a/ppp-on-up
+++ b/ppp-on-up
@@ -6,15 +6,16 @@
# run scripts on ppp up
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ppp-on-up.md
+:local 0 "ppp-on-up";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
:local Interface $interface;
:if ([ :typeof $Interface ] = "nothing") do={
- $LogPrintExit error "This script is supposed to run from ppp on-up script hook." true;
+ $LogPrintExit2 error $0 ("This script is supposed to run from ppp on-up script hook.") true;
}
:local IntName [ / interface get $Interface name ];
diff --git a/rotate-ntp b/rotate-ntp
index 6578078..24eb107 100644
--- a/rotate-ntp
+++ b/rotate-ntp
@@ -6,26 +6,27 @@
# rotate the ntp servers
# https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md
+:local 0 "rotate-ntp";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NtpPool;
-:global LogPrintExit;
+:global LogPrintExit2;
:local Ntp1;
:local Ntp2;
:if ([ / system ntp client get enabled ] != true) do={
- $LogPrintExit warning "NTP client is not enabled!" true;
+ $LogPrintExit2 warning $0 ("NTP client is not enabled!") true;
}
:do {
:set Ntp1 [ :resolve ("0." . $NtpPool) ];
:set Ntp2 [ :resolve ("1." . $NtpPool) ];
} on-error={
- $LogPrintExit warning "Resolving NTP server failed." true;
+ $LogPrintExit2 warning $0 ("Resolving NTP server failed.") true;
}
-$LogPrintExit info ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
+$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
/ system ntp client set primary-ntp=$Ntp1 secondary-ntp=$Ntp2;
diff --git a/script-updates b/script-updates
index be79f58..e35f15c 100644
--- a/script-updates
+++ b/script-updates
@@ -1,6 +1,6 @@
#!rsc by RouterOS
# RouterOS script: script-updates
-:global LogPrintExit;
+:global LogPrintExit2;
-$LogPrintExit warning ("This script has been replaced by function '\$ScriptInstallUpdate'.") true;
+$LogPrintExit2 warning "script-updates" ("This script has been replaced by function '\$ScriptInstallUpdate'.") true;
diff --git a/sms-action b/sms-action
index 4c39740..2d2600d 100644
--- a/sms-action
+++ b/sms-action
@@ -6,17 +6,18 @@
# run action on received SMS
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-action.md
+:local 0 "sms-action";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global SmsAction;
-:global LogPrintExit;
+:global LogPrintExit2;
:local Action $action;
:if ([ :typeof $Action ] = "nothing") do={
- $LogPrintExit error "This script is supposed to run from SMS hook with action=..." true;
+ $LogPrintExit2 error $0 ("This script is supposed to run from SMS hook with action=...") true;
}
:local Code ($SmsAction->$Action);
diff --git a/sms-forward b/sms-forward
index abfea99..58ed520 100644
--- a/sms-forward
+++ b/sms-forward
@@ -6,13 +6,14 @@
# forward SMS to e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-forward.md
+:local 0 "sms-forward";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ScriptLock;
:global SendNotification;
:global SymbolForNotification;
@@ -21,7 +22,7 @@
$ScriptLock "sms-forward";
:if ([ / tool sms get receive-enabled ] = false) do={
- $LogPrintExit warning "Receiving of SMS is not enabled." true;
+ $LogPrintExit2 warning $0 ("Receiving of SMS is not enabled.") true;
}
$WaitFullyConnected;
@@ -39,7 +40,7 @@ $WaitFullyConnected;
:if ($Phone = $Settings->"allowed-number" && \
($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={
- $LogPrintExit debug ("Removing SMS, which started a script.") false;
+ $LogPrintExit2 debug $0 ("Removing SMS, which started a script.") false;
/ tool sms inbox remove $Sms;
} else={
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
diff --git a/update-gre-address b/update-gre-address
index 50d1373..af57d2d 100644
--- a/update-gre-address
+++ b/update-gre-address
@@ -7,10 +7,11 @@
# ipsec remote peer
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-gre-address.md
+:local 0 "update-gre-address";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit;
+:global LogPrintExit2;
/ interface gre set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];
@@ -22,7 +23,7 @@
:if ([ :typeof ($PeerVal->"dynamic-address") ] = "str" && \
($PeerVal->"dynamic-address" != $GreIntVal->"remote-address" || \
$GreIntVal->"disabled" = true)) do={
- $LogPrintExit info ("Updating remote address for interface " . $GreIntVal->"name" . " to " . $PeerVal->"dynamic-address") false;
+ $LogPrintExit2 info $0 ("Updating remote address for interface " . $GreIntVal->"name" . " to " . $PeerVal->"dynamic-address") false;
/ interface gre set remote-address=0.0.0.0 disabled=yes [ find where remote-address=$PeerVal->"dynamic-address" name!=$GreIntVal->"name" ];
/ interface gre set $GreInt remote-address=($PeerVal->"dynamic-address") disabled=no;
}
diff --git a/update-tunnelbroker b/update-tunnelbroker
index 6cdb195..2168390 100644
--- a/update-tunnelbroker
+++ b/update-tunnelbroker
@@ -7,15 +7,16 @@
# update local address of tunnelbroker interface
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-tunnelbroker.md
+:local 0 "update-tunnelbroker";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertificateAvailable;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:if ([ / ip cloud get ddns-enabled ] != true) do={
- $LogPrintExit error "IP cloud DDNS is not enabled." true;
+ $LogPrintExit2 error $0 ("IP cloud DDNS is not enabled.") true;
}
# Get the current ip address from cloud
@@ -32,14 +33,14 @@
:local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ];
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
- $LogPrintExit error ("Downloading required certificate failed.") true;
+ $LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
}
- $LogPrintExit info ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $PublicAddress) false;
+ $LogPrintExit2 info $0 ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $PublicAddress) false;
/ tool fetch check-certificate=yes-without-crl \
("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \
user=($Comment->"user") password=($Comment->"pass") output=none;
/ interface 6to4 set $Interface local-address=$PublicAddress;
} else={
- $LogPrintExit debug ("All tunnelbroker configuration is up to date for interface " . $InterfaceVal->"name" . ".") false;
+ $LogPrintExit2 debug $0 ("All tunnelbroker configuration is up to date for interface " . $InterfaceVal->"name" . ".") false;
}
}
diff --git a/upload-backup b/upload-backup
index e16a4e5..1e3e8e8 100644
--- a/upload-backup
+++ b/upload-backup
@@ -6,6 +6,7 @@
# create and upload backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/upload-backup.md
+:local 0 "upload-backup";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@@ -21,7 +22,7 @@
:global CharacterReplace;
:global DeviceInfo;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global SendNotification;
:global SymbolForNotification;
:global WaitForFile;
@@ -31,7 +32,7 @@ $WaitFullyConnected;
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
- $LogPrintExit error ("Configured to send neither backup nor config export.") true;
+ $LogPrintExit2 error $0 ("Configured to send neither backup nor config export.") true;
}
# filename based on identity
@@ -50,7 +51,7 @@ $WaitFullyConnected;
user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".backup");
:set BackupFile ($FileName . ".backup");
} on-error={
- $LogPrintExit error ("Uploading backup file failed!") false;
+ $LogPrintExit2 error $0 ("Uploading backup file failed!") false;
:set BackupFile "failed";
:set Failed 1;
}
@@ -66,7 +67,7 @@ $WaitFullyConnected;
user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".rsc");
:set ConfigFile ($FileName . ".rsc");
} on-error={
- $LogPrintExit error ("Uploading configuration export failed!") false;
+ $LogPrintExit2 error $0 ("Uploading configuration export failed!") false;
:set ConfigFile "failed";
:set Failed 1;
}