fix: 授权码读取和系统重置命令错误
This commit is contained in:
1 parent
1412e774e3
commit
4fdf2939ad
2 files changed
+19
-6
No files matched your search
@@ -2,7 +2,9 @@ package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"be.ems/src/framework/cmd"
|
||||
"be.ems/src/framework/constants"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
@@ -125,9 +127,20 @@ func (s *BootloaderController) Reset(c *gin.Context) {
|
||||
// return
|
||||
// }
|
||||
|
||||
if err := machine.Reset(); err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
// 重置数据库
|
||||
if runtime.GOOS == "windows" {
|
||||
// return fmt.Errorf("not support window")
|
||||
} else {
|
||||
// 重置数据库
|
||||
if _, err := cmd.Exec("/usr/local/etc/omc/script/setup.sh -i"); err != nil {
|
||||
c.JSON(200, resp.ErrMsg("setup err"))
|
||||
return
|
||||
}
|
||||
// 重启服务
|
||||
if _, err := cmd.Execf("nohup sh -c \"sleep 1s && %s\" > /dev/null 2>&1 &", "sudo systemctl restart omc"); err != nil {
|
||||
c.JSON(200, resp.ErrMsg("restart err"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 清除授权信息
|
||||
|
||||
Reference in new issue
Block a user