Add the system command with reboot subcommand
This commit is contained in:
1 parent
4a59ea77f7
commit
b04ccae36b
7 files changed
+356
-59
No files matched your search
@@ -0,0 +1,25 @@
|
||||
//go:build linux && amd64
|
||||
|
||||
package portal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"syscall"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/dpogorzelski/speedrun/proto/portal"
|
||||
)
|
||||
|
||||
func (s *Server) SystemReboot(ctx context.Context, file *portal.SystemRebootRequest) (*portal.SystemRebootResponse, error) {
|
||||
fields := log.Fields{
|
||||
"context": "system",
|
||||
"command": "reboot",
|
||||
}
|
||||
log := log.WithFields(fields)
|
||||
log.Debug("Received system reboot request")
|
||||
|
||||
syscall.Sync()
|
||||
go syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
|
||||
|
||||
return &portal.SystemRebootResponse{State: portal.State_CHANGED, Message: "Rebooting"}, nil
|
||||
}
|
||||
Reference in new issue
Block a user