aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.d/13-remove-script.avifbin0 -> 1093 bytes
-rw-r--r--README.md13
-rw-r--r--doc/ip-addr-bridge.md2
-rw-r--r--doc/mod/bridge-port-to.md2
-rw-r--r--doc/mod/notification-matrix.md10
-rw-r--r--doc/mod/notification-telegram.md10
-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-functions160
-rw-r--r--log-forward28
-rw-r--r--mod/bridge-port-to14
-rw-r--r--mod/bridge-port-vlan17
-rw-r--r--mod/notification-matrix8
-rw-r--r--mod/notification-telegram8
-rw-r--r--netwatch-notify4
-rw-r--r--rotate-ntp32
18 files changed, 189 insertions, 175 deletions
diff --git a/README.d/13-remove-script.avif b/README.d/13-remove-script.avif
new file mode 100644
index 0000000..a5c7daf
--- /dev/null
+++ b/README.d/13-remove-script.avif
Binary files differ
diff --git a/README.md b/README.md
index df3cb9e..b4d0bdf 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)
@@ -241,6 +240,18 @@ without modification.
Starting a script's name with `mod/` makes it a module and it is run
automatically by `global-functions`.
+Removing a script
+-----------------
+
+There is no specific function for script removal. Just remove it from
+configuration...
+
+ /system/script/remove to-be-removed;
+
+![screenshot: remove script](README.d/13-remove-script.avif)
+
+Possibly a scheduler and other configuration has to be removed as well.
+
Contact
-------
diff --git a/doc/ip-addr-bridge.md b/doc/ip-addr-bridge.md
index 75685bb..f0b593e 100644
--- a/doc/ip-addr-bridge.md
+++ b/doc/ip-addr-bridge.md
@@ -21,7 +21,7 @@ Just install the script:
/system/scheduler/add name=ip-addr-bridge on-event="/system/script/run ip-addr-bridge;" start-time=startup;
-This will disable IP addresses on bridges without at lease one running port.
+This will disable IP addresses on bridges without at least one running port.
The IP address is enabled if at least one port is running.
Note that IP addresses on bridges without a single port (acting as loopback
diff --git a/doc/mod/bridge-port-to.md b/doc/mod/bridge-port-to.md
index 2b42a9b..f86b21d 100644
--- a/doc/mod/bridge-port-to.md
+++ b/doc/mod/bridge-port-to.md
@@ -35,7 +35,7 @@ Also dhcp client can be handled:
Add a scheduler to start with default setup on system startup:
$ScriptInstallUpdate global-wait;
- /system/scheduler/add name=bridge-port-vlan on-event="/system/script/run global-wait; :global BridgePortTo; \$BridgePortTo default;" start-time=startup;
+ /system/scheduler/add name=bridge-port-to on-event="/system/script/run global-wait; :global BridgePortTo; \$BridgePortTo default;" start-time=startup;
Usage and invocation
--------------------
diff --git a/doc/mod/notification-matrix.md b/doc/mod/notification-matrix.md
index 3da5659..c5003e0 100644
--- a/doc/mod/notification-matrix.md
+++ b/doc/mod/notification-matrix.md
@@ -90,6 +90,16 @@ Usage and invocation
There's nothing special to do. Every script or function sending a notification
will now send it to your Matrix account.
+But of course you can send notifications directly or use a function in your
+own scripts. Give it a try:
+
+ $SendMatrix "Subject..." "Body..."
+
+Alternatively this sends a notification with all available and configured
+methods:
+
+ $SendNotification "Subject..." "Body..."
+
See also
--------
diff --git a/doc/mod/notification-telegram.md b/doc/mod/notification-telegram.md
index 435694e..3bb31a7 100644
--- a/doc/mod/notification-telegram.md
+++ b/doc/mod/notification-telegram.md
@@ -53,6 +53,16 @@ Usage and invocation
There's nothing special to do. Every script or function sending a notification
will now send it to your Telegram account.
+But of course you can send notifications directly or use a function in your
+own scripts. Give it a try:
+
+ $SendTelegram "Subject..." "Body..."
+
+Alternatively this sends a notification with all available and configured
+methods:
+
+ $SendNotification "Subject..." "Body..."
+
See also
--------
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 d5df364..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 79;
+: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..3a2497e 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;
@@ -22,9 +22,7 @@
:global CertificateNameByCN;
:global CharacterReplace;
:global CleanFilePath;
-:global DefaultRouteIsReachable;
:global DeviceInfo;
-:global DNSIsResolving;
:global DownloadPackage;
:global EitherOr;
:global EscapeForRegEx;
@@ -34,6 +32,10 @@
:global GetRandomNumber;
:global HexToNum;
:global IfThenElse;
+:global IsDefaultRouteReachable;
+:global IsDNSResolving;
+:global IsFullyConnected;
+:global IsTimeSync;
:global LogPrintExit2;
:global MkDir;
:global NotificationFunctions;
@@ -51,7 +53,6 @@
:global SendNotification2;
:global SymbolByUnicodeName;
:global SymbolForNotification;
-:global TimeIsSync;
:global UrlEncode;
:global ValidateSyntax;
:global VersionToNum;
@@ -183,14 +184,6 @@
:return $Path;
}
-# default route is reachable
-:set DefaultRouteIsReachable do={
- :if ([ :len [ /ip/route/find where dst-address=0.0.0.0/0 active routing-table=main ] ] > 0) do={
- :return true;
- }
- :return false;
-}
-
# get readable device info
:set DeviceInfo do={
:global ExpectedConfigVersion;
@@ -233,18 +226,6 @@
("\n Expected: " . $ExpectedConfigVersion) ]);
}
-# check if DNS is resolving
-:set DNSIsResolving do={
- :global CharacterReplace;
-
- :do {
- :resolve "low-ttl.eworm.de";
- } on-error={
- :return false;
- }
- :return true;
-}
-
# download package from upgrade server
:set DownloadPackage do={
:local PkgName [ :tostr $1 ];
@@ -343,13 +324,13 @@
:global EmailQueue;
:global EitherOr;
+ :global IsTimeSync;
:global LogPrintExit2;
- :global TimeIsSync;
:local AllDone true;
:local QueueLen [ :len $EmailQueue ];
- :if ([ $TimeIsSync ] = false) do={
+ :if ([ $IsTimeSync ] = false) do={
$LogPrintExit2 debug $0 ("Time is not synced, not flushing.") false;
:return false;
}
@@ -462,6 +443,72 @@
:return $3;
}
+# check if default route is reachable
+:set IsDefaultRouteReachable do={
+ :if ([ :len [ /ip/route/find where dst-address=0.0.0.0/0 active routing-table=main ] ] > 0) do={
+ :return true;
+ }
+ :return false;
+}
+
+# check if DNS is resolving
+:set IsDNSResolving do={
+ :global CharacterReplace;
+
+ :do {
+ :resolve "low-ttl.eworm.de";
+ } on-error={
+ :return false;
+ }
+ :return true;
+}
+
+# check if system is is fully connected (default route reachable, DNS resolving, time sync)
+:set IsFullyConnected do={
+ :global IsDefaultRouteReachable;
+ :global IsDNSResolving;
+ :global IsTimeSync;
+
+ :if ([ $IsDefaultRouteReachable ] = false) do={
+ :return false;
+ }
+ :if ([ $IsDNSResolving ] = false) do={
+ :return false;
+ }
+ :if ([ $IsTimeSync ] = false) do={
+ :return false;
+ }
+ :return true;
+}
+
+# check if system time is sync
+:set IsTimeSync do={
+ :global LogPrintExit2;
+
+ :if ([ /system/ntp/client/get enabled ] = true) do={
+ :do {
+ :if ([ /system/ntp/client/get status ] = "synchronized") do={
+ :return true;
+ }
+ } on-error={
+ :if ([ :typeof [ /system/ntp/client/get last-adjustment ] ] = "time") do={
+ :return true;
+ }
+ }
+ :return false;
+ }
+
+ :if ([ /ip/cloud/get ddns-enabled ] = true && [ /ip/cloud/get update-time ] = true) do={
+ :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
+ :return true;
+ }
+ :return false;
+ }
+
+ $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
+ :return true;
+}
+
# log and print with same text, optionally exit
:set LogPrintExit2 do={
:local Severity [ :tostr $1 ];
@@ -761,7 +808,13 @@
:set SourceNew ($Result->"data");
}
} on-error={
- $LogPrintExit2 warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!") false;
+ :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={
+ $LogPrintExit2 warning $0 ("Failed fetching script '" . $ScriptVal->"name" . \
+ "', removing dummy. Typo on installation?") false;
+ /system/script/remove $Script;
+ } else={
+ $LogPrintExit2 warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!") false;
+ }
}
}
}
@@ -1031,7 +1084,7 @@
:return true;
}
-# send notification via e-mail - expects at lease two string arguments
+# send notification via e-mail - expects at least two string arguments
:set SendEMail do={
:global SendEMail2;
@@ -1047,7 +1100,7 @@
($NotificationFunctions->"email") ("\$NotificationFunctions->\"email\"") $Notification;
}
-# send notification via NotificationFunctions - expects at lease two string arguments
+# send notification via NotificationFunctions - expects at least two string arguments
:set SendNotification do={
:global SendNotification2;
@@ -1110,34 +1163,6 @@
:return ($Return . " ");
}
-# check if system time is sync
-:set TimeIsSync do={
- :global LogPrintExit2;
-
- :if ([ /system/ntp/client/get enabled ] = true) do={
- :do {
- :if ([ /system/ntp/client/get status ] = "synchronized") do={
- :return true;
- }
- } on-error={
- :if ([ :typeof [ /system/ntp/client/get last-adjustment ] ] = "time") do={
- :return true;
- }
- }
- :return false;
- }
-
- :if ([ /ip/cloud/get ddns-enabled ] = true && [ /ip/cloud/get update-time ] = true) do={
- :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
- :return true;
- }
- :return false;
- }
-
- $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
- :return true;
-}
-
# url encoding
:set UrlEncode do={
:local Input [ :tostr $1 ];
@@ -1208,18 +1233,18 @@
# wait for default route to be reachable
:set WaitDefaultRouteReachable do={
- :global DefaultRouteIsReachable;
+ :global IsDefaultRouteReachable;
- :while ([ $DefaultRouteIsReachable ] = false) do={
+ :while ([ $IsDefaultRouteReachable ] = false) do={
:delay 1s;
}
}
# wait for DNS to resolve
:set WaitDNSResolving do={
- :global DNSIsResolving;
+ :global IsDNSResolving;
- :while ([ $DNSIsResolving ] = false) do={
+ :while ([ $IsDNSResolving ] = false) do={
:delay 1s;
}
}
@@ -1256,18 +1281,9 @@
# wait for time to become synced
:set WaitTimeSync do={
- :global LogPrintExit2;
- :global TimeIsSync;
+ :global IsTimeSync;
- :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;
- }
- }
+ :while ([ $IsTimeSync ] = false) do={
:delay 1s;
}
}
diff --git a/log-forward b/log-forward
index 3867519..63c7ea7 100644
--- a/log-forward
+++ b/log-forward
@@ -26,6 +26,7 @@
:global QuotedPrintable;
:global ScriptLock;
:global SendNotification2;
+:global SymbolByUnicodeName;
:global SymbolForNotification;
$ScriptLock $0;
@@ -43,12 +44,15 @@ $ScriptLock $0;
:local Duplicates false;
:local Last [ $IfThenElse ([ :len $LogForwardLast ] > 0) [ $HexToNum $LogForwardLast ] -1 ];
:local Messages "";
+:local Warning false;
:local MessageVal;
:local MessageDups [ :toarray "" ];
-:local LogForwardFilterLogForwarding ("^" . [ $EscapeForRegEx ("Error sending e-mail <" . \
- [ $QuotedPrintable ("[" . $Identity . "] " . [ $SymbolForNotification "memo" ] . \
- "Log Forwarding") ] . ">:") ]);
+:local LogForwardFilterLogForwarding ("^Error sending e-mail <(" . \
+ [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
+ [ $SymbolForNotification "memo" ] . "Log Forwarding") ] ] . "|" . \
+ [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
+ [ $SymbolForNotification "warning-sign" ] . "Log Forwarding") ] ] . ")>:");
:foreach Message in=[ /log/find where (!(message="") and !(message~$LogForwardFilterLogForwarding) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
@@ -56,6 +60,9 @@ $ScriptLock $0;
:if ($Last < [ $HexToNum ($MessageVal->".id") ]) do={
:local DupCount ($MessageDups->($MessageVal->"message"));
+ :if ($MessageVal->"topics" ~ "(emergency|alert|critical|error|warning)") do={
+ :set Warning true;
+ }
:if ($DupCount < 3) do={
:set Messages ($Messages . "\n" . [ $IfThenElse ($NotificationsWithSymbols = true) (" \E2\97\8F ") ] . \
$MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message");
@@ -68,14 +75,17 @@ $ScriptLock $0;
}
:if ($Count > 0) do={
+ :set LogForwardRateLimit ($LogForwardRateLimit + 10);
+
$SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "memo" ] . "Log Forwarding"); \
- message=("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) \
- "this message" ("these " . $Count . " messages") ] . " after " . \
- [ /system/resource/get uptime ] . " uptime." . [ $IfThenElse ($Duplicates = true) \
- (" Multi-repeated messages have been skipped.") ] . "\n" . $Messages) });
+ subject=([ $SymbolForNotification [ $IfThenElse ($Warning = true) "warning-sign" "memo" ] ] . \
+ "Log Forwarding"); \
+ message=("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) "this message" \
+ ("these " . $Count . " messages") ] . " after " . [ /system/resource/get uptime ] . " uptime." . \
+ [ $IfThenElse ($Duplicates = true) (" Multi-repeated messages have been skipped.") ] . \
+ [ $IfThenElse ($LogForwardRateLimit > 30) ("\nRate limit in action, delaying forwarding.") ] . \
+ "\n" . $Messages) });
- :set LogForwardRateLimit ($LogForwardRateLimit + 10);
:set LogForwardLast ($MessageVal->".id");
} else={
:if ($LogForwardRateLimit > 0) do={
diff --git a/mod/bridge-port-to b/mod/bridge-port-to
index 36b827b..ae74824 100644
--- a/mod/bridge-port-to
+++ b/mod/bridge-port-to
@@ -15,6 +15,7 @@
:global LogPrintExit2;
:global ParseKeyValueStore;
+ :local InterfaceReEnable [ :toarray "" ];
:foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={
:local BridgePortVal [ /interface/bridge/port/get $BridgePort ];
:foreach Config,BridgeDefault in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={
@@ -42,10 +43,12 @@
/ip/dhcp-client/disable $DHCPClient;
:delay 200ms;
}
- /interface/ethernet/disable [ find where name=$BridgePortVal->"interface" ];
+ :local Disable [ /interface/ethernet/find where name=$BridgePortVal->"interface" ];
+ :if ([ :len $Disable ] > 0) do={
+ /interface/ethernet/disable $Disable;
+ :set InterfaceReEnable ($InterfaceReEnable, $Disable);
+ }
/interface/bridge/port/set disabled=no bridge=$BridgeDefault $BridgePort;
- :delay 500ms;
- /interface/ethernet/enable [ find where name=$BridgePortVal->"interface" ];
} else={
$LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
" bridge " . $BridgeDefault . ".") false;
@@ -54,4 +57,9 @@
}
}
}
+ :if ([ :len $InterfaceReEnable ] > 0) do={
+ :delay 2s;
+ $LogPrintExit2 info $0 ("Re-enabling interfaces...") false;
+ /interface/ethernet/enable $InterfaceReEnable;
+ }
}
diff --git a/mod/bridge-port-vlan b/mod/bridge-port-vlan
index b880c82..a43d7d7 100644
--- a/mod/bridge-port-vlan
+++ b/mod/bridge-port-vlan
@@ -15,6 +15,7 @@
:global LogPrintExit2;
:global ParseKeyValueStore;
+ :local InterfaceReEnable [ :toarray "" ];
:foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={
:local BridgePortVal [ /interface/bridge/port/get $BridgePort ];
:foreach Config,Vlan in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={
@@ -35,6 +36,7 @@
/ip/dhcp-client/enable $DHCPClient;
}
} else={
+ :local VlanName $Vlan;
:if ($Vlan != [ :tostr [ :tonum $Vlan ] ]) do={
:do {
:set $Vlan ([ /interface/bridge/vlan/get [ find where comment=$Vlan ] vlan-ids ]->0);
@@ -44,15 +46,17 @@
}
:if ($BridgePortVal->"disabled" = true || $Vlan != $BridgePortVal->"pvid") do={
$LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $ConfigTo . \
- " vlan " . $Vlan . ", disabling dhcp client.") false;
+ " vlan " . $Vlan . [ $IfThenElse ($Vlan != $VlanName) (" (" . $VlanName . ")") ] . ", disabling dhcp client.") false;
:if ([ :len $DHCPClient ] = 1) do={
/ip/dhcp-client/disable $DHCPClient;
:delay 200ms;
}
- /interface/ethernet/disable [ find where name=$BridgePortVal->"interface" ];
+ :local Disable [ /interface/ethernet/find where name=$BridgePortVal->"interface" ];
+ :if ([ :len $Disable ] > 0) do={
+ /interface/ethernet/disable $Disable;
+ :set InterfaceReEnable ($InterfaceReEnable, $Disable);
+ }
/interface/bridge/port/set disabled=no pvid=$Vlan $BridgePort;
- :delay 500ms;
- /interface/ethernet/enable [ find where name=$BridgePortVal->"interface" ];
} else={
$LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \
" vlan " . $Vlan . ".") false;
@@ -61,4 +65,9 @@
}
}
}
+ :if ([ :len $InterfaceReEnable ] > 0) do={
+ :delay 2s;
+ $LogPrintExit2 info $0 ("Re-enabling interfaces...") false;
+ /interface/ethernet/enable $InterfaceReEnable;
+ }
}
diff --git a/mod/notification-matrix b/mod/notification-matrix
index c3cf24f..f905839 100644
--- a/mod/notification-matrix
+++ b/mod/notification-matrix
@@ -13,8 +13,14 @@
:set FlushMatrixQueue do={
:global MatrixQueue;
+ :global IsFullyConnected;
:global LogPrintExit2;
+ :if ([ $IsFullyConnected ] = false) do={
+ $LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
+ :return false;
+ }
+
:local AllDone true;
:local QueueLen [ :len $MatrixQueue ];
@@ -140,7 +146,7 @@
}
}
-# send notification via Matrix - expects at lease two string arguments
+# send notification via Matrix - expects at least two string arguments
:set SendMatrix do={
:global SendMatrix2;
diff --git a/mod/notification-telegram b/mod/notification-telegram
index 230dd57..493aa00 100644
--- a/mod/notification-telegram
+++ b/mod/notification-telegram
@@ -12,8 +12,14 @@
:set FlushTelegramQueue do={
:global TelegramQueue;
+ :global IsFullyConnected;
:global LogPrintExit2;
+ :if ([ $IsFullyConnected ] = false) do={
+ $LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
+ :return false;
+ }
+
:local AllDone true;
:local QueueLen [ :len $TelegramQueue ];
@@ -147,7 +153,7 @@
}
}
-# send notification via telegram - expects at lease two string arguments
+# send notification via telegram - expects at least two string arguments
:set SendTelegram do={
:global SendTelegram2;
diff --git a/netwatch-notify b/netwatch-notify
index 47b7fa1..45b0c76 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -12,8 +12,8 @@
:global NetwatchNotify;
-:global DNSIsResolving;
:global IfThenElse;
+:global IsDNSResolving;
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
@@ -67,7 +67,7 @@ $ScriptLock $0;
}
:if ([ :typeof ($HostInfo->"resolve") ] = "str") do={
- :if ([ $DNSIsResolving ] = true) do={
+ :if ([ $IsDNSResolving ] = true) do={
:do {
:local Resolve [ :resolve ($HostInfo->"resolve") ];
:if ($Resolve != $HostVal->"host") do={
diff --git a/rotate-ntp b/rotate-ntp
index 2a095f8..9374129 100644
--- a/rotate-ntp
+++ b/rotate-ntp
@@ -1,32 +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 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) ];
-} on-error={
- $LogPrintExit2 warning $0 ("Resolving NTP server failed.") true;
-}
-
-$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
-/system/ntp/client/set servers=($Ntp1, $Ntp2);
+# dummy for removal