Compare commits

..

70 commits

Author SHA1 Message Date
Christian Hesse
ce64529c45 netwatch-dns: check with a HTTP/2 request
We need RouterOS 7.24 for this to catch runtime errors for bad
command parameters.

Actually this would work with RouterOS 7.23 on architectures that
support http-version=http2 ...
2026-07-16 13:41:04 +02:00
Christian Hesse
bbb251ade5 Merge branch 'dhcp-to-dns' into next 2026-07-16 13:41:04 +02:00
Christian Hesse
5e3070e36b bump required RouterOS version for all scripts 2026-07-16 13:41:04 +02:00
Christian Hesse
c26c63c390 dhcp-to-dns: allow to ignore for specific lease 2026-07-16 13:41:04 +02:00
Christian Hesse
1abfc59b73 global-functions: $NetMask6: use shift operator...
... and drop the workaround. This requires RouterOS 7.22beta3.
2026-07-16 13:41:04 +02:00
Christian Hesse
d0821113cc update list of contributors 2026-07-16 13:41:04 +02:00
Christian Hesse
d90d8297c9 Merge branch 'break-in-loop' into next 2026-07-16 13:41:04 +02:00
Łukasz Witkowski
0e53aa7f4c dhcp-to-dns: allow to specify domain for CNAMEs...
... in network or lease.

Co-authored-by: Christian Hesse <mail@eworm.de>
2026-07-16 13:41:04 +02:00
Christian Hesse
1a1b936957 Merge branch 'continue-in-loop' into next 2026-07-16 13:41:04 +02:00
Christian Hesse
1a870c3092 telegram-chat: fix indention 2026-07-16 13:41:04 +02:00
Łukasz Witkowski
1245260299 dhcp-to-dns: set $LeaseInfo
Co-authored-by: Christian Hesse <mail@eworm.de>
2026-07-16 13:41:04 +02:00
Christian Hesse
9423d7f1ef Merge branch 'early-exit-with-exit' into next 2026-07-16 13:41:04 +02:00
Christian Hesse
608045ce31 dhcp-to-dns: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
723cacec9f telegram-chat: use :break in loop 2026-07-16 13:41:04 +02:00
Łukasz Witkowski
37387f5770 dhcp-to-dns: convert DNS names to lower case
Co-authored-by: Christian Hesse <mail@eworm.de>
2026-07-16 13:41:04 +02:00
Christian Hesse
a68259e863 Merge branch 'compare-ids' into next 2026-07-16 13:41:04 +02:00
Christian Hesse
41c2d163a3 global-functions: deprecate $ExitError 2026-07-16 13:41:04 +02:00
Christian Hesse
faa2465bcc dhcp-to-dns: use another :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
17a4fd7766 check-certificates: use :break in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
5470d97a0d dhcp-to-dns: support to ignore networks
Closes: https://github.com/eworm-de/routeros-scripts/issues/119
2026-07-16 13:41:04 +02:00
Christian Hesse
2176187257 global-functions: deprecate $HexToNum 2026-07-16 13:41:04 +02:00
Christian Hesse
6eddaccba9 update-tunnelbroker: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
dff4fb4a8c dhcp-to-dns: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
069de4c948 log-forward: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
0c9c92eb5b update-gre-address: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
3eb20152bb telegram-chat: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
c1eda113b5 log-forward: use comparison for ids
This was introduced with RouterOS 7.22beta1.

Initializing $LogForwardLast with boolean value looks odd, but this is
required to match the very first message.
2026-07-16 13:41:04 +02:00
Christian Hesse
4613405037 telegram-chat: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
9715f95ef5 netwatch-dns: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
c8a66955d3 sms-forward: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
9533f21be0 netwatch-dns: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
7a992f0557 sms-action: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
3bf40ec73f netwatch-dns: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
1116585bee ppp-on-up: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
1826d2fc5b netwatch-dns: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
df65f7263d packages-update: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
31e64f6e96 global-functions: $ScriptInstallUpdate: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
f825f484fe ospf-to-leds: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
68a48e00bd global-functions: $ScriptInstallUpdate: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
15e4c93784 netwatch-notify: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
25608feb0e global-functions: $CleanName: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
e38af4881d netwatch-dns: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
847c985cf4 fw-addr-lists: fix indention 2026-07-16 13:41:04 +02:00
Christian Hesse
fbf346fdd0 log-forward: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
c096306e59 fw-addr-lists: use :continue in loop 2026-07-16 13:41:04 +02:00
Christian Hesse
04eb34d8cc ipv6-update: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
b2674a4e79 ipsec-to-dns: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
eaedb2d5b9 hotspot-to-wpa-cleanup: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
d27d7e0ecc hotspot-to-wpa: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
415c3bc164 gps-track: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
3e9ec8fa31 fw-addr-lists: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
382057afc3 firmware-upgrade-reboot: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
d2f906d9f8 dhcpv6-client-lease: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
0f61c22477 dhcpv4-server-lease: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
8d1a2f2834 dhcp-to-dns: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
307afc9a31 dhcp-lease-comment: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
ff6fc0a7fc daily-psk: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
49c86440ed collect-wireless-mac: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
356661c535 check-routeros-update: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
6f78415c8a check-perpetual-license: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
c2204d55f6 check-lte-firmware-upgrade: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
46cb8e870e check-health: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
0b06740dca check-certificates: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
2f134a2738 certificate-renew-issued: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
8c07b9f252 capsman-rolling-upgrade: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
0bd7175e78 capsman-download-packages: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
558b02c8bb backup-upload: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
3894b5c7d9 backup-partition: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
f252914622 backup-email: early exit with :exit 2026-07-16 13:41:04 +02:00
Christian Hesse
4bc63b575d backup-cloud: early exit with :exit 2026-07-16 13:41:04 +02:00
5 changed files with 79 additions and 96 deletions

View file

@ -16,7 +16,7 @@ Mode button with multiple presses
Description
-----------
These scripts extend the functionality of mode button. Instead of just one
This script extend the functionality of mode button. Instead of just one
you can trigger several actions by pressing the mode button several times.
The hardware needs to have a mode button, see
@ -39,9 +39,9 @@ Copy this code to terminal to check:
Requirements and installation
-----------------------------
Just install the scripts:
Just install the script:
$ScriptInstallUpdate mode-button,mode-button-scheduler;
$ScriptInstallUpdate mode-button;
Then configure the mode button to run `mode-button`:

View file

@ -15,7 +15,7 @@
# Git commit id & info, expected configuration version
:global CommitId "unknown";
:global CommitInfo "unknown";
:global ExpectedConfigVersion 144;
:global ExpectedConfigVersion 143;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View file

@ -1,80 +0,0 @@
#!rsc by RouterOS
# RouterOS script: mode-button-scheduler
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.22
# requires device-mode, scheduler
#
# act on multiple mode and reset button presses
# https://rsc.eworm.de/doc/mode-button.md
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global ModeButton;
:global LogPrint;
:global ModeButtonScheduler;
:global ValidateSyntax;
:local LEDInvert do={
:global ModeButtonLED;
:global IfThenElse;
:local LED [ /system/leds/find where leds=$ModeButtonLED \
!disabled type~"^(on|off)\$" interface=[] ];
:if ([ :len $LED ] = 0) do={
:return false;
}
/system/leds/set type=[ $IfThenElse ([ get $LED type ] = "on") "off" "on" ] $LED;
}
:local Scheduler [ /system/scheduler/find where name="mode-button-scheduler" ];
:if ([ :len $Scheduler ] = 0) do={
$LogPrint error $ScriptName ("Scheduler does not exist.");
:exit;
}
:local Count ([ :deserialize from=json [ /system/scheduler/get $Scheduler comment ] ]->"count");
:local Code ($ModeButton->[ :tostr $Count ]);
/system/scheduler/remove $Scheduler;
:if ([ :len $Code ] = 0) do={
$LogPrint info $ScriptName ("No action defined for " . $Count . " mode-button presses.");
:exit;
}
:if ([ $ValidateSyntax $Code ] = false) do={
$LogPrint warning $ScriptName \
("The code for " . $Count . " mode-button presses failed syntax validation!");
:exit;
}
$LogPrint info $ScriptName ("Acting on " . $Count . " mode-button presses: " . $Code);
:for I from=1 to=$Count do={
$LEDInvert;
:if ([ /system/routerboard/settings/get silent-boot ] = false) do={
:beep length=200ms;
}
:delay 200ms;
$LEDInvert;
:delay 200ms;
}
:onerror Err {
[ :parse $Code ];
} do={
$LogPrint warning $ScriptName \
("The code for " . $Count . " mode-button presses failed with runtime error: " . $Err);
}
} do={
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}

View file

@ -10,21 +10,86 @@
# https://rsc.eworm.de/doc/mode-button.md
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:local Scheduler [ /system/scheduler/find where name="mode-button-scheduler" ];
:global ModeButton;
:global LogPrint;
:set ($ModeButton->"count") ($ModeButton->"count" + 1);
:local Scheduler [ /system/scheduler/find where name="_ModeButtonScheduler" ];
:if ([ :len $Scheduler ] = 0) do={
:log info ($ScriptName . ": Creating scheduler mode-button-scheduler, counting presses...");
/system/scheduler/add name="mode-button-scheduler" interval=3s \
comment=[ :serialize to=json ({ count=1 }) ] \
on-event="/system/script/run mode-button-scheduler;";
$LogPrint info $ScriptName ("Creating scheduler _ModeButtonScheduler, counting presses...");
:global ModeButtonScheduler do={ :onerror Err {
:local FuncName $0;
:global ModeButton;
:global LogPrint;
:global ModeButtonScheduler;
:global ValidateSyntax;
:local LEDInvert do={
:global ModeButtonLED;
:global IfThenElse;
:local LED [ /system/leds/find where leds=$ModeButtonLED \
!disabled type~"^(on|off)\$" interface=[] ];
:if ([ :len $LED ] = 0) do={
:return false;
}
/system/leds/set type=[ $IfThenElse ([ get $LED type ] = "on") "off" "on" ] $LED;
}
:local Count ($ModeButton->"count");
:local Code ($ModeButton->[ :tostr $Count ]);
:set ($ModeButton->"count") 0;
:set ModeButtonScheduler;
/system/scheduler/remove [ find where name="_ModeButtonScheduler" ];
:if ([ :len $Code ] > 0) do={
:if ([ $ValidateSyntax $Code ] = true) do={
$LogPrint info $FuncName ("Acting on " . $Count . " mode-button presses: " . $Code);
:for I from=1 to=$Count do={
$LEDInvert;
:if ([ /system/routerboard/settings/get silent-boot ] = false) do={
:beep length=200ms;
}
:delay 200ms;
$LEDInvert;
:delay 200ms;
}
:onerror Err {
[ :parse $Code ];
} do={
$LogPrint warning $FuncName \
("The code for " . $Count . " mode-button presses failed with runtime error: " . $Err);
}
} else={
$LogPrint warning $FuncName \
("The code for " . $Count . " mode-button presses failed syntax validation!");
}
} else={
$LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses.");
}
} do={
:global ExitOnError; $ExitOnError $0 $Err;
} }
/system/scheduler/add name="_ModeButtonScheduler" \
on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s;
} else={
:log debug ($ScriptName . ": Updating scheduler mode-button-scheduler...");
:local Presses (([ :deserialize from=json [ /system/scheduler/get $Scheduler comment ] ]->"count") + 1);
/system/scheduler/set $Scheduler start-time=[ /system/clock/get time ] \
comment=[ :serialize to=json ({ count=$Presses }) ];
$LogPrint debug $ScriptName ("Updating scheduler _ModeButtonScheduler...");
/system/scheduler/set $Scheduler start-time=[ /system/clock/get time ];
}
} do={
:log error ([ :jobname ] . ": " . $Err);
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}

View file

@ -68,7 +68,6 @@
141="Introduced script 'dhcpv6-client-lease' to run several scripts on IPv6 DHCP client lease.";
142="Added a setting for 'mod/notification-email' to check availability of certificate chain.";
143="Made backup scripts 'backup-email' and 'backup-upload' support date & time in filenames.";
144="Split and reworked 'mode-button' for compatibility with RouterOS 7.24, configuration was updated automatically.";
};
# Migration steps to be applied on script updates
@ -80,5 +79,4 @@
132=":if ([ :len [ /system/script/find where name=\"check-health\" ] ] > 0) do={ :local Code \":local Install \\\"check-health\\\"; :if ([ :len [ /system/health/find where type=\\\"\\\" name~\\\"-state\\\\\\\$\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/state\\\"); }; :if ([ :len [ /system/health/find where type=\\\"C\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/temperature\\\"); }; :if ([ :len [ /system/health/find where type=\\\"V\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/voltage\\\"); }; :global ScriptInstallUpdate; \\\$ScriptInstallUpdate \\\$Install;\"; :global ValidateSyntax; :if ([ \$ValidateSyntax \$Code ] = true) do={ :do { [ :parse \$Code ]; } on-error={ }; }; };";
138="/certificate/set trusted=yes [ find where trusted=yes ];";
140=":if ([ :len [ /system/script/find where name=\"lease-script\" ] ] > 0) do={ /system/script/set name=\"dhcpv4-server-lease\" \"lease-script\"; :global ScriptInstallUpdate; \$ScriptInstallUpdate; /ip/dhcp-server/set lease-script=\"dhcpv4-server-lease\" [ find where lease-script=\"lease-script\" ]; };";
144=":if ([ :len [ /system/script/find where name=\"mode-button\" ] ] > 0) do={ :global ScriptInstallUpdate; \$ScriptInstallUpdate mode-button-scheduler; };";
};