diff --git a/cmd/rv/main.go b/cmd/rv/main.go index 841ed3a0..fcb5b3f6 100644 --- a/cmd/rv/main.go +++ b/cmd/rv/main.go @@ -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 ( @@ -95,10 +95,11 @@ const ( // Revid modes. const ( - modeNormal = "Normal" - modePaused = "Paused" - modeBurst = "Burst" - modeLoop = "Loop" + modeNormal = "Normal" + 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") diff --git a/revid/config/variables.go b/revid/config/variables.go index f77dfce3..b890a02e 100644 --- a/revid/config/variables.go +++ b/revid/config/variables.go @@ -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) {}, }, {