MCPcopy
hub / github.com/IceWhaleTech/CasaOS / InitInfo

Function InitInfo

route/init.go:39–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39func InitInfo() {
40 mb := model.BaseInfo{}
41 if file.Exists(config.AppInfo.DBPath + "/baseinfo.conf") {
42 err := json.Unmarshal(file.ReadFullFile(config.AppInfo.DBPath+"/baseinfo.conf"), &mb)
43 if err != nil {
44 logger.Error("baseinfo.conf", zap.String("error", err.Error()))
45 }
46 }
47 if file.Exists("/etc/CHANNEL") {
48 channel := file.ReadFullFile("/etc/CHANNEL")
49 mb.Channel = string(channel)
50 }
51 mac, err := service.MyService.System().GetMacAddress()
52 if err != nil {
53 logger.Error("GetMacAddress", zap.String("error", err.Error()))
54 }
55 mb.Hash = encryption.GetMD5ByStr(mac)
56 mb.Version = common.VERSION
57 osRelease, _ := file1.ReadOSRelease()
58
59 mb.DriveModel = osRelease["MODEL"]
60 if len(mb.DriveModel) == 0 {
61 mb.DriveModel = "Casa"
62 }
63 os.Remove(config.AppInfo.DBPath + "/baseinfo.conf")
64 by, err := json.Marshal(mb)
65 if err != nil {
66 logger.Error("init info err", zap.Any("err", err))
67 return
68 }
69 file.WriteToFullPath(by, config.AppInfo.DBPath+"/baseinfo.conf", 0o666)
70}
71
72func InitNetworkMount() {
73 time.Sleep(time.Second * 10)

Callers 1

InitFunctionFunction · 0.85

Calls 8

ExistsFunction · 0.92
ReadFullFileFunction · 0.92
GetMD5ByStrFunction · 0.92
WriteToFullPathFunction · 0.92
GetMacAddressMethod · 0.65
SystemMethod · 0.65
RemoveMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected