Shutdown mode

Approved-by: Saxon Milton
This commit is contained in:
Alan Noble 2023-12-15 05:12:28 +00:00
parent 578e60823b
commit 268b253389
2 changed files with 16 additions and 6 deletions

View File

@ -75,7 +75,7 @@ import (
)
// Current software version.
const version = "v1.4.5"
const version = "v1.5.0"
// Copyright information prefixed to all metadata.
const (
@ -99,6 +99,7 @@ const (
modePaused = "Paused"
modeBurst = "Burst"
modeLoop = "Loop"
modeShutdown = "Shutdown"
)
// Misc constants.
@ -108,6 +109,7 @@ const (
profilePath = "rv.prof"
pkg = "rv: "
runPreDelay = 20 * time.Second
rebootCmd = "syncreboot"
)
// Software define pin values.
@ -269,6 +271,14 @@ func run(rv *revid.Revid, ns *netsender.Sender, l logging.Logger, nl *netlogger.
continue
}
ns.SetMode(modePaused, &vs)
case modeShutdown:
l.Debug("mode is Shutdown, shutting down")
rv.Stop()
ns.SetMode(modePaused, &vs)
out, err := exec.Command(rebootCmd, "-s=true").CombinedOutput()
if err != nil {
l.Warning("could not use syncreboot to shutdown, out: %s, err: %w", string(out), err)
}
}
l.Info("revid updated with new mode")

View File

@ -425,7 +425,7 @@ var Variables = []struct {
},
{
Name: KeyMode,
Type: "enum:Normal,Paused,Burst",
Type: "enum:Normal,Paused,Burst,Shutdown",
Update: func(c *Config, v string) {},
},
{