aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md21
-rw-r--r--backup-email2
-rw-r--r--backup-upload2
-rw-r--r--check-health88
-rw-r--r--doc/capsman-download-packages.md8
-rw-r--r--global-config7
-rw-r--r--global-config-overlay2
-rw-r--r--global-config.changes8
-rw-r--r--global-functions11
-rw-r--r--ospf-to-leds14
-rw-r--r--rotate-ntp2
11 files changed, 83 insertions, 82 deletions
diff --git a/README.md b/README.md
index 990aef9..02cb009 100644
--- a/README.md
+++ b/README.md
@@ -118,30 +118,15 @@ to be updated automatically!
### Changes for RouterOS v6
-RouterOS v6 will become deprecated at some time in the future, but to date
-it is still the default for these scripts (in branch `main`). This will
-change however, so if you want to stay with RouterOS v6 for some time add
-these lines to your `global-config-overlay`, if missing:
+RouterOS v7 is the way to go, let's consider RouterOS v6 deprecated.
+If you want to stay with RouterOS v6 for some time add these lines
+to your `global-config-overlay`, if missing:
# Use branch routeros-v6 with RouterOS v6:
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
Then reload the configuration.
-### Changes for RouterOS v7
-
-RouterOS v7 is developed in paralled to RouterOS v6. The former brings some
-shiny new features, the latter provides proven stability.
-
-The changes require incompatible changes to scripts, so these changes go to
-a separate branch. If you decide to run RouterOS v7 please switch to branch
-`routeros-v7` by adding these lines to your `global-config-overlay`:
-
- # Use branch routeros-v7 with RouterOS v7:
- :global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
-
-Then reload the configuration and continue below to update scripts.
-
Updating scripts
----------------
diff --git a/backup-email b/backup-email
index bda9215..ccbd4de 100644
--- a/backup-email
+++ b/backup-email
@@ -62,7 +62,7 @@ $WaitFullyConnected;
# create configuration export
:if ($BackupSendExport = true) do={
- / export terse file=$FilePath;
+ / export terse show-sensitive file=$FilePath;
$WaitForFile ($FilePath . ".rsc");
:set ConfigFile ($FileName . ".rsc");
:set Attach ($Attach, ($FilePath . ".rsc"));
diff --git a/backup-upload b/backup-upload
index 6aba3e7..c482b42 100644
--- a/backup-upload
+++ b/backup-upload
@@ -76,7 +76,7 @@ $WaitFullyConnected;
# create configuration export
:if ($BackupSendExport = true) do={
- / export terse file=$FilePath;
+ / export terse show-sensitive file=$FilePath;
$WaitForFile ($FilePath . ".rsc");
:do {
diff --git a/check-health b/check-health
index 28de93e..ca379c4 100644
--- a/check-health
+++ b/check-health
@@ -24,98 +24,108 @@
:global SendNotification2;
:global SymbolForNotification;
-:local FormatVoltage do={
- :local Voltage [ :tonum $1 ];
- :return (($Voltage / 10) . "." . [ :pick $Voltage ([ :len $Voltage ] - 1) ] . "V");
+:local TempToNum do={
+ :global CharacterReplace;
+ :local T [ :toarray [ $CharacterReplace $1 "." "," ] ];
+ :return ($T->0 * 10 + $T->1);
}
-:local CheckHealthCurrent [ / system health get ];
-
-:if ([ :len $CheckHealthCurrent ] = 0) do={
+:if ([ :len [ / system health find ] ] = 0) do={
$LogPrintExit2 error $0 ("Your device does not provide any health values.") true;
}
+:if ([ :typeof $CheckHealthLast ] != "array") do={
+ :set CheckHealthLast [ :toarray "" ];
+}
:if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
:set CheckHealthTemperatureNotified [ :toarray "" ];
}
$ScriptLock $0;
-:foreach Name,Voltage in=$CheckHealthCurrent do={
- :if ($Name ~ "(battery|voltage)" && \
- [ :typeof ($CheckHealthLast->$Name) ] = "num" && \
- [ :typeof $Voltage ] = "num") do={
- :if ($CheckHealthLast->$Name * (100 + $CheckHealthVoltagePercent) < $Voltage * 100 || \
- $CheckHealthLast->$Name * 100 > $Voltage * (100 + $CheckHealthVoltagePercent)) do={
+:foreach Voltage in=[ / system health find where type="V" ] do={
+ :local Name [ / system health get $Voltage name ];
+ :local Value [ / system health get $Voltage value ];
+
+ :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
+ :local NumCurr [ $TempToNum $Value ];
+ :local NumLast [ $TempToNum ($CheckHealthLast->$Name) ];
+
+ :if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
+ $NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
$SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($CheckHealthLast->$Name < \
- $Voltage) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
+ subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
+ $NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
- "old value: " . [ $FormatVoltage ($CheckHealthLast->$Name) ] . "\n" . \
- "new value: " . [ $FormatVoltage $Voltage ]) });
+ "old value: " . ($CheckHealthLast->$Name) . " V\n" . \
+ "new value: " . $Value . " V") });
} else={
- :if ($Voltage <= $CheckHealthVoltageLow && $CheckHealthLast->$Name > $CheckHealthVoltageLow) do={
+ :if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \
- message=("The " . $Name . " on " . $Identity . " dropped to " . [ $FormatVoltage $Voltage ] . " below hard limit.") });
+ message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") });
}
- :if ($Voltage > $CheckHealthVoltageLow && $CheckHealthLast->$Name <= $CheckHealthVoltageLow) do={
+ :if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \
- message=("The " . $Name . " on " . $Identity . " recovered to " . [ $FormatVoltage $Voltage ] . " above hard limit.") });
+ message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") });
}
}
}
+ :set ($CheckHealthLast->$Name) $Value;
}
-:foreach Name,PSU in=$CheckHealthCurrent do={
- :if ($Name ~ "psu.*-state" && \
- [ :typeof ($CheckHealthLast->$Name) ] = "str" && \
- [ :typeof $PSU ] = "str") do={
+:foreach PSU in=[ / system health find where name~"^psu.*-state\$" ] do={
+ :local Name [ / system health get $PSU name ];
+ :local Value [ / system health get $PSU value ];
+
+ :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
:if ($CheckHealthLast->$Name = "ok" && \
- $PSU != "ok") do={
+ $Value != "ok") do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
message=("The power supply unit '" . $Name . "' on " . $Identity . " failed!") });
}
:if ($CheckHealthLast->$Name != "ok" && \
- $PSU = "ok") do={
+ $Value = "ok") do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
message=("The power supply unit '" . $Name . "' on " . $Identity . " recovered!") });
}
}
+ :set ($CheckHealthLast->$Name) $Value;
}
-:foreach Name,Temperature in=$CheckHealthCurrent do={
- :if ($Name ~ "temperature" && \
- [ :typeof $Temperature ] = "num") do={
+:foreach Temperature in=[ / system health find where type="C" ] do={
+ :local Name [ / system health get $Temperature name ];
+ :local Value [ / system health get $Temperature value ];
+
+ :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
:if ([ :typeof ($CheckHealthTemperature->$Name) ] != "num" ) do={
$LogPrintExit2 info $0 ("No threshold given for " . $Name . ", assuming 50C.") false;
:set ($CheckHealthTemperature->$Name) 50;
}
- :local Validate [ / system health get $Name ];
- :while ($Temperature != $Validate) do={
- :set Temperature $Validate;
- :set Validate [ / system health get $Name ];
+ :local Validate [ / system health get [ find where name=$Name ] value ];
+ :while ($Value != $Validate) do={
+ :set Value $Validate;
+ :set Validate [ / system health get [ find where name=$Name ] value ];
}
- :if ($Temperature > $CheckHealthTemperature->$Name && \
+ :if ($Value > $CheckHealthTemperature->$Name && \
$CheckHealthTemperatureNotified->$Name != true) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
- $Temperature . "\C2\B0" . "C") });
+ $Value . "\C2\B0" . "C") });
:set ($CheckHealthTemperatureNotified->$Name) true;
}
- :if ($Temperature <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
+ :if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
$CheckHealthTemperatureNotified->$Name = true) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
message=("The " . $Name . " on " . $Identity . " dropped below threshold: " . \
- $Temperature . "\C2\B0" . "C") });
+ $Value . "\C2\B0" . "C") });
:set ($CheckHealthTemperatureNotified->$Name) false;
}
}
+ :set ($CheckHealthLast->$Name) $Value;
}
-
-:set CheckHealthLast $CheckHealthCurrent;
diff --git a/doc/capsman-download-packages.md b/doc/capsman-download-packages.md
index cdbd72b..a27ca1e 100644
--- a/doc/capsman-download-packages.md
+++ b/doc/capsman-download-packages.md
@@ -32,11 +32,9 @@ place the required packages to CAPsMAN package path (see
function `$DownloadPackage`, use something like this to download latest
packages to directory `routeros`:
- $DownloadPackage system "" arm routeros;
- $DownloadPackage security "" arm routeros;
- [...]
- $DownloadPackage system "" mipsbe routeros;
- $DownloadPackage security "" mipsbe routeros;
+ $DownloadPackage routeros "" arm routeros;
+ $DownloadPackage routeros "" arm64 routeros;
+ $DownloadPackage routeros "" mipsbe routeros;
[...]
Usage and invocation
diff --git a/global-config b/global-config
index 024e52f..454e5bf 100644
--- a/global-config
+++ b/global-config
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
-:global GlobalConfigVersion 74;
+:global GlobalConfigVersion 75;
# This is used for DNS and backup file.
:global Domain "example.com";
@@ -159,14 +159,11 @@
# alternative urls - main: stable code - next: currently in development
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/main/";
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/next/";
-#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/routeros-v7/";
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/main/";
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/next/";
-#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/routeros-v7/";
:global ScriptUpdatesUrlSuffix "";
-# use next or routeros-v7 branch with default url (git.eworm.de)
+# use next branch with default url (git.eworm.de)
#:global ScriptUpdatesUrlSuffix "\?h=next";
-#:global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
# Use this for defaults with $ScriptRunOnce
# Install module with:
diff --git a/global-config-overlay b/global-config-overlay
index 37f78cf..562d7b5 100644
--- a/global-config-overlay
+++ b/global-config-overlay
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
# Comment or remove to disable news and change notifications.
-:global GlobalConfigVersion 74;
+:global GlobalConfigVersion 75;
# Copy configuration from global-config here and modify it.
diff --git a/global-config.changes b/global-config.changes
index a070ecd..d1058e4 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -2,6 +2,9 @@
# Copyright (c) 2019-2022 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+:global IfThenElse;
+:global RequiredRouterOS;
+
# Changes for global-config to be added to notification on script updates
:global GlobalConfigChanges {
1="Moved variables from 'global-config' to 'global-functions' for independence";
@@ -73,11 +76,14 @@
67="Moved modules to directory with shorter name.";
68="Reintroduced 'global-wait' for functions in scheduler.";
69="Support hard lower limit for voltage in 'check-health'.";
- 70="MikroTik started pushing RouterOS v7. Changes are required if you run it, see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7";
+ 70="MikroTik started pushing RouterOS v7. Changes are no longer required.";
71="MikroTik is pushing RouterOS v7 even more, in parallel branches. If you want to keep RouterOS v6 for some time see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6";
72="Introduced new script 'netwatch-dns' to manage DNS and DoH servers from netwatch.";
73="Renamed backup scripts ('cloud-backup' -> 'backup-cloud', 'email-backup' -> 'backup-email', 'upload-backup' -> 'backup-upload').";
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
+ 75=("Finally merged the RouterOS v7 code into the main branch. " . [ $IfThenElse ([ $RequiredRouterOS "global-config.changes" "7.0" false ] = true) \
+ ("You may now drop '\$ScriptUpdatesUrlSuffix' from 'global-config-overlay'.") \
+ ("Still running RouterOS v6, so last reminder to see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6") ]);
};
# Migration steps to be applied on script updates
diff --git a/global-functions b/global-functions
index 625bbe4..1e402d9 100644
--- a/global-functions
+++ b/global-functions
@@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
-:global ExpectedConfigVersion 74;
+:global ExpectedConfigVersion 75;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
@@ -1257,12 +1257,11 @@
}
# check for required RouterOS version
-$RequiredRouterOS "global-functions" "6.47" true;
-
-# ... and give a hint on RouterOS v7.
:if ([ $RequiredRouterOS "global-functions" "7.0" false ] = true) do={
- $LogPrintExit2 warning $0 ("RouterOS v7 brings some incompatible changes. Please switch to branch " . \
- "'routeros-v7', see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7") false;
+ $RequiredRouterOS "global-functions" "7.1" true;
+} else={
+ $LogPrintExit2 warning $0 ("Still running RouterOS v6, please switch to branch " . \
+ "'routeros-v6', see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6") false;
}
# signal we are ready
diff --git a/ospf-to-leds b/ospf-to-leds
index 448cc6b..39501c9 100644
--- a/ospf-to-leds
+++ b/ospf-to-leds
@@ -18,12 +18,18 @@
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
:local LEDType [ / system leds get [ find where leds=$LED ] type ];
- :if ($InstanceVal->"state" = "running" && $LEDType = "off") do={
- $LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " is running, led on!") false;
+ :local NeighborCount 0;
+ :foreach Area in=[ / routing ospf area find where instance=($InstanceVal->"name") ] do={
+ :local AreaName [ / routing ospf area get $Area name ];
+ :set NeighborCount ($NeighborCount + [ :len [ / routing ospf neighbor find where area=$AreaName ] ]);
+ }
+
+ :if ($NeighborCount > 0 && $LEDType = "off") do={
+ $LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " has " . $NeighborCount . " neighbors, led on!") false;
/ system leds set type=on [ find where leds=$LED ];
}
- :if ($InstanceVal->"state" = "down" && $LEDType = "on") do={
- $LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " is down, led off!") false;
+ :if ($NeighborCount = 0 && $LEDType = "on") do={
+ $LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " has no neighbors, led off!") false;
/ system leds set type=off [ find where leds=$LED ];
}
}
diff --git a/rotate-ntp b/rotate-ntp
index 83bf90a..dd3483a 100644
--- a/rotate-ntp
+++ b/rotate-ntp
@@ -29,4 +29,4 @@
}
$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 servers=($Ntp1, $Ntp2);