diff options
-rw-r--r-- | global-config | 7 | ||||
-rw-r--r-- | sms-action | 27 |
2 files changed, 13 insertions, 21 deletions
diff --git a/global-config b/global-config index e42139b..5d8617a 100644 --- a/global-config +++ b/global-config @@ -47,6 +47,13 @@ # add mode here... }; +# Run commands on SMS action. +:global "sms-action" { + shutdown="/ system shutdown"; + reboot="/ system reboot"; +# add more 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"; @@ -4,26 +4,11 @@ # # run action on received SMS -:log info ("Received SMS with action '" . $action . "'"); -# delay a second to give log servers a chance to get the info -:delay 1s; - -:if ($action = "reboot") do={ - / system reboot; -} - -:if ($action = "shutdown") do={ - / system shutdown; -} +:global "sms-action"; -:if ($action = "update") do={ - / system package update install; -} +:local code ($"sms-action"->$action); +:local parsed [ :parse $code ]; -:if ($action= "trackon") do={ - / system scheduler enable gps-track; -} - -:if ($action = "trackoff") do={ - / system scheduler disable gps-track; -} +:log info ("Acting on SMS action '" . $action . "': " . $code); +:delay 1s; +$parsed; |