From d03b6d9374b4f4884bfd90bfc04b1d26802d6666 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 2 Sep 2021 08:59:09 +0200 Subject: global-functions: bump the required version for RouterOS 7.x ... but keep a warning when running RouterOS v6. --- global-functions | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/global-functions b/global-functions index 625bbe4..388d24e 100644 --- a/global-functions +++ b/global-functions @@ -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 -- cgit v1.2.3-54-g00ecf From cdd607037eba0571dd137e9efa507353d88a81c8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 14 Dec 2021 16:44:01 +0100 Subject: README: drop hint on branch 'routeros-v7' --- README.md | 21 +++------------------ global-config | 5 +---- 2 files changed, 4 insertions(+), 22 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/global-config b/global-config index 024e52f..02d99b4 100644 --- a/global-config +++ b/global-config @@ -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: -- cgit v1.2.3-54-g00ecf From 35d10f80f503a92ef7d7004ecac196267ee3946e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 1 Sep 2021 20:38:14 +0200 Subject: backup-email: export with show-sensitive This is available (and required) with RouterOS 7.1rc1. --- backup-email | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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")); -- cgit v1.2.3-54-g00ecf From 768afd84c6f0644f899db450691a050e01c2a272 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 1 Sep 2021 20:40:07 +0200 Subject: backup-upload: export with show-sensitive This is available (and required) with RouterOS 7.1rc1. --- backup-upload | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { -- cgit v1.2.3-54-g00ecf From 7e5652e0c5f45f6c606a60be5eabd57df785d50d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Sep 2021 15:12:46 +0200 Subject: ospf-to-leds: get state from count of neighbors The state property is gone in RouterOS v7... --- ospf-to-leds | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 ]; } } -- cgit v1.2.3-54-g00ecf From 0ecabfecf7739d368849190e47af1ab1c51a79f0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 30 Sep 2021 12:10:57 +0200 Subject: rotate-ntp: syntax for ROS 7.x The property name changed in RouterOS v7... --- rotate-ntp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v1.2.3-54-g00ecf From 93770d40a8c51dd3128ebc1a6b1edcdf0ceb7be6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 16 Nov 2021 13:49:14 +0100 Subject: check-health: adopt new data structure for ROS 7.x The PSU state has an empty string for type... Thus matching on name. --- check-health | 88 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 39 deletions(-) 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; -- cgit v1.2.3-54-g00ecf From 25704812b21a9e24bff83f5406c94b2b54684be3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 13 Dec 2021 21:00:11 +0100 Subject: doc/capsman-download-packages: only bundle is available now --- doc/capsman-download-packages.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 -- cgit v1.2.3-54-g00ecf From 5135a413329ed401ae62ef6b4d05fe09fc0df2f7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 14 Jan 2022 08:35:47 +0100 Subject: global: notify about merging 'routeros-v7' into 'main' --- global-config | 2 +- global-config-overlay | 2 +- global-config.changes | 8 +++++++- global-functions | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/global-config b/global-config index 02d99b4..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"; 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 # 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 388d24e..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; -- cgit v1.2.3-54-g00ecf