From 106a9bddefd7577b4baf7ae1d78e1bbde09b281e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 09:18:48 +0100 Subject: [PATCH 01/21] README: give hint on device mode --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 98209bd..8594f58 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ Specific scripts may require even newer RouterOS version. > ℹ️ **Info**: The `main` branch is now RouterOS v7 only. If you are still > running RouterOS v6 switch to `routeros-v6` branch! +Starting with RouterOS 7.17 the +[device-mode](https://help.mikrotik.com/docs/spaces/ROS/pages/93749258/Device-mode) +has been extended to give more fine-grained control over what features are +available. You need to enable `scheduler` and `fetch` at least, specific +scripts may require additional features. + ### Hardware RouterOS packages increase in size with each release. This becomes a From b177e298d7b447c41854d840eed6f687b6cec8b6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 09:45:25 +0100 Subject: [PATCH 02/21] global-functions: $ScriptInstallUpdate: support checking for device-mode features --- global-functions.rsc | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index d5ac31c..7d65f45 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -5,6 +5,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch, scheduler # # global functions # https://rsc.eworm.de/ @@ -1071,6 +1072,7 @@ :local ExpectedConfigVersionBefore $ExpectedConfigVersion; :local ReloadGlobalFunctions false; :local ReloadGlobalConfig false; + :local DeviceMode [ /system/device-mode/get ]; :foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={ :local ScriptVal [ /system/script/get $Script ]; @@ -1113,19 +1115,31 @@ :if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={ :local Required ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); :if ([ $RequiredRouterOS $0 [ $EitherOr $Required "0.0" ] false ] = true) do={ - :if ([ $ValidateSyntax $SourceNew ] = true) do={ - $LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); - /system/script/set owner=($ScriptVal->"name") \ - source=[ $IfThenElse ($ScriptUpdatesCRLF = true) $SourceCRLF $SourceNew ] $Script; - :if ($ScriptVal->"name" = "global-config") do={ - :set ReloadGlobalConfig true; + :local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ]; + :local MissingDM ({}); + :foreach Feature,Value in=$RequiredDM do={ + :if ([ :typeof ($DeviceMode->$Feature) ] = "bool" && ($DeviceMode->$Feature) = false) do={ + :set MissingDM ($MissingDM, $Feature); } - :if ($ScriptVal->"name" = "global-functions" || $ScriptVal->"name" ~ ("^mod/.")) do={ - :set ReloadGlobalFunctions true; + } + :if ([ :len $MissingDM ] = 0) do={ + :if ([ $ValidateSyntax $SourceNew ] = true) do={ + $LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); + /system/script/set owner=($ScriptVal->"name") \ + source=[ $IfThenElse ($ScriptUpdatesCRLF = true) $SourceCRLF $SourceNew ] $Script; + :if ($ScriptVal->"name" = "global-config") do={ + :set ReloadGlobalConfig true; + } + :if ($ScriptVal->"name" = "global-functions" || $ScriptVal->"name" ~ ("^mod/.")) do={ + :set ReloadGlobalFunctions true; + } + } else={ + $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \ + "' failed! Ignoring!"); } } else={ - $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \ - "' failed! Ignoring!"); + $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \ + "device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!"); } } else={ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ From aebc4e37da1a8e9ed1b343a83c7d60ac50fab9d5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:26:22 +0100 Subject: [PATCH 03/21] backup-partition: add dependencies on device-mode --- backup-partition.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/backup-partition.rsc b/backup-partition.rsc index b8bf7b1..bfa7765 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -5,6 +5,7 @@ # # provides: backup-script, order=70 # requires RouterOS, version=7.14 +# requires device-mode, scheduler # # save configuration to fallback partition # https://rsc.eworm.de/doc/backup-partition.md From d81a786e8288fea463c7188f1939c59713add31a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:20:26 +0100 Subject: [PATCH 04/21] backup-upload: add dependencies on device-mode --- backup-upload.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/backup-upload.rsc b/backup-upload.rsc index 011c502..dc5120f 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -5,6 +5,7 @@ # # provides: backup-script, order=50 # requires RouterOS, version=7.14 +# requires device-mode, fetch # # create and upload backup and config file # https://rsc.eworm.de/doc/backup-upload.md From 95b675f67ec9d7c5a9df01a54c1754834b02beee Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:21:12 +0100 Subject: [PATCH 05/21] check-certificates: add dependencies on device-mode --- check-certificates.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/check-certificates.rsc b/check-certificates.rsc index 02e3e52..4271e00 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch # # check for certificate validity # https://rsc.eworm.de/doc/check-certificates.md From 43f6c0b975bb4db73131f78014ca3d59123bd4a6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:21:26 +0100 Subject: [PATCH 06/21] check-routeros-update: add dependencies on device-mode --- check-routeros-update.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 9486d6c..5c9b392 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch, scheduler # # check for RouterOS update, send notification and/or install # https://rsc.eworm.de/doc/check-routeros-update.md From bc0227c49b99372ff46516e55175cf6ae1da31d3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:21:40 +0100 Subject: [PATCH 07/21] gps-track: add dependencies on device-mode --- gps-track.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/gps-track.rsc b/gps-track.rsc index 08873de..5e35f8d 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch # # track gps data by sending json data to http server # https://rsc.eworm.de/doc/gps-track.md From e29ef31eb85e9b9001536ed1bb63a0b479cf4cad Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:35:31 +0100 Subject: [PATCH 08/21] hotspot-to-wpa: add dependencies on device-mode --- hotspot-to-wpa.capsman.rsc | 1 + hotspot-to-wpa.template.rsc | 1 + hotspot-to-wpa.wifi.rsc | 1 + 3 files changed, 3 insertions(+) diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index 1c77de9..de9f9d9 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # add private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index d8cd261..003b12e 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # add private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index 345087d..0d6a7b9 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # add private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md From 1ad4d05be8a69490902308baa515b8c87095bb2d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:35:23 +0100 Subject: [PATCH 09/21] hotspot-to-wpa-cleanup: add dependencies on device-mode --- hotspot-to-wpa-cleanup.capsman.rsc | 1 + hotspot-to-wpa-cleanup.template.rsc | 1 + hotspot-to-wpa-cleanup.wifi.rsc | 1 + 3 files changed, 3 insertions(+) diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index fde36f9..c21ec3e 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -5,6 +5,7 @@ # # provides: lease-script, order=80 # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # manage and clean up private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 3ddcbe0..1bd877e 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -5,6 +5,7 @@ # # provides: lease-script, order=80 # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # manage and clean up private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 034530b..8e36204 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -5,6 +5,7 @@ # # provides: lease-script, order=80 # requires RouterOS, version=7.14 +# requires device-mode, hotspot # # manage and clean up private WPA passphrase after hotspot login # https://rsc.eworm.de/doc/hotspot-to-wpa.md From 5f1cbe6de5466ccaaf1b5eb29f7087f04cf342c3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:25:15 +0100 Subject: [PATCH 10/21] ipsec-to-dns: add dependencies on device-mode --- ipsec-to-dns.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index 1af5809..91f6b45 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, ipsec # # and add/remove/update DNS entries from IPSec mode-config # https://rsc.eworm.de/doc/ipsec-to-dns.md From 56e74268b079fba7bda8803c0d88eeb67d0f4397 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:31:30 +0100 Subject: [PATCH 11/21] mode-button: add dependencies on device-mode --- mode-button.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mode-button.rsc b/mode-button.rsc index 9339f1c..4cf5e75 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, scheduler # # act on multiple mode and reset button presses # https://rsc.eworm.de/doc/mode-button.md From 370e81321fe485a94560b4debe2ce7044c99e86f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:15:49 +0100 Subject: [PATCH 12/21] mod/notification-email: add dependencies on device-mode --- mod/notification-email.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index ca23550..404e74d 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, email, scheduler # # send notifications via e-mail # https://rsc.eworm.de/doc/mod/notification-email.md From 9a12934202c1bf8f46b326b37e7b06d84609c4ce Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:21:57 +0100 Subject: [PATCH 13/21] mod/notification-matrix: add dependencies on device-mode --- mod/notification-matrix.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc index aee231d..9b2b641 100644 --- a/mod/notification-matrix.rsc +++ b/mod/notification-matrix.rsc @@ -5,6 +5,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch, scheduler # # send notifications via Matrix # https://rsc.eworm.de/doc/mod/notification-matrix.md From 9f2f54b4790659189c60e72918cc200625c22d25 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:22:08 +0100 Subject: [PATCH 14/21] mod/notification-ntfy: add dependencies on device-mode --- mod/notification-ntfy.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index df252bb..212fde2 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch, scheduler # # send notifications via Ntfy (ntfy.sh) # https://rsc.eworm.de/doc/mod/notification-ntfy.md From 378a8978dfb86f1f690732cc0e513330282bcd98 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:22:22 +0100 Subject: [PATCH 15/21] mod/notification-telegram: add dependencies on device-mode --- mod/notification-telegram.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index a20367c..c3ef2dd 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch, scheduler # # send notifications via Telegram # https://rsc.eworm.de/doc/mod/notification-telegram.md From 59c9d0ce4bf97407a5f35d8556ecc9f4f03ca752 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:22:43 +0100 Subject: [PATCH 16/21] mod/scriptrunonce: add dependencies on device-mode --- mod/scriptrunonce.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc index cae2b05..e5368c4 100644 --- a/mod/scriptrunonce.rsc +++ b/mod/scriptrunonce.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, fetch # # download script and run it once # https://rsc.eworm.de/doc/mod/scriptrunonce.md From 3ef458860153ab858eec70e0899efa91a84236d4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:22:55 +0100 Subject: [PATCH 17/21] netwatch-dns: add dependencies on device-mode --- netwatch-dns.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index e05c3ac..467d636 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.16 +# requires device-mode, fetch # # monitor and manage dns/doh with netwatch # https://rsc.eworm.de/doc/netwatch-dns.md From 8dc1e1ea6bdb815de28823dfa43d1cfeda67379f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:32:17 +0100 Subject: [PATCH 18/21] packages-update: add dependencies on device-mode --- packages-update.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/packages-update.rsc b/packages-update.rsc index 9971e47..ff47b2a 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, scheduler # # download packages and reboot for installation # https://rsc.eworm.de/doc/packages-update.md From ef48b8d39ebacf2bd1c560c6dea33399a9a47b47 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:23:58 +0100 Subject: [PATCH 19/21] telegram-chat: add dependencies on device-mode --- telegram-chat.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index dcdbefa..8f29d8c 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.15 +# requires device-mode, fetch # # use Telegram to chat with your Router and send commands # https://rsc.eworm.de/doc/telegram-chat.md From 9421566352041654e1f2ded815739b040eec1df4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:28:40 +0100 Subject: [PATCH 20/21] unattended-lte-firmware-upgrade: add dependencies on device-mode --- unattended-lte-firmware-upgrade.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/unattended-lte-firmware-upgrade.rsc b/unattended-lte-firmware-upgrade.rsc index c7df92f..74495d1 100644 --- a/unattended-lte-firmware-upgrade.rsc +++ b/unattended-lte-firmware-upgrade.rsc @@ -4,6 +4,7 @@ # https://rsc.eworm.de/COPYING.md # # requires RouterOS, version=7.14 +# requires device-mode, scheduler # # schedule unattended lte firmware upgrade # https://rsc.eworm.de/doc/unattended-lte-firmware-upgrade.md From d921af9a6bda54da74f6b7520db1a8e5697c8c3e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2025 10:23:06 +0100 Subject: [PATCH 21/21] update-tunnelbroker: add dependencies on device-mode --- update-tunnelbroker.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index c47a45f..a58589b 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -6,6 +6,7 @@ # # provides: ppp-on-up # requires RouterOS, version=7.14 +# requires device-mode, fetch # # update local address of tunnelbroker interface # https://rsc.eworm.de/doc/update-tunnelbroker.md