link 2 rokov pred
rodič
commit
c5d2cebe92
2 zmenil súbory, kde vykonal 20 pridanie a 7 odobranie
  1. 1 1
      main.go
  2. 19 6
      service/system.go

+ 1 - 1
main.go

@@ -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()

+ 19 - 6
service/system.go

@@ -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()