mirror of https://bitbucket.org/ausocean/av.git
rv: added Off variable to shutdown pi if true.
This commit is contained in:
parent
1acfdf059e
commit
395d5a21f1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue