global: give script or function name in log messages

This commit is contained in:
Christian Hesse 2021-02-22 15:14:10 +01:00
parent b0e52aa2d1
commit f46db91845
46 changed files with 262 additions and 212 deletions

View file

@ -8,6 +8,7 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "accesslist-duplicates.capsman";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }

View file

@ -8,6 +8,7 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "accesslist-duplicates.local";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }

View file

@ -9,6 +9,7 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man' # !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'! # !! or 'interface wireless'!
:local 0 "accesslist-duplicates%TEMPL%";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }

View file

@ -6,13 +6,14 @@
# reset bridge ports to default bridge # reset bridge ports to default bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
:local 0 "bridge-port-to-default";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BridgePortTo; :global BridgePortTo;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={ :foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={
@ -23,19 +24,19 @@
:if ($BridgeDefault = "dhcp-client") do={ :if ($BridgeDefault = "dhcp-client") do={
:if ([ :len $DHCPClient ] != 1) 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; " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
} }
:local DHCPClientDisabled [ / ip dhcp-client get $DHCPClient disabled ]; :local DHCPClientDisabled [ / ip dhcp-client get $DHCPClient disabled ];
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={ :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; / interface bridge port disable $BridgePort;
/ ip dhcp-client enable $DHCPClient; / ip dhcp-client enable $DHCPClient;
} }
} else={ } else={
:if ($BridgePortVal->"disabled" = true || $BridgeDefault != $BridgePortVal->"bridge") do={ :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; " bridge " . $BridgeDefault . ", disabling dhcp client.") false;
:if ([ :len $DHCPClient ] = 1) do={ :if ([ :len $DHCPClient ] = 1) do={
/ ip dhcp-client disable $DHCPClient; / ip dhcp-client disable $DHCPClient;
@ -43,7 +44,7 @@
} }
/ interface bridge port set disabled=no bridge=$BridgeDefault $BridgePort; / interface bridge port set disabled=no bridge=$BridgeDefault $BridgePort;
} else={ } else={
$LogPrintExit debug ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \ $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
" bridge " . $BridgeDefault . ".") false; " bridge " . $BridgeDefault . ".") false;
} }
} }

View file

@ -6,6 +6,7 @@
# toggle bridge ports between default and alt bridge # toggle bridge ports between default and alt bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
:local 0 "bridge-port-toggle";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }

View file

@ -7,12 +7,13 @@
# download and cleanup packages for CAP installation from CAPsMAN # download and cleanup packages for CAP installation from CAPsMAN
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-download-packages.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-download-packages.md
:local 0 "capsman-download-packages";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CleanFilePath; :global CleanFilePath;
:global DownloadPackage; :global DownloadPackage;
:global LogPrintExit; :global LogPrintExit2;
:global MkDir; :global MkDir;
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
@ -25,15 +26,15 @@ $WaitFullyConnected;
:local Updated false; :local Updated false;
:if ([ :len $PackagePath ] = 0) do={ :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 ([ :len [ / file find where name=$PackagePath type="directory" ] ] = 0) do={
:if ([ $MkDir $PackagePath ] = false) 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; $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; "). Please place your packages!") false;
} }

View file

@ -7,10 +7,11 @@
# upgrade CAPs one after another # upgrade CAPs one after another
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-rolling-upgrade.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-rolling-upgrade.md
:local 0 "capsman-rolling-upgrade";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock "capsman-rolling-upgrade"; $ScriptLock "capsman-rolling-upgrade";
@ -23,7 +24,7 @@ $ScriptLock "capsman-rolling-upgrade";
:if ($Delay > 120) do={ :set Delay 120; } :if ($Delay > 120) do={ :set Delay 120; }
:foreach RemoteCap in=[ / caps-man remote-cap find where version!=$InstalledVersion ] do={ :foreach RemoteCap in=[ / caps-man remote-cap find where version!=$InstalledVersion ] do={
:local RemoteCapVal [ / caps-man remote-cap get $RemoteCap ]; :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; " (" . $RemoteCapVal->"identity" . ")...") false;
/ caps-man remote-cap upgrade [ find where name=$RemoteCapVal->"name" ]; / caps-man remote-cap upgrade [ find where name=$RemoteCapVal->"name" ];
:delay ($Delay . "s"); :delay ($Delay . "s");

View file

@ -6,12 +6,13 @@
# renew locally issued certificates # renew locally issued certificates
# https://git.eworm.de/cgit/routeros-scripts/about/doc/certificate-renew-issued.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/certificate-renew-issued.md
:local 0 "certificate-renew-issued";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertIssuedExportPass; :global CertIssuedExportPass;
:global LogPrintExit; :global LogPrintExit2;
:global MkDir; :global MkDir;
:foreach Cert in=[ / certificate find where issued expires-after<3w ] do={ :foreach Cert in=[ / certificate find where issued expires-after<3w ] do={
@ -26,12 +27,12 @@
/ certificate export-certificate ($CertVal->"name") type=pkcs12 \ / certificate export-certificate ($CertVal->"name") type=pkcs12 \
file-name=("cert-issued/" . $CertVal->"common-name") \ file-name=("cert-issued/" . $CertVal->"common-name") \
export-passphrase=($CertIssuedExportPass->($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; "\", exported to \"cert-issued/" . $CertVal->"common-name" . ".p12\".") false;
} else={ } else={
$LogPrintExit warning ("Failed creating directory, not exporting certificate.") false; $LogPrintExit2 warning $0 ("Failed creating directory, not exporting certificate.") false;
} }
} else={ } else={
$LogPrintExit info ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false; $LogPrintExit2 info $0 ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false;
} }
} }

View file

@ -6,6 +6,7 @@
# check for certificate validity # check for certificate validity
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-certificates.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/check-certificates.md
:local 0 "check-certificates";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -17,7 +18,7 @@
:global CertificateAvailable :global CertificateAvailable
:global CertificateNameByCN; :global CertificateNameByCN;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -37,7 +38,7 @@ $WaitFullyConnected;
:do { :do {
:if ([ :len $CertRenewUrl ] = 0) 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={ :foreach Type in={ ".pem"; ".p12" } do={
@ -55,7 +56,7 @@ $WaitFullyConnected;
$CertificateNameByCN [ / certificate get $CertInChain common-name ]; $CertificateNameByCN [ / certificate get $CertInChain common-name ];
} }
} on-error={ } 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 ]; :local CertNewVal [ / certificate get $CertNew ];
:if ([ $CertificateAvailable ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") ] = false) do={ :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={ :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={ :if (($CertVal->"private-key") = true && ($CertVal->"private-key") != ($CertNewVal->"private-key")) do={
/ certificate remove $CertNew; / 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") ]; / 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 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") ]; / ip ipsec identity set remote-certificate=($CertNewVal->"name") [ / ip ipsec identity find where remote-certificate=($CertVal->"name") ];
} on-error={ } 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 { :do {
/ ip hotspot profile set ssl-certificate=($CertNewVal->"name") [ / ip hotspot profile find where ssl-certificate=($CertVal->"name") ]; / ip hotspot profile set ssl-certificate=($CertNewVal->"name") [ / ip hotspot profile find where ssl-certificate=($CertVal->"name") ];
} on-error={ } 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; / certificate remove $Cert;
@ -102,9 +103,9 @@ $WaitFullyConnected;
"Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \ "Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \
"Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \ "Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \
"Expires in: " . [ $FormatExpire ($CertNewVal->"expires-after") ]) "" "true"; "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={ } 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 ]; :local CertVal [ / certificate get $Cert ];
:if ([ :len [ / certificate scep-server find where ca-cert=($CertVal->"ca") ] ] > 0) do={ :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={ } else={
:local State [ $IfThenElse (($CertVal->"expired") = true) "expired" "is about to expire" ]; :local State [ $IfThenElse (($CertVal->"expired") = true) "expired" "is about to expire" ];
@ -125,7 +126,7 @@ $WaitFullyConnected;
"Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \ "Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \
"Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \ "Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \
"Expires in: " . [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ]); "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; ", it is invalid after " . ($CertVal->"invalid-after") . ".") false;
} }
} }

View file

@ -6,6 +6,7 @@
# check for RouterOS health state # check for RouterOS health state
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-health.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/check-health.md
:local 0 "check-health";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -16,7 +17,7 @@
:global CheckHealthVoltagePercent; :global CheckHealthVoltagePercent;
:global Identity; :global Identity;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -28,7 +29,7 @@
:local CheckHealthCurrent [ / system health get ]; :local CheckHealthCurrent [ / system health get ];
:if ([ :len $CheckHealthCurrent ] = 0) do={ :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={ :if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
@ -70,7 +71,7 @@
:if ($Name ~ "temperature" && \ :if ($Name ~ "temperature" && \
[ :typeof $Temperature ] = "num") do={ [ :typeof $Temperature ] = "num") do={
:if ([ :typeof ($CheckHealthTemperature->$Name) ] != "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; :set ($CheckHealthTemperature->$Name) 50;
} }
:local Validate [ / system health get $Name ]; :local Validate [ / system health get $Name ];

View file

@ -6,6 +6,7 @@
# check for LTE firmware upgrade, send notification # check for LTE firmware upgrade, send notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-lte-firmware-upgrade.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/check-lte-firmware-upgrade.md
:local 0 "check-lte-firmware-upgrade";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -13,7 +14,7 @@
:global SentLteFirmwareUpgradeNotification; :global SentLteFirmwareUpgradeNotification;
:global CharacterReplace; :global CharacterReplace;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -23,7 +24,7 @@
:local Firmware [ / interface lte firmware-upgrade $Interface once as-value ]; :local Firmware [ / interface lte firmware-upgrade $Interface once as-value ];
:if ($SentLteFirmwareUpgradeNotification = ($Firmware->"latest")) do={ :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; ($Firmware->"latest") . ".") false;
} else={ } else={
:if (($Firmware->"installed") != ($Firmware->"latest")) do={ :if (($Firmware->"installed") != ($Firmware->"latest")) do={
@ -38,7 +39,7 @@
} }
} }
} on-error={ } 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; $IntName . ".") false;
} }
} }

View file

@ -6,6 +6,7 @@
# check for RouterOS update, send notification and/or install # check for RouterOS update, send notification and/or install
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-routeros-update.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/check-routeros-update.md
:local 0 "check-routeros-update";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -16,7 +17,7 @@
:global SentRouterosUpdateNotification; :global SentRouterosUpdateNotification;
:global DeviceInfo; :global DeviceInfo;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptFromTerminal; :global ScriptFromTerminal;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -37,7 +38,7 @@ $WaitFullyConnected;
:if ([ :len [ / system package find where name="wireless" disabled=no ] ] > 0) do={ :if ([ :len [ / system package find where name="wireless" disabled=no ] ] > 0) do={
:if ([ / interface wireless cap get enabled ] = true && \ :if ([ / interface wireless cap get enabled ] = true && \
[ / caps-man manager get enabled ] = false) do={ [ / 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 ]; :local Update [ / system package update get ];
:if ([ :len ($Update->"latest-version") ] = 0) do={ :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") ]; :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@ -58,7 +59,7 @@ $WaitFullyConnected;
:if ($NumInstalled < $NumLatest) do={ :if ($NumInstalled < $NumLatest) do={
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) 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") \ $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ ("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "...") $Link "true";
@ -67,7 +68,7 @@ $WaitFullyConnected;
:if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \ :if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \
version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={ 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") \ $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \ ("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "...") $Link "true";
@ -81,10 +82,10 @@ $WaitFullyConnected;
($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \ ($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \
"&latest=" . $Update->"latest-version") output=user as-value ]; "&latest=" . $Update->"latest-version") output=user as-value ];
} on-error={ } 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={ :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") \ $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ ("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "...") $Link "true";
@ -102,7 +103,7 @@ $WaitFullyConnected;
} }
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :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; $Update->"latest-version" . ".") true;
} }
@ -115,7 +116,7 @@ $WaitFullyConnected;
:if ($NumInstalled > $NumLatest) do={ :if ($NumInstalled > $NumLatest) do={
:if ($SentRouterosUpdateNotification = $Update->"latest-version") 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; $Update->"latest-version" . ".") true;
} }
@ -123,7 +124,7 @@ $WaitFullyConnected;
("A different RouterOS version " . ($Update->"latest-version") . \ ("A different RouterOS version " . ($Update->"latest-version") . \
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \ " is available for " . $Identity . ", but it is a downgrade.\n\n" . \
[ $DeviceInfo ]) $Link "true"; [ $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; " is available for downgrade.") false;
:set SentRouterosUpdateNotification ($Update->"latest-version"); :set SentRouterosUpdateNotification ($Update->"latest-version");
} }

View file

@ -6,6 +6,7 @@
# upload backup to MikroTik cloud # upload backup to MikroTik cloud
# https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md
:local 0 "cloud-backup";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -13,7 +14,7 @@
:global Identity; :global Identity;
:global DeviceInfo; :global DeviceInfo;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:global WaitFullyConnected; :global WaitFullyConnected;
@ -42,5 +43,5 @@ $WaitFullyConnected;
} on-error={ } on-error={
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \ $SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \
("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]); ("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;
} }

View file

@ -8,13 +8,14 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "collect-wireless-mac.capsman";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity; :global Identity;
:global GetMacVendor; :global GetMacVendor;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :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={ :if ([ :len [ / caps-man access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ caps-man access-list add comment="--- collected above ---" disabled=yes; / 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); :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 Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \ :local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface); "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; / caps-man access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \ $SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \ ("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" . \ "DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime); "Date: " . $DateTime);
} else={ } else={
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / caps-man access-list get $AccessList comment ]) false; [ / caps-man access-list get $AccessList comment ]) false;
} }
} }

View file

@ -8,13 +8,14 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "collect-wireless-mac.local";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity; :global Identity;
:global GetMacVendor; :global GetMacVendor;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :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={ :if ([ :len [ / interface wireless access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ interface wireless access-list add comment="--- collected above ---" disabled=yes; / 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); :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 Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \ :local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface); "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; / interface wireless access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \ $SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \ ("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" . \ "DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime); "Date: " . $DateTime);
} else={ } else={
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / interface wireless access-list get $AccessList comment ]) false; [ / interface wireless access-list get $AccessList comment ]) false;
} }
} }

View file

@ -9,13 +9,14 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man' # !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'! # !! or 'interface wireless'!
:local 0 "collect-wireless-mac%TEMPL%";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity; :global Identity;
:global GetMacVendor; :global GetMacVendor;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -24,7 +25,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
:if ([ :len [ / %PATH% access-list find where comment="--- collected above ---" disabled ] ] = 0) do={ :if ([ :len [ / %PATH% access-list find where comment="--- collected above ---" disabled ] ] = 0) do={
/ %PATH% access-list add comment="--- collected above ---" disabled=yes; / %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); :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 Vendor [ $GetMacVendor $Mac ];
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \ :local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface); "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; / %PATH% access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
$SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \ $SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \ ("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" . \ "DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime); "Date: " . $DateTime);
} else={ } else={
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
[ / %PATH% access-list get $AccessList comment ]) false; [ / %PATH% access-list get $AccessList comment ]) false;
} }
} }

View file

@ -9,13 +9,14 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "daily-psk.capsman";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment; :global DailyPskMatchComment;
:global Identity; :global Identity;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:global UrlEncode; :global UrlEncode;
@ -65,13 +66,13 @@ $WaitFullyConnected;
:local Skip 0; :local Skip 0;
:if ($NewPsk != $OldPsk) do={ :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; / caps-man access-list set $AccList private-passphrase=$NewPsk;
:if ([ :len [ / caps-man interface find where configuration=$Configuration ] ] > 0) do={ :if ([ :len [ / caps-man interface find where configuration=$Configuration ] ] > 0) do={
:foreach SeenSsid in=$Seen do={ :foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) 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; :set Skip 1;
} }
} }

View file

@ -9,13 +9,14 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "daily-psk.local";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment; :global DailyPskMatchComment;
:global Identity; :global Identity;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:global UrlEncode; :global UrlEncode;
@ -65,13 +66,13 @@ $WaitFullyConnected;
:local Skip 0; :local Skip 0;
:if ($NewPsk != $OldPsk) do={ :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; / interface wireless access-list set $AccList private-pre-shared-key=$NewPsk;
:if ([ :len [ / interface wireless find where name=$IntName disabled=no ] ] = 1) do={ :if ([ :len [ / interface wireless find where name=$IntName disabled=no ] ] = 1) do={
:foreach SeenSsid in=$Seen do={ :foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) 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; :set Skip 1;
} }
} }

View file

@ -10,13 +10,14 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man' # !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'! # !! or 'interface wireless'!
:local 0 "daily-psk%TEMPL%";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment; :global DailyPskMatchComment;
:global Identity; :global Identity;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:global UrlEncode; :global UrlEncode;
@ -69,7 +70,7 @@ $WaitFullyConnected;
:local Skip 0; :local Skip 0;
:if ($NewPsk != $OldPsk) do={ :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; / interface wireless access-list set $AccList private-pre-shared-key=$NewPsk;
/ caps-man access-list set $AccList private-passphrase=$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={ :if ([ :len [ / caps-man interface find where configuration=$Configuration ] ] > 0) do={
:foreach SeenSsid in=$Seen do={ :foreach SeenSsid in=$Seen do={
:if ($SeenSsid = $Ssid) 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; :set Skip 1;
} }
} }

View file

@ -8,10 +8,11 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "dhcp-lease-comment.capsman";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={ :foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ]; :local LeaseVal [ / ip dhcp-server lease get $Lease ];
@ -21,7 +22,7 @@
:set NewComment [ / caps-man access-list get $AccessList comment ]; :set NewComment [ / caps-man access-list get $AccessList comment ];
} }
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={ :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; / ip dhcp-server lease set comment=$NewComment $Lease;
} }
} }

View file

@ -8,10 +8,11 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local 0 "dhcp-lease-comment.local";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={ :foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ]; :local LeaseVal [ / ip dhcp-server lease get $Lease ];
@ -21,7 +22,7 @@
:set NewComment [ / interface wireless access-list get $AccessList comment ]; :set NewComment [ / interface wireless access-list get $AccessList comment ];
} }
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={ :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; / ip dhcp-server lease set comment=$NewComment $Lease;
} }
} }

View file

@ -9,10 +9,11 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man' # !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'! # !! or 'interface wireless'!
:local 0 "dhcp-lease-comment%TEMPL%";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={ :foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
:local LeaseVal [ / ip dhcp-server lease get $Lease ]; :local LeaseVal [ / ip dhcp-server lease get $Lease ];
@ -22,7 +23,7 @@
:set NewComment [ / %PATH% access-list get $AccessList comment ]; :set NewComment [ / %PATH% access-list get $AccessList comment ];
} }
:if ([ :len $NewComment ] != 0 && $LeaseVal->"comment" != $NewComment) do={ :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; / ip dhcp-server lease set comment=$NewComment $Lease;
} }
} }

View file

@ -6,6 +6,7 @@
# check DHCP leases and add/remove/update DNS entries # check DHCP leases and add/remove/update DNS entries
# https://git.eworm.de/cgit/routeros-scripts/about/doc/dhcp-to-dns.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/dhcp-to-dns.md
:local 0 "dhcp-to-dns";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -17,7 +18,7 @@
:global CharacterReplace; :global CharacterReplace;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:local Zone \ :local Zone \
([ $IfThenElse ($PrefixInZone = true) "dhcp." ] . \ ([ $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={ :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; / 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); :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 DnsRecordVal [ / ip dns static get $DnsRecord ];
:local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ]; :local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ];
:if ([ :len [ / ip dhcp-server lease find where mac-address=$MacAddress address=($DnsRecordVal->"address") status=bound ] ] > 0) do={ :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={ } else={
:local Found false; :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; / ip dns static remove $DnsRecord;
} }
} }
@ -65,13 +66,13 @@
} }
:if ($DnsIp = $LeaseVal->"address") do={ :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={ } 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; / ip dns static set name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord;
} }
} else={ } 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; / ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
} }
} }

View file

@ -1,6 +1,6 @@
#!rsc by RouterOS #!rsc by RouterOS
# RouterOS script: early-errors # 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;

View file

@ -6,6 +6,7 @@
# create and email backup and config file # create and email backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/email-backup.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/email-backup.md
:local 0 "email-backup";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -19,7 +20,7 @@
:global CharacterReplace; :global CharacterReplace;
:global DeviceInfo; :global DeviceInfo;
:global LogPrintExit; :global LogPrintExit2;
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
@ -27,11 +28,11 @@ $WaitFullyConnected;
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $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={ :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 # filename based on identity

View file

@ -32,6 +32,7 @@
:global IfThenElse; :global IfThenElse;
:global IPCalc; :global IPCalc;
:global LogPrintExit; :global LogPrintExit;
:global LogPrintExit2;
:global MkDir; :global MkDir;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global RandomDelay; :global RandomDelay;
@ -58,19 +59,19 @@
:local CommonName [ :tostr $1 ]; :local CommonName [ :tostr $1 ];
:global CertificateDownload; :global CertificateDownload;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global RequiredRouterOS; :global RequiredRouterOS;
:if ([ / system resource get free-hdd-space ] < 8388608 && \ :if ([ / system resource get free-hdd-space ] < 8388608 && \
[ / certificate settings get crl-download ] = true && \ [ / certificate settings get crl-download ] = true && \
[ / certificate settings get crl-store ] = "system") do={ [ / 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; "is configured to download certificate CRLs to system!") false;
} }
:if ([ :len [ / certificate find where common-name=$CommonName ] ] = 0) do={ :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={ :if ([ $CertificateDownload $CommonName ] = false) do={
:return false; :return false;
} }
@ -83,7 +84,7 @@
:local CertVal [ / certificate get [ find where common-name=$CommonName ] ]; :local CertVal [ / certificate get [ find where common-name=$CommonName ] ];
:do { :do {
:if ([ :len [ / certificate find where skid=($CertVal->"akid") ] ] = 0) 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; "\" is incomplete, missing \"" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\".") false;
:if ([ $CertificateDownload $CommonName ] = false) do={ :if ([ $CertificateDownload $CommonName ] = false) do={
:return false; :return false;
@ -102,11 +103,11 @@
:global ScriptUpdatesUrlSuffix; :global ScriptUpdatesUrlSuffix;
:global CertificateNameByCN; :global CertificateNameByCN;
:global LogPrintExit; :global LogPrintExit2;
:global UrlEncode; :global UrlEncode;
:global WaitForFile; :global WaitForFile;
$LogPrintExit info ("Downloading and importing certificate with " . \ $LogPrintExit2 info $0 ("Downloading and importing certificate with " . \
"CommonName \"" . $CommonName . "\".") false; "CommonName \"" . $CommonName . "\".") false;
:do { :do {
:local LocalFileName ($CommonName . ".pem"); :local LocalFileName ($CommonName . ".pem");
@ -123,7 +124,7 @@
$CertificateNameByCN [ / certificate get $Cert common-name ]; $CertificateNameByCN [ / certificate get $Cert common-name ];
} }
} on-error={ } on-error={
$LogPrintExit warning ("Failed importing certificate with " . \ $LogPrintExit2 warning $0 ("Failed importing certificate with " . \
"CommonName \"" . $CommonName . "\"!") false; "CommonName \"" . $CommonName . "\"!") false;
:return false; :return false;
} }
@ -242,7 +243,7 @@
:global CertificateAvailable; :global CertificateAvailable;
:global CleanFilePath; :global CleanFilePath;
:global LogPrintExit; :global LogPrintExit2;
:global WaitForFile; :global WaitForFile;
:if ([ :len $PkgName ] = 0) do={ :return false; } :if ([ :len $PkgName ] = 0) do={ :return false; }
@ -256,12 +257,12 @@
:local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ]; :local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
:if ([ :len [ / file find where name=$PkgDest type="package" ] ] > 0) do={ :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; :return true;
} }
:if ([ $CertificateAvailable "R3" ] = false) do={ :if ([ $CertificateAvailable "R3" ] = false) do={
$LogPrintExit error ("Downloading required certificate failed.") true; $LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
} }
:local Retry 3; :local Retry 3;
@ -276,7 +277,7 @@
:return true; :return true;
} }
} on-error={ } on-error={
$LogPrintExit debug ("Downloading package failed.") false; $LogPrintExit2 debug $0 ("Downloading package failed.") false;
} }
/ file remove [ find where name=$PkgDest ]; / file remove [ find where name=$PkgDest ];
@ -290,13 +291,13 @@
:set FlushEmailQueue do={ :set FlushEmailQueue do={
:global EmailQueue; :global EmailQueue;
:global LogPrintExit; :global LogPrintExit2;
:local AllDone true; :local AllDone true;
:local QueueLen [ :len $EmailQueue ]; :local QueueLen [ :len $EmailQueue ];
:if ([ :len [ / system scheduler find where name="FlushEmailQueue" ] ] > 0 && $QueueLen = 0) do={ :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 ]; / system scheduler set interval=1m [ find where name="FlushEmailQueue" interval=1s ];
@ -332,13 +333,13 @@
:global TelegramQueue; :global TelegramQueue;
:global TelegramTokenId; :global TelegramTokenId;
:global LogPrintExit; :global LogPrintExit2;
:local AllDone true; :local AllDone true;
:local QueueLen [ :len $TelegramQueue ]; :local QueueLen [ :len $TelegramQueue ];
:if ([ :len [ / system scheduler find where name="FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={ :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={ :foreach Id,Message in=$TelegramQueue do={
@ -352,7 +353,7 @@
"&text=" . ($Message->"text")); "&text=" . ($Message->"text"));
:set ($TelegramQueue->$Id); :set ($TelegramQueue->$Id);
} on-error={ } on-error={
$LogPrintExit debug ("Sending queued Telegram message failed.") false; $LogPrintExit2 debug $0 ("Sending queued Telegram message failed.") false;
:set AllDone false; :set AllDone false;
} }
} }
@ -369,11 +370,11 @@
:local Mac [ :tostr $1 ]; :local Mac [ :tostr $1 ];
:global CertificateAvailable; :global CertificateAvailable;
:global LogPrintExit; :global LogPrintExit2;
:do { :do {
:if ([ $CertificateAvailable "Cloudflare Inc ECC CA-3" ] = false) 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 \ :local Vendor ([ / tool fetch check-certificate=yes-without-crl \
("https://api.macvendors.com/" . [ :pick $Mac 0 8 ]) output=user as-value ]->"data"); ("https://api.macvendors.com/" . [ :pick $Mac 0 8 ]) output=user as-value ]->"data");
@ -449,11 +450,19 @@
:return $Return; :return $Return;
} }
# log and print with same text, optionally exit # deprecated compatibility wrapper
:set LogPrintExit do={ :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 Severity [ :tostr $1 ];
:local Message [ :tostr $2 ]; :local Name [ :tostr $2 ];
:local Exit [ :tostr $3 ]; :local Message [ :tostr $3 ];
:local Exit [ :tostr $4 ];
:global PrintDebug; :global PrintDebug;
@ -468,12 +477,13 @@
:return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m"); :return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m");
} }
:local Log ($Name . ": " . $Message);
:if ($Severity ~ "^(debug|error|info)\$") do={ :if ($Severity ~ "^(debug|error|info)\$") do={
:if ($Severity = "debug") do={ :log debug $Message; } :if ($Severity = "debug") do={ :log debug $Log; }
:if ($Severity = "error") do={ :log error $Message; } :if ($Severity = "error") do={ :log error $Log; }
:if ($Severity = "info" ) do={ :log info $Message; } :if ($Severity = "info" ) do={ :log info $Log; }
} else={ } else={
:log warning $Message; :log warning $Log;
:set Severity "warning"; :set Severity "warning";
} }
@ -545,11 +555,11 @@
:local Required [ :tostr $2 ]; :local Required [ :tostr $2 ];
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global VersionToNum; :global VersionToNum;
:if ([ $VersionToNum $Required ] > [ $VersionToNum [ / system package update get installed-version ] ]) do={ :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; " '" . $Caller . "' (at least specific functionality) requires RouterOS " . $Required . ". Please update!") false;
:return false; :return false;
} }
@ -560,7 +570,7 @@
:set ScriptFromTerminal do={ :set ScriptFromTerminal do={
:local Script [ :tostr $1 ]; :local Script [ :tostr $1 ];
:global LogPrintExit; :global LogPrintExit2;
:foreach Job in=[ / system script job find where script=$Script ] do={ :foreach Job in=[ / system script job find where script=$Script ] do={
:set Job [ / system script job get $Job ]; :set Job [ / system script job get $Job ];
@ -568,11 +578,11 @@
:set Job [ / system script job get [ find where .id=($Job->"parent") ] ]; :set Job [ / system script job get [ find where .id=($Job->"parent") ] ];
} }
:if (($Job->"type") = "login") do={ :if (($Job->"type") = "login") do={
$LogPrintExit debug ("Script " . $Script . " started from terminal.") false; $LogPrintExit2 debug $0 ("Script " . $Script . " started from terminal.") false;
:return true; :return true;
} }
} }
$LogPrintExit debug ("Script " . $Script . " NOT started from terminal.") false; $LogPrintExit2 debug $0 ("Script " . $Script . " NOT started from terminal.") false;
:return false; :return false;
} }
@ -591,19 +601,19 @@
:global SentConfigChangesNotification; :global SentConfigChangesNotification;
:global CertificateAvailable; :global CertificateAvailable;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptInstallUpdate; :global ScriptInstallUpdate;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $CertificateAvailable "R3" ] = false) do={ :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={ :foreach Script in=$Scripts do={
:if ([ :len [ / system script find where name=$Script ] ] = 0) 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"; / 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={ :foreach Scheduler in=[ / system scheduler find where on-event~("\\b" . $ScriptVal->"name" . "\\b") ] do={
:local SchedulerVal [ / system scheduler get $Scheduler ]; :local SchedulerVal [ / system scheduler get $Scheduler ];
:if ($ScriptVal->"policy" != $SchedulerVal->"policy") do={ :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; " and its scheduler " . $SchedulerVal->"name" . "!") false;
} }
} }
@ -630,7 +640,7 @@
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={ :if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={
:local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ]; :local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ];
:if (!($Comment->"ignore" = true)) do={ :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 { :do {
:local BaseUrl $ScriptUpdatesBaseUrl; :local BaseUrl $ScriptUpdatesBaseUrl;
:local UrlSuffix $ScriptUpdatesUrlSuffix; :local UrlSuffix $ScriptUpdatesUrlSuffix;
@ -643,7 +653,7 @@
:set SourceNew ($Result->"data"); :set SourceNew ($Result->"data");
} }
} on-error={ } 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={ :if ($SourceNew != $ScriptVal->"source") do={
:local DontRequirePermissions \ :local DontRequirePermissions \
($SourceNew~"\n# requires: dont-require-permissions=yes\n"); ($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 \ / system script set owner=($ScriptVal->"name") source=$SourceNew \
dont-require-permissions=$DontRequirePermissions $Script; dont-require-permissions=$DontRequirePermissions $Script;
:if ($ScriptVal->"name" = "global-config" && \ :if ($ScriptVal->"name" = "global-config" && \
[ :len [ / system script find where name="global-config-overlay" ] ] > 0) do={ [ :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 { :do {
/ system script { run global-config; run global-config-overlay; } / system script { run global-config; run global-config-overlay; }
} on-error={ } 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={ :if ($ScriptVal->"name" = "global-functions") do={
$LogPrintExit info ("Reloading global functions.") false; $LogPrintExit2 info $0 ("Reloading global functions.") false;
:do { :do {
/ system script run global-functions; / system script run global-functions;
} on-error={ } on-error={
$LogPrintExit error ("Reloading global functions failed!") false; $LogPrintExit2 error $0 ("Reloading global functions failed!") false;
} }
} }
} else={ } else={
$LogPrintExit debug ("Script " . $ScriptVal->"name" . " did not change.") false; $LogPrintExit2 debug $0 ("Script " . $ScriptVal->"name" . " did not change.") false;
} }
} else={ } 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={ } 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 " . \ " is out of date. Please update " . $ConfigScript . ", then increase " . \
"\$GlobalConfigVersion (currently " . $GlobalConfigVersion . \ "\$GlobalConfigVersion (currently " . $GlobalConfigVersion . \
") to " . $ExpectedConfigVersion . " and re-run " . $ConfigScript . "."); ") 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 { :do {
:local Result [ / tool fetch check-certificate=yes-without-crl \ :local Result [ / tool fetch check-certificate=yes-without-crl \
($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \ ($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \
@ -712,17 +722,17 @@
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={ :for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
:local Migration ($GlobalConfigMigration->[ :tostr $I ]); :local Migration ($GlobalConfigMigration->[ :tostr $I ]);
:if ([ :typeof $Migration ] = "str") do={ :if ([ :typeof $Migration ] = "str") do={
$LogPrintExit info ("Applying migration: " . $Migration) false; $LogPrintExit2 info $0 ("Applying migration: " . $Migration) false;
[ :parse $Migration ]; [ :parse $Migration ];
} }
:set NotificationMessage ($NotificationMessage . \ :set NotificationMessage ($NotificationMessage . \
"\n * " . $GlobalConfigChanges->[ :tostr $I ]); "\n * " . $GlobalConfigChanges->[ :tostr $I ]);
$LogPrintExit info ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false; $LogPrintExit2 info $0 ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
} }
:set GlobalConfigChanges; :set GlobalConfigChanges;
:set GlobalConfigMigration; :set GlobalConfigMigration;
} on-error={ } on-error={
$LogPrintExit warning ("Failed fetching changes!") false; $LogPrintExit2 warning $0 ("Failed fetching changes!") false;
:set NotificationMessage ($NotificationMessage . \ :set NotificationMessage ($NotificationMessage . \
"\n\nChanges are not available."); "\n\nChanges are not available.");
} }
@ -743,18 +753,18 @@
} }
:if ($ScriptInstallUpdateBefore != [ :tostr $ScriptInstallUpdate ]) do={ :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 # lock script against multiple invocation
:set ScriptLock do={ :set ScriptLock do={
:global LogPrintExit; :global LogPrintExit2;
:local Script [ :tostr $1 ]; :local Script [ :tostr $1 ];
:if ([ :len [ / system script job find where script=$Script ] ] > 1) do={ :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 EmailGeneralCc;
:global EmailQueue; :global EmailQueue;
:global LogPrintExit; :global LogPrintExit2;
:global IfThenElse; :global IfThenElse;
:if ([ :len $EmailGeneralTo ] = 0) do={ :if ([ :len $EmailGeneralTo ] = 0) do={
@ -823,7 +833,7 @@
:global CertificateAvailable; :global CertificateAvailable;
:global CharacterReplace; :global CharacterReplace;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global SymbolForNotification; :global SymbolForNotification;
:global UrlEncode; :global UrlEncode;
@ -886,14 +896,14 @@
:do { :do {
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) 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 \ / tool fetch check-certificate=yes-without-crl output=none http-method=post \
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \ ("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
http-data=("chat_id=" . $ChatId . "&disable_notification=" . $Silent . \ http-data=("chat_id=" . $ChatId . "&disable_notification=" . $Silent . \
"&disable_web_page_preview=true&parse_mode=" . $ParseMode . "&text=" . $Text); "&disable_web_page_preview=true&parse_mode=" . $ParseMode . "&text=" . $Text);
} on-error={ } on-error={
$LogPrintExit info ("Failed sending telegram notification! Queuing...") false; $LogPrintExit2 info $0 ("Failed sending telegram notification! Queuing...") false;
:if ([ :typeof $TelegramQueue ] = "nothing") do={ :if ([ :typeof $TelegramQueue ] = "nothing") do={
:set TelegramQueue [ :toarray "" ]; :set TelegramQueue [ :toarray "" ];
@ -950,7 +960,7 @@
# check if system time is sync # check if system time is sync
:set TimeIsSync do={ :set TimeIsSync do={
:global LogPrintExit; :global LogPrintExit2;
:if ([ / system ntp client get enabled ] = true) do={ :if ([ / system ntp client get enabled ] = true) do={
:do { :do {
@ -972,7 +982,7 @@
:return false; :return false;
} }
$LogPrintExit debug ("No time source configured! Returning gracefully...") false; $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
:return true; :return true;
} }
@ -1081,7 +1091,7 @@
# wait for time to become synced # wait for time to become synced
:set WaitTimeSync do={ :set WaitTimeSync do={
:global LogPrintExit; :global LogPrintExit2;
:global TimeIsSync; :global TimeIsSync;
:while ([ $TimeIsSync ] = false) do={ :while ([ $TimeIsSync ] = false) do={
@ -1090,7 +1100,7 @@
:do { :do {
/ system script run rotate-ntp; / system script run rotate-ntp;
} on-error={ } on-error={
$LogPrintExit debug ("Running rotate-ntp failed.") false; $LogPrintExit2 debug $0 ("Running rotate-ntp failed.") false;
} }
} }
:delay 1s; :delay 1s;

View file

@ -6,6 +6,6 @@
:delay 500ms; :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;

View file

@ -6,13 +6,14 @@
# track gps data by sending json data to http server # track gps data by sending json data to http server
# https://git.eworm.de/cgit/routeros-scripts/about/doc/gps-track.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/gps-track.md
:local 0 "gps-track";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global GpsTrackUrl; :global GpsTrackUrl;
:global Identity; :global Identity;
:global LogPrintExit; :global LogPrintExit2;
:local CoordinateFormat [ / system gps get coordinate-format ]; :local CoordinateFormat [ / system gps get coordinate-format ];
:local Gps [ / system gps monitor once as-value ]; :local Gps [ / system gps monitor once as-value ];
@ -25,9 +26,9 @@
"\"lon\":\"" . ($Gps->"longitude") . "\"," . \ "\"lon\":\"" . ($Gps->"longitude") . "\"," . \
"\"identity\":\"" . $Identity . "\"" . \ "\"identity\":\"" . $Identity . "\"" . \
"}"); "}");
$LogPrintExit debug ("Sending GPS data in " . $CoordinateFormat . " format: " . \ $LogPrintExit2 debug $0 ("Sending GPS data in " . $CoordinateFormat . " format: " . \
"lat: " . ($Gps->"latitude") . " " . \ "lat: " . ($Gps->"latitude") . " " . \
"lon: " . ($Gps->"longitude")) false; "lon: " . ($Gps->"longitude")) false;
} else={ } else={
$LogPrintExit debug ("GPS data not valid.") false; $LogPrintExit2 debug $0 ("GPS data not valid.") false;
} }

View file

@ -6,10 +6,11 @@
# add private WPA passphrase after hotspot login # add private WPA passphrase after hotspot login
# https://git.eworm.de/cgit/routeros-scripts/about/doc/hotspot-to-wpa.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/hotspot-to-wpa.md
:local 0 "hotspot-to-wpa";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:local MacAddress $"mac-address"; :local MacAddress $"mac-address";
:local UserName $username; :local UserName $username;
@ -18,11 +19,11 @@
:if ([ :len [ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ] ] = 0) do={ :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; / 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); :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; " (user " . $UserName . ").") false;
/ caps-man access-list remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ]; / caps-man access-list remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];

View file

@ -6,16 +6,17 @@
# update firewall and dns settings on IPv6 prefix change # update firewall and dns settings on IPv6 prefix change
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ipv6-update.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/ipv6-update.md
:local 0 "ipv6-update";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local PdPrefix $"pd-prefix"; :local PdPrefix $"pd-prefix";
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:if ([ :typeof $PdPrefix ] = "nothing") do={ :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 ]; :local Pool [ / ipv6 pool get [ find where prefix=$PdPrefix ] name ];

View file

@ -6,16 +6,17 @@
# run scripts on DHCP lease # run scripts on DHCP lease
# https://git.eworm.de/cgit/routeros-scripts/about/doc/lease-script.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/lease-script.md
:local 0 "lease-script";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:if ([ :typeof $leaseActIP ] = "nothing" || \ :if ([ :typeof $leaseActIP ] = "nothing" || \
[ :typeof $leaseActMAC ] = "nothing" || \ [ :typeof $leaseActMAC ] = "nothing" || \
[ :typeof $leaseServerName ] = "nothing" || \ [ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={ [ :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; :local Scripts;

View file

@ -6,6 +6,7 @@
# forward log messages via notification # forward log messages via notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/log-forward.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/log-forward.md
:local 0 "log-forward";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -16,7 +17,7 @@
:global LogForwardRateLimit; :global LogForwardRateLimit;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -30,7 +31,7 @@ $ScriptLock "log-forward";
:if ($LogForwardRateLimit > 30) do={ :if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1); :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; $WaitFullyConnected;

View file

@ -6,23 +6,24 @@
# act on multiple mode and reset button presses # act on multiple mode and reset button presses
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
:local 0 "mode-button";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global ModeButton; :global ModeButton;
:global LogPrintExit; :global LogPrintExit2;
:set ($ModeButton->"count") ($ModeButton->"count" + 1); :set ($ModeButton->"count") ($ModeButton->"count" + 1);
:local Scheduler [ / system scheduler find where name="ModeButtonScheduler" ]; :local Scheduler [ / system scheduler find where name="ModeButtonScheduler" ];
:if ([ :len $Scheduler ] = 0) do={ :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 ModeButtonScheduler do={
:global ModeButton; :global ModeButton;
:global LogPrintExit; :global LogPrintExit2;
:global ModeButtonScheduler; :global ModeButtonScheduler;
:local LEDInvert do={ :local LEDInvert do={
@ -45,7 +46,7 @@
/ system scheduler remove ModeButtonScheduler; / system scheduler remove ModeButtonScheduler;
:if ([ :len $Code ] > 0) do={ :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={ :for I from=1 to=$Count do={
$LEDInvert; $LEDInvert;
@ -59,12 +60,12 @@
[ :parse $Code ]; [ :parse $Code ];
} else={ } 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" \ / system scheduler add name="ModeButtonScheduler" \
on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s; on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s;
} else={ } else={
$LogPrintExit debug ("Updating scheduler ModeButtonScheduler...") false; $LogPrintExit2 debug $0 ("Updating scheduler ModeButtonScheduler...") false;
/ system scheduler set $Scheduler start-time=[ /system clock get time ]; / system scheduler set $Scheduler start-time=[ /system clock get time ];
} }

View file

@ -1,6 +1,6 @@
#!rsc by RouterOS #!rsc by RouterOS
# RouterOS script: mode-button-event # 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;

View file

@ -1,6 +1,6 @@
#!rsc by RouterOS #!rsc by RouterOS
# RouterOS script: mode-button-scheduler # 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;

View file

@ -6,13 +6,14 @@
# monitor netwatch and send notifications # monitor netwatch and send notifications
# https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-notify.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-notify.md
:local 0 "netwatch-notify";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NetwatchNotify; :global NetwatchNotify;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -32,7 +33,7 @@
} }
:if ($HostVal->"status" = "up") do={ :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"); :local Count ($Metric->"count");
:set ($Metric->"count") 0; :set ($Metric->"count") 0;
:if ($Metric->"notified" = true) do={ :if ($Metric->"notified" = true) do={
@ -40,7 +41,7 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \ ("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
"It was down for " . $Count . " checks since " . ($Metric->"since") . "."); "It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={ :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") ]; [ :parse ($HostInfo->"up-hook") ];
} }
} }
@ -65,7 +66,7 @@
:set Parent ($NetwatchNotify->$Parent->"parent"); :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->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \ ($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
("parent host " . $Parent . " is down.") ]) false; ("parent host " . $Parent . " is down.") ]) false;
@ -74,7 +75,7 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . "."); ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
:set ($Metric->"notified") true; :set ($Metric->"notified") true;
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ :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") ]; [ :parse ($HostInfo->"down-hook") ];
} }
} }

View file

@ -6,10 +6,11 @@
# visualize ospf instance state via leds # visualize ospf instance state via leds
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ospf-to-leds.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/ospf-to-leds.md
:local 0 "ospf-to-leds";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:foreach Instance in=[ / routing ospf instance find where comment~"^ospf-to-leds," ] do={ :foreach Instance in=[ / routing ospf instance find where comment~"^ospf-to-leds," ] do={
@ -17,7 +18,7 @@
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds"); :local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
:local LEDType [ / system leds get [ find where leds=$LED ] type ]; :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={ :if ($InstanceVal->"state" = "running" && $LEDType = "off") do={
/ system leds set type=on [ find where leds=$LED ]; / system leds set type=on [ find where leds=$LED ];
} }

View file

@ -6,11 +6,12 @@
# download packages and reboot for installation # download packages and reboot for installation
# https://git.eworm.de/cgit/routeros-scripts/about/doc/packages-update.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/packages-update.md
:local 0 "packages-update";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DownloadPackage; :global DownloadPackage;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptFromTerminal; :global ScriptFromTerminal;
:global ScriptLock; :global ScriptLock;
:global VersionToNum; :global VersionToNum;
@ -20,11 +21,11 @@ $ScriptLock "packages-update";
:local Update [ / system package update get ]; :local Update [ / system package update get ];
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={ :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={ :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") ]; :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@ -40,39 +41,39 @@ $ScriptLock "packages-update";
:put "Canceled..."; :put "Canceled...";
} }
} else={ } 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={ :foreach Package in=[ / system package find where !bundle ] do={
:local PkgName [ / system package get $Package name ]; :local PkgName [ / system package get $Package name ];
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={ 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={ :foreach Script in=[ / system script find where name~"^(cloud|email|upload)-backup\$" ] do={
:local ScriptName [ / system script get $Script name ]; :local ScriptName [ / system script get $Script name ];
:do { :do {
$LogPrintExit info ("Running backup script " . $ScriptName . " before update.") false; $LogPrintExit2 info $0 ("Running backup script " . $ScriptName . " before update.") false;
/ system script run $Script; / system script run $Script;
} on-error={ } 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={ :if ([ $ScriptFromTerminal "packages-update" ] = true) do={
:put "Do you want to continue anyway? [y/N]"; :put "Do you want to continue anyway? [y/N]";
:if (([ :terminal inkey timeout=60 ] % 32) = 25) do={ :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={ } else={
$LogPrintExit info ("Canceled update...") true; $LogPrintExit2 info $0 ("Canceled update...") true;
} }
} else={ } else={
$LogPrintExit info ("Canceled non-interactive update.") true; $LogPrintExit2 info $0 ("Canceled non-interactive update.") true;
} }
} }
} }
:if ($DoDowngrade = true) do={ :if ($DoDowngrade = true) do={
$LogPrintExit info ("Rebooting for downgrade.") false; $LogPrintExit2 info $0 ("Rebooting for downgrade.") false;
:delay 1s; :delay 1s;
/ system package downgrade; / system package downgrade;
} }
@ -83,10 +84,10 @@ $ScriptLock "packages-update";
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \ / system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \ on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
"/ system scheduler remove reboot-for-update; / system reboot;"); "/ 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; :delay 1s;
/ system reboot; / system reboot;

View file

@ -6,15 +6,16 @@
# run scripts on ppp up # run scripts on ppp up
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ppp-on-up.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/ppp-on-up.md
:local 0 "ppp-on-up";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit; :global LogPrintExit2;
:local Interface $interface; :local Interface $interface;
:if ([ :typeof $Interface ] = "nothing") do={ :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 ]; :local IntName [ / interface get $Interface name ];

View file

@ -6,26 +6,27 @@
# rotate the ntp servers # rotate the ntp servers
# https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md
:local 0 "rotate-ntp";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NtpPool; :global NtpPool;
:global LogPrintExit; :global LogPrintExit2;
:local Ntp1; :local Ntp1;
:local Ntp2; :local Ntp2;
:if ([ / system ntp client get enabled ] != true) do={ :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 { :do {
:set Ntp1 [ :resolve ("0." . $NtpPool) ]; :set Ntp1 [ :resolve ("0." . $NtpPool) ];
:set Ntp2 [ :resolve ("1." . $NtpPool) ]; :set Ntp2 [ :resolve ("1." . $NtpPool) ];
} on-error={ } 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; / system ntp client set primary-ntp=$Ntp1 secondary-ntp=$Ntp2;

View file

@ -1,6 +1,6 @@
#!rsc by RouterOS #!rsc by RouterOS
# RouterOS script: script-updates # 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;

View file

@ -6,17 +6,18 @@
# run action on received SMS # run action on received SMS
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-action.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-action.md
:local 0 "sms-action";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global SmsAction; :global SmsAction;
:global LogPrintExit; :global LogPrintExit2;
:local Action $action; :local Action $action;
:if ([ :typeof $Action ] = "nothing") do={ :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); :local Code ($SmsAction->$Action);

View file

@ -6,13 +6,14 @@
# forward SMS to e-mail # forward SMS to e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-forward.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-forward.md
:local 0 "sms-forward";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity; :global Identity;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
@ -21,7 +22,7 @@
$ScriptLock "sms-forward"; $ScriptLock "sms-forward";
:if ([ / tool sms get receive-enabled ] = false) do={ :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; $WaitFullyConnected;
@ -39,7 +40,7 @@ $WaitFullyConnected;
:if ($Phone = $Settings->"allowed-number" && \ :if ($Phone = $Settings->"allowed-number" && \
($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={ ($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; / tool sms inbox remove $Sms;
} else={ } else={
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \ :set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \

View file

@ -7,10 +7,11 @@
# ipsec remote peer # ipsec remote peer
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-gre-address.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/update-gre-address.md
:local 0 "update-gre-address";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :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 ]; / 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" && \ :if ([ :typeof ($PeerVal->"dynamic-address") ] = "str" && \
($PeerVal->"dynamic-address" != $GreIntVal->"remote-address" || \ ($PeerVal->"dynamic-address" != $GreIntVal->"remote-address" || \
$GreIntVal->"disabled" = true)) do={ $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 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; / interface gre set $GreInt remote-address=($PeerVal->"dynamic-address") disabled=no;
} }

View file

@ -7,15 +7,16 @@
# update local address of tunnelbroker interface # update local address of tunnelbroker interface
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-tunnelbroker.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/update-tunnelbroker.md
:local 0 "update-tunnelbroker";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertificateAvailable; :global CertificateAvailable;
:global LogPrintExit; :global LogPrintExit2;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:if ([ / ip cloud get ddns-enabled ] != true) do={ :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 # Get the current ip address from cloud
@ -32,14 +33,14 @@
:local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ]; :local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ];
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={ :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 \ / tool fetch check-certificate=yes-without-crl \
("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \ ("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \
user=($Comment->"user") password=($Comment->"pass") output=none; user=($Comment->"user") password=($Comment->"pass") output=none;
/ interface 6to4 set $Interface local-address=$PublicAddress; / interface 6to4 set $Interface local-address=$PublicAddress;
} else={ } 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;
} }
} }

View file

@ -6,6 +6,7 @@
# create and upload backup and config file # create and upload backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/upload-backup.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/upload-backup.md
:local 0 "upload-backup";
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
@ -21,7 +22,7 @@
:global CharacterReplace; :global CharacterReplace;
:global DeviceInfo; :global DeviceInfo;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit; :global LogPrintExit2;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
:global WaitForFile; :global WaitForFile;
@ -31,7 +32,7 @@ $WaitFullyConnected;
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $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 # filename based on identity
@ -50,7 +51,7 @@ $WaitFullyConnected;
user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".backup"); user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".backup");
:set BackupFile ($FileName . ".backup"); :set BackupFile ($FileName . ".backup");
} on-error={ } on-error={
$LogPrintExit error ("Uploading backup file failed!") false; $LogPrintExit2 error $0 ("Uploading backup file failed!") false;
:set BackupFile "failed"; :set BackupFile "failed";
:set Failed 1; :set Failed 1;
} }
@ -66,7 +67,7 @@ $WaitFullyConnected;
user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".rsc"); user=$BackupUploadUser password=$BackupUploadPass src-path=($FileName . ".rsc");
:set ConfigFile ($FileName . ".rsc"); :set ConfigFile ($FileName . ".rsc");
} on-error={ } on-error={
$LogPrintExit error ("Uploading configuration export failed!") false; $LogPrintExit2 error $0 ("Uploading configuration export failed!") false;
:set ConfigFile "failed"; :set ConfigFile "failed";
:set Failed 1; :set Failed 1;
} }