From 395d5a21f11cb49b469128175aa3b29b9241451c Mon Sep 17 00:00:00 2001 From: Trek H Date: Thu, 24 Mar 2022 09:57:04 +1030 Subject: [PATCH] rv: added Off variable to shutdown pi if true. --- cmd/rv/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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)