mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-07 07:09:46 +00:00
done
This commit is contained in:
parent
287445fdb0
commit
e7a26dc60c
@ -62,9 +62,9 @@ func SendAllHardwareStatusBySocket() {
|
||||
|
||||
body["sys_mem"] = memInfo
|
||||
|
||||
body["sys_cpu"] = cpu
|
||||
body["sys_cpu"] = cpuData
|
||||
|
||||
body["sys_net"] = netList
|
||||
body["sys_net"] = newNet
|
||||
systemTempMap := service.MyService.Notify().GetSystemTempMap()
|
||||
for k, v := range systemTempMap {
|
||||
body[k] = v
|
||||
|
||||
@ -119,6 +119,7 @@ func InitRouter() *gin.Engine {
|
||||
v1FolderGroup.PUT("/name", v1.RenamePath)
|
||||
v1FolderGroup.GET("", v1.DirPath) ///file/dirpath
|
||||
v1FolderGroup.POST("", v1.MkdirAll) ///file/mkdir
|
||||
v1FolderGroup.GET("/size", v1.GetSize)
|
||||
}
|
||||
v1BatchGroup := v1Group.Group("/batch")
|
||||
v1BatchGroup.Use()
|
||||
|
||||
@ -649,3 +649,14 @@ func DeleteOperateFileOrDir(c *gin.Context) {
|
||||
go service.MyService.Notify().SendFileOperateNotify(true)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
func GetSize(c *gin.Context) {
|
||||
json := make(map[string]string)
|
||||
c.ShouldBind(&json)
|
||||
path := json["path"]
|
||||
size, err := file.GetFileOrDirSize(path)
|
||||
if err != nil {
|
||||
c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: size})
|
||||
}
|
||||
|
||||
@ -336,11 +336,10 @@ func GetSystemProxy(c *gin.Context) {
|
||||
|
||||
func PutSystemState(c *gin.Context) {
|
||||
state := c.Param("state")
|
||||
if state == "off" {
|
||||
if strings.ToLower(state) == "off" {
|
||||
service.MyService.System().SystemShutdown()
|
||||
} else if state == "restart" {
|
||||
} else if strings.ToLower(state) == "restart" {
|
||||
service.MyService.System().SystemReboot()
|
||||
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: "The operation will be completed shortly."})
|
||||
}
|
||||
|
||||
@ -376,6 +376,7 @@ func (s *systemService) GetCPUPower() map[string]string {
|
||||
}
|
||||
|
||||
func (s *systemService) SystemReboot() error {
|
||||
//cmd := exec.Command("/bin/bash", "-c", "reboot")
|
||||
arg := []string{"6"}
|
||||
cmd := exec.Command("init", arg...)
|
||||
_, err := cmd.CombinedOutput()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user