1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-15 23:54:17 +02:00
This commit is contained in:
LinkLeong
2022-11-29 02:25:26 +00:00
parent 60608c5dc7
commit eb31bf5586
7 changed files with 91 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
net2 "net"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
@ -52,6 +53,8 @@ type SystemService interface {
GetCPUTemperature() int
GetCPUPower() map[string]string
GetMacAddress() (string, error)
SystemReboot() error
SystemShutdown() error
}
type systemService struct{}
@ -364,6 +367,26 @@ func (s *systemService) GetCPUPower() map[string]string {
return data
}
func (s *systemService) SystemReboot() error {
arg := []string{"6"}
cmd := exec.Command("init", arg...)
_, err := cmd.CombinedOutput()
if err != nil {
return err
}
return nil
}
func (s *systemService) SystemShutdown() error {
arg := []string{"0"}
cmd := exec.Command("init", arg...)
_, err := cmd.CombinedOutput()
if err != nil {
return err
}
return nil
}
func NewSystemService() SystemService {
return &systemService{}
}