mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-07-25 18:51:35 +00:00
mode-button-scheduler: early exit with :exit
This commit is contained in:
parent
a88eea6e64
commit
363adaaa47
3 changed files with 7 additions and 11 deletions
|
|
@ -4,7 +4,7 @@ Mode button with multiple presses
|
||||||
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||||
[](https://mikrotik.com/download/changelogs/)
|
[](https://mikrotik.com/download/changelogs/)
|
||||||
[](https://t.me/routeros_scripts)
|
[](https://t.me/routeros_scripts)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@
|
||||||
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.21
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, scheduler
|
# 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
|
||||||
|
|
||||||
:local ExitOK false;
|
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
||||||
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
||||||
|
|
@ -39,8 +38,7 @@
|
||||||
|
|
||||||
:if ([ :len $Scheduler ] = 0) do={
|
:if ([ :len $Scheduler ] = 0) do={
|
||||||
$LogPrint error $ScriptName ("Scheduler does not exist.");
|
$LogPrint error $ScriptName ("Scheduler does not exist.");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Count ([ :deserialize from=json [ /system/scheduler/get $Scheduler comment ] ]->"count");
|
:local Count ([ :deserialize from=json [ /system/scheduler/get $Scheduler comment ] ]->"count");
|
||||||
|
|
@ -50,15 +48,13 @@
|
||||||
|
|
||||||
:if ([ :len $Code ] = 0) do={
|
:if ([ :len $Code ] = 0) do={
|
||||||
$LogPrint info $ScriptName ("No action defined for " . $Count . " mode-button presses.");
|
$LogPrint info $ScriptName ("No action defined for " . $Count . " mode-button presses.");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ $ValidateSyntax $Code ] = false) do={
|
:if ([ $ValidateSyntax $Code ] = false) do={
|
||||||
$LogPrint warning $ScriptName \
|
$LogPrint warning $ScriptName \
|
||||||
("The code for " . $Count . " mode-button presses failed syntax validation!");
|
("The code for " . $Count . " mode-button presses failed syntax validation!");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$LogPrint info $ScriptName ("Acting on " . $Count . " mode-button presses: " . $Code);
|
$LogPrint info $ScriptName ("Acting on " . $Count . " mode-button presses: " . $Code);
|
||||||
|
|
@ -80,5 +76,5 @@
|
||||||
("The code for " . $Count . " mode-button presses failed with runtime error: " . $Err);
|
("The code for " . $Count . " mode-button presses failed with runtime error: " . $Err);
|
||||||
}
|
}
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.21
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, scheduler
|
# requires device-mode, scheduler
|
||||||
#
|
#
|
||||||
# act on multiple mode and reset button presses
|
# act on multiple mode and reset button presses
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue