aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-06-14 21:17:01 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-06-15 16:39:49 +0200
commitb3de1fad3459aa886b3ca3e1f1f91066ab0730b6 (patch)
treeae2eca55b833d01b2d82c526f833a73f9b439578
parent66b7fccd303137d68cf571e79a0ffd7ca82f4b6a (diff)
drop script 'rotate-ntp'change-81
For RouterOS 6.x a separate package 'ntp' exists. This adds server functionality, but allows ip addresses for the client only. I added the script 'rotate-ntp' to update addresses from names... Now with RouterOS 7.x there's no extra package and the limitation does no longer exist. So let's just drop the script. This adds migration code, that... * removes the script from configuration * removes a scheduler from configuration * sets the configured ntp pool name for ntp client
-rw-r--r--README.md1
-rw-r--r--doc/rotate-ntp.md46
-rw-r--r--global-config6
-rw-r--r--global-config-overlay2
-rw-r--r--global-config.changes2
-rw-r--r--global-functions10
-rw-r--r--rotate-ntp39
7 files changed, 9 insertions, 97 deletions
diff --git a/README.md b/README.md
index df3cb9e..6eb035f 100644
--- a/README.md
+++ b/README.md
@@ -194,7 +194,6 @@ Available scripts
* [Visualize OSPF state via LEDs](doc/ospf-to-leds.md)
* [Manage system update](doc/packages-update.md)
* [Run scripts on ppp connection](doc/ppp-on-up.md)
-* [Rotate NTP servers](doc/rotate-ntp.md)
* [Act on received SMS](doc/sms-action.md)
* [Forward received SMS](doc/sms-forward.md)
* [Import SSH keys](doc/ssh-keys-import.md)
diff --git a/doc/rotate-ntp.md b/doc/rotate-ntp.md
index f548eba..9a016a3 100644
--- a/doc/rotate-ntp.md
+++ b/doc/rotate-ntp.md
@@ -1,43 +1,3 @@
-Rotate NTP servers
-==================
-
-[◀ Go back to main README](../README.md)
-
-> ℹ️ **Info**: This script can not be used on its own but requires the base
-> installation. See [main README](../README.md) for details.
-
-Description
------------
-
-RouterOS requires NTP servers to be configured by IP address. Servers from a
-pool may appear and disappear, leaving broken NTP configuration.
-
-This script allows to rotate IP addresses from a given pool.
-
-Requirements and installation
------------------------------
-
-Just install the script:
-
- $ScriptInstallUpdate rotate-ntp;
-
-Configuration
--------------
-
-The configuration goes to `global-config-overlay`, this is the parameter:
-
-* `NtpPool`: dns name of ntp server pool
-
-Usage and invocation
---------------------
-
-Just run the script to update the NTP configuration with actual IP
-addresses from pool if required.
-
-Alternatively a scheduler can be created:
-
- /system/scheduler/add interval=5d name=rotate-ntp on-event="/system/script/run rotate-ntp;" start-time=startup;
-
----
-[◀ Go back to main README](../README.md)
-[▲ Go back to top](#top)
+This script has been dropped as the limitation does no longer exist with
+RouterOS 7.x, where you can enable a ntp server and use a name for the client
+at the same time.
diff --git a/global-config b/global-config
index 70d8a2f..b1f4770 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 80;
+:global GlobalConfigVersion 81;
# This is used for DNS and backup file.
:global Domain "example.com";
@@ -146,10 +146,6 @@
# add more here...
};
-# This address should resolve ntp servers and is used to update
-# ntp settings. A pool can rotate servers.
-:global NtpPool "pool.ntp.org";
-
# This is the address used to send gps data to.
:global GpsTrackUrl "https://example.com/index.php";
diff --git a/global-config-overlay b/global-config-overlay
index 48daf8e..eaa43f6 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 80;
+:global GlobalConfigVersion 81;
# Copy configuration from global-config here and modify it.
diff --git a/global-config.changes b/global-config.changes
index e317b02..04f88e7 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -89,6 +89,7 @@
78="New documentation is online for notifications via Telegram & Matrix, variable inspection, ip address calculation and running scripts once.";
79="Introduced new script 'backup-partition' to save configuration to fallback partition.";
80="The 'routeros-v7' branch will now freeze, and vanish any time in future. You already switched to 'main' branch, well done!";
+ 81="Dropped script 'rotate-ntp', as the limitation does no longer exist.";
};
# Migration steps to be applied on script updates
@@ -101,4 +102,5 @@
66=":global ScriptInstallUpdate; :if ([ :len [ /system/script/find where name=\"bridge-port-to-default\" ] ] > 0) do={ /system/script/remove [ find where name~\"^bridge-port-to(-default|ggle)\\\$\" ]; \$ScriptInstallUpdate mod/bridge-port-to; }";
67=":global ScriptInstallUpdate; :global CharacterReplace; :foreach Script in=[ /system/script/find where name~\"^global-functions.d/\" ] do={ /system/script/set name=[ \$CharacterReplace [ /system/script/get \$Script name ] \"global-functions.d/\" \"mod/\" ] \$Script; }; \$ScriptInstallUpdate;";
73=":global ScriptInstallUpdate; :global CharacterReplace; :foreach Old,New in={ \"cloud-backup\"=\"backup-cloud\"; \"email-backup\"=\"backup-email\"; \"upload-backup\"=\"backup-upload\" } do={ /system/script/set name=\$New [ find where name=\$Old ]; :foreach Scheduler in=[ /system/scheduler/find where on-event~\$Old ] do={ /system/scheduler/set \$Scheduler name=[ \$CharacterReplace [ get \$Scheduler name ] \$Old \$New ] on-event=[ \$CharacterReplace [ get \$Scheduler on-event ] \$Old \$New ]; }; }; \$ScriptInstallUpdate;";
+ 81=":global NtpPool; :if ([ :len [ /system/script/find where name=\"rotate-ntp\" ] ] > 0) do={ /system/script/remove [ find where name=\"rotate-ntp\" ]; /system/scheduler/remove [ find where name=\"rotate-ntp\" ]; /system/ntp/client/set servers=\$NtpPool; };";
};
diff --git a/global-functions b/global-functions
index 7266861..c12bd54 100644
--- a/global-functions
+++ b/global-functions
@@ -10,7 +10,7 @@
:local 0 "global-functions";
# expected configuration version
-:global ExpectedConfigVersion 80;
+:global ExpectedConfigVersion 81;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
@@ -1260,14 +1260,6 @@
:global TimeIsSync;
:while ([ $TimeIsSync ] = false) do={
- :if ([ :len [ /system/script/find where name="rotate-ntp" ] ] > 0 && \
- ([ /system/resource/get uptime ] % (180 * 1000000000)) = 0s) do={
- :do {
- /system/script/run rotate-ntp;
- } on-error={
- $LogPrintExit2 debug $0 ("Running rotate-ntp failed.") false;
- }
- }
:delay 1s;
}
}
diff --git a/rotate-ntp b/rotate-ntp
index 4446cba..9374129 100644
--- a/rotate-ntp
+++ b/rotate-ntp
@@ -1,39 +1,2 @@
#!rsc by RouterOS
-# RouterOS script: rotate-ntp
-# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
-#
-# rotate the ntp servers
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md
-
-:local 0 "rotate-ntp";
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:global NtpPool;
-:global RotateNtpResolveFailed;
-
-:global LogPrintExit2;
-
-:local Ntp1;
-:local Ntp2;
-
-:if ([ /system/ntp/client/get enabled ] != true) do={
- $LogPrintExit2 warning $0 ("NTP client is not enabled!") true;
-}
-
-:do {
- :set Ntp1 [ :resolve ("0." . $NtpPool) ];
- :set Ntp2 [ :resolve ("1." . $NtpPool) ];
- :set RotateNtpResolveFailed false;
-} on-error={
- :if ($RotateNtpResolveFailed != true) do={
- :set RotateNtpResolveFailed true;
- $LogPrintExit2 warning $0 ("Resolving NTP server failed.") true;
- } else={
- $LogPrintExit2 debug $0 ("Resolving NTP server failed, again.") true;
- }
-}
-
-$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
-/system/ntp/client/set servers=($Ntp1, $Ntp2);
+# dummy for removal