Skip to content

Commit

Permalink
Socket update (IceWhaleTech#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkLeong authored May 30, 2023
1 parent 955e8de commit c5d2ceb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func init() {

route.InitFunction()
go SendToSocket(service.MyService.System().GetDeviceInfo())
service.MyService.System().GenreateSystemEntry()
//service.MyService.System().GenreateSystemEntry()
///
//service.MountLists = make(map[string]*mountlib.MountPoint)
//configfile.Install()
Expand Down
25 changes: 19 additions & 6 deletions service/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,30 @@ func (c *systemService) GenreateSystemEntry() {

}
func (c *systemService) GetSystemEntry() string {
entryFilePath := filepath.Join(config.AppInfo.DBPath, "db", "entry.json")
_, err := os.Open(entryFilePath)
if os.IsNotExist(err) {

modelsPath := "/var/lib/casaos/www/modules"
entryFileName := "entry.json"
dir, err := os.ReadDir(modelsPath)
if err != nil {
logger.Error("read dir error", zap.Error(err))
return ""
}
by, err := os.ReadFile(entryFilePath)
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("read entry file error", zap.Error(err))
logger.Error("write entry file error", zap.Error(err))
return ""
}
return string(by)
return json
}
func (c *systemService) GetMacAddress() (string, error) {
interfaces, err := net.Interfaces()
Expand Down

0 comments on commit c5d2ceb

Please sign in to comment.