style: 系统初始引导函数优化

This commit is contained in:
TsMask
2024-05-07 19:14:44 +08:00
parent 1708b12bd1
commit 9abfe9b30e
2 changed files with 31 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ import (
"be.ems/src/framework/constants/common"
"be.ems/src/framework/logger"
"be.ems/src/framework/utils/cmd"
"be.ems/src/framework/utils/crypto"
"be.ems/src/framework/utils/parse"
)
@@ -143,3 +144,30 @@ func SetLaunchInfo(info map[string]any) error {
}
return codeFileWrite(LaunchInfo)
}
// Bootloader 启动引导标记
func Bootloader(flag bool) error {
return SetLaunchInfo(map[string]any{
common.LAUNCH_BOOTLOADER: flag, // 启动引导 true开 false关
common.LAUNCH_BOOTLOADER + "Time": time.Now().UnixMilli(), // 引导完成时间
})
}
// Reset 引导数据重置
func Reset() error {
// 重置数据库
if runtime.GOOS == "windows" {
// return fmt.Errorf("not support window")
} else {
if _, err := cmd.ExecWithCheck("sudo", "/usr/local/omc/bin/setomc.sh", "-m", "install"); err != nil {
return err
}
}
// 重置引导标记
if err := Bootloader(true); err != nil {
return err
}
return nil
}