rv: added Off variable to shutdown pi if true.

This commit is contained in:
Trek H 2022-03-24 09:57:04 +10:30
parent 1acfdf059e
commit 395d5a21f1
1 changed files with 9 additions and 0 deletions

View File

@ -59,6 +59,7 @@ import (
"os"
"runtime/pprof"
"strconv"
"syscall"
"time"
"gopkg.in/natefinch/lumberjack.v2"
@ -212,6 +213,14 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
}
l.Log(logger.Debug, "got new vars", "vars", vars)
// Shutdown pi if variable 'Off' is found and set to true.
if v, ok := vars["Off"]; ok && v == "true" {
err = syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
if err != nil {
l.Log(logger.Error, "could not power off", "error", err)
}
}
// Configure revid based on the vars.
l.Log(logger.Debug, "updating revid's configuration")
err = rv.Update(vars)