Merge branch 'device-mode' into next

This commit is contained in:
Christian Hesse 2025-01-29 22:20:51 +01:00
commit 3c8ec5169f
25 changed files with 53 additions and 10 deletions

View file

@ -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 > **Info**: The `main` branch is now RouterOS v7 only. If you are still
> running RouterOS v6 switch to `routeros-v6` branch! > 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 ### Hardware
RouterOS packages increase in size with each release. This becomes a RouterOS packages increase in size with each release. This becomes a

View file

@ -5,6 +5,7 @@
# #
# provides: backup-script, order=70 # provides: backup-script, order=70
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, scheduler
# #
# save configuration to fallback partition # save configuration to fallback partition
# https://rsc.eworm.de/doc/backup-partition.md # https://rsc.eworm.de/doc/backup-partition.md

View file

@ -5,6 +5,7 @@
# #
# provides: backup-script, order=50 # provides: backup-script, order=50
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch
# #
# create and upload backup and config file # create and upload backup and config file
# https://rsc.eworm.de/doc/backup-upload.md # https://rsc.eworm.de/doc/backup-upload.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch
# #
# check for certificate validity # check for certificate validity
# https://rsc.eworm.de/doc/check-certificates.md # https://rsc.eworm.de/doc/check-certificates.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch, scheduler
# #
# check for RouterOS update, send notification and/or install # check for RouterOS update, send notification and/or install
# https://rsc.eworm.de/doc/check-routeros-update.md # https://rsc.eworm.de/doc/check-routeros-update.md

View file

@ -5,6 +5,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch, scheduler
# #
# global functions # global functions
# https://rsc.eworm.de/ # https://rsc.eworm.de/
@ -1071,6 +1072,7 @@
:local ExpectedConfigVersionBefore $ExpectedConfigVersion; :local ExpectedConfigVersionBefore $ExpectedConfigVersion;
:local ReloadGlobalFunctions false; :local ReloadGlobalFunctions false;
:local ReloadGlobalConfig false; :local ReloadGlobalConfig false;
:local DeviceMode [ /system/device-mode/get ];
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={ :foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={
:local ScriptVal [ /system/script/get $Script ]; :local ScriptVal [ /system/script/get $Script ];
@ -1113,6 +1115,14 @@
:if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={ :if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={
:local Required ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); :local Required ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version");
:if ([ $RequiredRouterOS $0 [ $EitherOr $Required "0.0" ] false ] = true) do={ :if ([ $RequiredRouterOS $0 [ $EitherOr $Required "0.0" ] false ] = true) do={
: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 ([ :len $MissingDM ] = 0) do={
:if ([ $ValidateSyntax $SourceNew ] = true) do={ :if ([ $ValidateSyntax $SourceNew ] = true) do={
$LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); $LogPrint info $0 ("Updating script: " . $ScriptVal->"name");
/system/script/set owner=($ScriptVal->"name") \ /system/script/set owner=($ScriptVal->"name") \
@ -1127,6 +1137,10 @@
$LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \ $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \
"' failed! Ignoring!"); "' failed! Ignoring!");
} }
} else={
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \
"device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!");
}
} else={ } else={
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \
$Required . ", which is not met by your installation. Ignoring!"); $Required . ", which is not met by your installation. Ignoring!");

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch
# #
# track gps data by sending json data to http server # track gps data by sending json data to http server
# https://rsc.eworm.de/doc/gps-track.md # https://rsc.eworm.de/doc/gps-track.md

View file

@ -5,6 +5,7 @@
# #
# provides: lease-script, order=80 # provides: lease-script, order=80
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# manage and clean up private WPA passphrase after hotspot login # manage and clean up private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -5,6 +5,7 @@
# #
# provides: lease-script, order=80 # provides: lease-script, order=80
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# manage and clean up private WPA passphrase after hotspot login # manage and clean up private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -5,6 +5,7 @@
# #
# provides: lease-script, order=80 # provides: lease-script, order=80
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# manage and clean up private WPA passphrase after hotspot login # manage and clean up private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# add private WPA passphrase after hotspot login # add private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# add private WPA passphrase after hotspot login # add private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, hotspot
# #
# add private WPA passphrase after hotspot login # add private WPA passphrase after hotspot login
# https://rsc.eworm.de/doc/hotspot-to-wpa.md # https://rsc.eworm.de/doc/hotspot-to-wpa.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, ipsec
# #
# and add/remove/update DNS entries from IPSec mode-config # and add/remove/update DNS entries from IPSec mode-config
# https://rsc.eworm.de/doc/ipsec-to-dns.md # https://rsc.eworm.de/doc/ipsec-to-dns.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, email, scheduler
# #
# send notifications via e-mail # send notifications via e-mail
# https://rsc.eworm.de/doc/mod/notification-email.md # https://rsc.eworm.de/doc/mod/notification-email.md

View file

@ -5,6 +5,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch, scheduler
# #
# send notifications via Matrix # send notifications via Matrix
# https://rsc.eworm.de/doc/mod/notification-matrix.md # https://rsc.eworm.de/doc/mod/notification-matrix.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch, scheduler
# #
# send notifications via Ntfy (ntfy.sh) # send notifications via Ntfy (ntfy.sh)
# https://rsc.eworm.de/doc/mod/notification-ntfy.md # https://rsc.eworm.de/doc/mod/notification-ntfy.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch, scheduler
# #
# send notifications via Telegram # send notifications via Telegram
# https://rsc.eworm.de/doc/mod/notification-telegram.md # https://rsc.eworm.de/doc/mod/notification-telegram.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch
# #
# download script and run it once # download script and run it once
# https://rsc.eworm.de/doc/mod/scriptrunonce.md # https://rsc.eworm.de/doc/mod/scriptrunonce.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, scheduler
# #
# act on multiple mode and reset button presses # act on multiple mode and reset button presses
# https://rsc.eworm.de/doc/mode-button.md # https://rsc.eworm.de/doc/mode-button.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.16 # requires RouterOS, version=7.16
# requires device-mode, fetch
# #
# monitor and manage dns/doh with netwatch # monitor and manage dns/doh with netwatch
# https://rsc.eworm.de/doc/netwatch-dns.md # https://rsc.eworm.de/doc/netwatch-dns.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, scheduler
# #
# download packages and reboot for installation # download packages and reboot for installation
# https://rsc.eworm.de/doc/packages-update.md # https://rsc.eworm.de/doc/packages-update.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.15 # requires RouterOS, version=7.15
# requires device-mode, fetch
# #
# use Telegram to chat with your Router and send commands # use Telegram to chat with your Router and send commands
# https://rsc.eworm.de/doc/telegram-chat.md # https://rsc.eworm.de/doc/telegram-chat.md

View file

@ -4,6 +4,7 @@
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, scheduler
# #
# schedule unattended lte firmware upgrade # schedule unattended lte firmware upgrade
# https://rsc.eworm.de/doc/unattended-lte-firmware-upgrade.md # https://rsc.eworm.de/doc/unattended-lte-firmware-upgrade.md

View file

@ -6,6 +6,7 @@
# #
# provides: ppp-on-up # provides: ppp-on-up
# requires RouterOS, version=7.14 # requires RouterOS, version=7.14
# requires device-mode, fetch
# #
# update local address of tunnelbroker interface # update local address of tunnelbroker interface
# https://rsc.eworm.de/doc/update-tunnelbroker.md # https://rsc.eworm.de/doc/update-tunnelbroker.md