mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-06-16 05:55:33 +00:00
Socket update (#1151)
This commit is contained in:
parent
955e8dea07
commit
c5d2cebe92
2
main.go
2
main.go
@ -87,7 +87,7 @@ func init() {
|
|||||||
|
|
||||||
route.InitFunction()
|
route.InitFunction()
|
||||||
go SendToSocket(service.MyService.System().GetDeviceInfo())
|
go SendToSocket(service.MyService.System().GetDeviceInfo())
|
||||||
service.MyService.System().GenreateSystemEntry()
|
//service.MyService.System().GenreateSystemEntry()
|
||||||
///
|
///
|
||||||
//service.MountLists = make(map[string]*mountlib.MountPoint)
|
//service.MountLists = make(map[string]*mountlib.MountPoint)
|
||||||
//configfile.Install()
|
//configfile.Install()
|
||||||
|
@ -149,17 +149,30 @@ func (c *systemService) GenreateSystemEntry() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
func (c *systemService) GetSystemEntry() string {
|
func (c *systemService) GetSystemEntry() string {
|
||||||
entryFilePath := filepath.Join(config.AppInfo.DBPath, "db", "entry.json")
|
|
||||||
_, err := os.Open(entryFilePath)
|
modelsPath := "/var/lib/casaos/www/modules"
|
||||||
if os.IsNotExist(err) {
|
entryFileName := "entry.json"
|
||||||
return ""
|
dir, err := os.ReadDir(modelsPath)
|
||||||
}
|
|
||||||
by, err := os.ReadFile(entryFilePath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("read entry file error", zap.Error(err))
|
logger.Error("read dir error", zap.Error(err))
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return string(by)
|
json := "["
|
||||||
|
for _, v := range dir {
|
||||||
|
data, err := os.ReadFile(filepath.Join(modelsPath, v.Name(), entryFileName))
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("read entry file error", zap.Error(err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
json += string(data) + ","
|
||||||
|
}
|
||||||
|
json = strings.TrimRight(json, ",")
|
||||||
|
json += "]"
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("write entry file error", zap.Error(err))
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return json
|
||||||
}
|
}
|
||||||
func (c *systemService) GetMacAddress() (string, error) {
|
func (c *systemService) GetMacAddress() (string, error) {
|
||||||
interfaces, err := net.Interfaces()
|
interfaces, err := net.Interfaces()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user