Skip to content

Commit

Permalink
Merge pull request #44 from conlan0/develop
Browse files Browse the repository at this point in the history
Add agent shutdown command
  • Loading branch information
wh1te909 authored Feb 22, 2024
2 parents a29709c + d3eb6e0 commit 67abc85
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agent/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,22 @@ func (a *Agent) RunRPC() {
msg.Respond(resp)
}()

case "shutdown":
go func() {
a.Logger.Debugln("Scheduling immediate shutdown")
var resp []byte
ret := codec.NewEncoderBytes(&resp, new(codec.MsgpackHandle))
ret.Encode("ok")
msg.Respond(resp)
if runtime.GOOS == "windows" {
CMD("shutdown.exe", []string{"/s", "/t", "5", "/f"}, 15, false)
} else {
opts := a.NewCMDOpts()
opts.Command = "shutdown -h now"
a.CmdV2(opts)
}
}()

case "rebootnow":
go func() {
a.Logger.Debugln("Scheduling immediate reboot")
Expand Down

0 comments on commit 67abc85

Please sign in to comment.