routeros-scripts/mode-button-scheduler
Christian Hesse 71ad56aacc explicitly name the license
Copyright (C) 2013-2020 Christian Hesse <mail@eworm.de>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

https://www.gnu.org/licenses/#GPL
https://www.gnu.org/licenses/gpl.html
https://www.gnu.org/licenses/gpl.md
2020-06-19 22:17:42 +02:00

36 lines
953 B
Plaintext

#!rsc
# RouterOS script: mode-button-scheduler
# Copyright (c) 2018-2020 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
# act on multiple mode-botton presses from scheduler
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
:global ModeButton;
:global LogPrintExit;
:local Count ($ModeButton->"count");
:local Code ($ModeButton->[ :tostr $Count ]);
:set ($ModeButton->"count") 0;
/ system scheduler remove mode-button-scheduler;
:if ([ :len $Code ] > 0) do={
$LogPrintExit info ("Acting on " . $Count . " mode-button presses: " . $Code) false;
:if ([ / system routerboard settings get silent-boot ] = false) do={
:for I from=1 to=$Count do={
:beep length=200ms;
:delay 200ms;
}
} else={
:delay 1s;
}
:local Parsed [ :parse $Code ];
$Parsed;
} else={
$LogPrintExit info ("No action defined for " . $Count . " mode-button presses.") false;
}