Add system shutdown subcommand
This commit is contained in:
@@ -23,3 +23,17 @@ func (s *Server) SystemReboot(ctx context.Context, system *portal.SystemRebootRe
|
||||
|
||||
return &portal.SystemRebootResponse{State: portal.State_CHANGED, Message: "Rebooting"}, nil
|
||||
}
|
||||
|
||||
func (s *Server) SystemShutdown(ctx context.Context, system *portal.SystemShutdownRequest) (*portal.SystemShutdownResponse, error) {
|
||||
fields := log.Fields{
|
||||
"context": "system",
|
||||
"command": "shutdown",
|
||||
}
|
||||
log := log.WithFields(fields)
|
||||
log.Debug("Received system shutdown request")
|
||||
|
||||
syscall.Sync()
|
||||
go syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
|
||||
|
||||
return &portal.SystemShutdownResponse{State: portal.State_CHANGED, Message: "Shutting down"}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user