aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-09-10 22:15:54 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-09-10 22:15:54 +0200
commit172d789f2a4f350555665173f53f6cd5122cd1a7 (patch)
treefe7cd5f64346631c9f2bbc3e9ffd40c646b8faa1
parent8f4986af0bb0ecea13594b9ea2bbcfbaa6c8a7e7 (diff)
add scripts mode-button-{event,scheduler}
-rw-r--r--global-config8
-rw-r--r--mode-button-event14
-rw-r--r--mode-button-scheduler16
3 files changed, 38 insertions, 0 deletions
diff --git a/global-config b/global-config
index ae7f73a..e42139b 100644
--- a/global-config
+++ b/global-config
@@ -39,6 +39,14 @@
# pseudo-random PSK.
:global "daily-psk-match-comment" "Daily PSK";
+# Run different commands with multiple mode-button presses.
+:global "mode-button" {
+ 1="/ system script run leds-toggle-mode;";
+ 2="/ system shutdown";
+ 3="/ system reboot";
+# add mode here...
+};
+
# This address should resolve ntp servers and is used to update
# ntp settings. A pool can rotate servers.
:global "ntp-pool" "pool.ntp.org";
diff --git a/mode-button-event b/mode-button-event
new file mode 100644
index 0000000..2306e1e
--- /dev/null
+++ b/mode-button-event
@@ -0,0 +1,14 @@
+#
+# RouterOS script: mode-button-event
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# run on mode-button event and count button presses
+
+:global "mode-button";
+
+:set ($"mode-button"->"count") ($"mode-button"->"count" + 1);
+
+:if ([ :len [ / system scheduler find where name="mode-button-scheduler" ] ] = 0) do={
+ :log info "Creating mode-button scheduler...";
+ / system scheduler add name=mode-button-scheduler on-event=mode-button-scheduler interval=5s;
+}
diff --git a/mode-button-scheduler b/mode-button-scheduler
new file mode 100644
index 0000000..bf85826
--- /dev/null
+++ b/mode-button-scheduler
@@ -0,0 +1,16 @@
+#
+# RouterOS script: mode-button-scheduler
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# act on multiple mode-botton presses from scheduler
+
+:global "mode-button";
+
+:local count ($"mode-button"->"count");
+:local action [ :parse ($"mode-button"->[ :tostr $count ]) ];
+
+:set ($"mode-button"->"count") 0;
+/ system scheduler remove mode-button-scheduler;
+
+:log info ("Acting on " . $count . " mode-button presses.");
+$action;