From 68dfe26198d2b433977f65460f8f2c2d347d305a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 17 Jul 2026 09:24:47 +0200 Subject: [PATCH] mode-button: drop all global variables With RouterOS 7.24 (actually 7.24beta1 I think) the mode, reset and wps button scripts are run with limited policy. This causes global variables not being available... So let's drop them here. This is kind of inconvenient, but we can live with it. The second script 'mode-button-scheduler' is run from scheduler and does not suffer that limitation. --- mode-button.rsc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index 6210ac97..364fa33f 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -10,26 +10,21 @@ # 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 LogPrint; - :local Scheduler [ /system/scheduler/find where name="mode-button-scheduler" ]; :if ([ :len $Scheduler ] = 0) do={ - $LogPrint info $ScriptName ("Creating scheduler mode-button-scheduler, counting presses..."); + :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;"; } else={ - $LogPrint debug $ScriptName ("Updating scheduler mode-button-scheduler..."); + :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 }) ]; } } do={ - :global ExitOnError; $ExitOnError [ :jobname ] $Err; + :log error ([ :jobname ] . ": " . $Err); }