From 268b253389a00cf97001da7c7128cbb1a6ce5db3 Mon Sep 17 00:00:00 2001 From: Alan Noble Date: Fri, 15 Dec 2023 05:12:28 +0000 Subject: [PATCH] Shutdown mode Approved-by: Saxon Milton --- cmd/rv/main.go | 20 +++++++++++++++----- revid/config/variables.go | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) 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) {}, }, {