diff --git a/cmd/rv/main.go b/cmd/rv/main.go index 817a0e18..3a842901 100644 --- a/cmd/rv/main.go +++ b/cmd/rv/main.go @@ -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)