|
@@ -17,6 +17,7 @@ import (
|
|
"imuslab.com/arozos/mod/agi/static"
|
|
"imuslab.com/arozos/mod/agi/static"
|
|
apt "imuslab.com/arozos/mod/apt"
|
|
apt "imuslab.com/arozos/mod/apt"
|
|
"imuslab.com/arozos/mod/filesystem"
|
|
"imuslab.com/arozos/mod/filesystem"
|
|
|
|
+ "imuslab.com/arozos/mod/filesystem/arozfs"
|
|
metadata "imuslab.com/arozos/mod/filesystem/metadata"
|
|
metadata "imuslab.com/arozos/mod/filesystem/metadata"
|
|
"imuslab.com/arozos/mod/iot"
|
|
"imuslab.com/arozos/mod/iot"
|
|
"imuslab.com/arozos/mod/share"
|
|
"imuslab.com/arozos/mod/share"
|
|
@@ -197,8 +198,8 @@ func (g *Gateway) APIHandler(w http.ResponseWriter, r *http.Request, thisuser *u
|
|
// Handle user requests
|
|
// Handle user requests
|
|
func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisuser *user.User) {
|
|
func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisuser *user.User) {
|
|
//Get user object from the request
|
|
//Get user object from the request
|
|
- startupRoot := g.Option.StartupRoot
|
|
|
|
- startupRoot = filepath.ToSlash(filepath.Clean(startupRoot))
|
|
|
|
|
|
+ //startupRoot := g.Option.StartupRoot
|
|
|
|
+ //startupRoot = filepath.ToSlash(filepath.Clean(startupRoot))
|
|
|
|
|
|
//Get the script files for the plugin
|
|
//Get the script files for the plugin
|
|
scriptFile, err := utils.GetPara(r, "script")
|
|
scriptFile, err := utils.GetPara(r, "script")
|
|
@@ -212,11 +213,12 @@ func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisu
|
|
scriptExists := false
|
|
scriptExists := false
|
|
scriptScope := "./web/"
|
|
scriptScope := "./web/"
|
|
for _, thisScope := range g.Option.ActivateScope {
|
|
for _, thisScope := range g.Option.ActivateScope {
|
|
- thisScope = filepath.ToSlash(filepath.Clean(thisScope))
|
|
|
|
- if utils.FileExists(thisScope + "/" + scriptFile) {
|
|
|
|
|
|
+ thisScope = arozfs.ToSlash(filepath.Clean(thisScope))
|
|
|
|
+ if utils.FileExists(arozfs.ToSlash(filepath.Join(thisScope, scriptFile))) {
|
|
scriptExists = true
|
|
scriptExists = true
|
|
- scriptFile = thisScope + "/" + scriptFile
|
|
|
|
|
|
+ scriptFile = arozfs.ToSlash(filepath.Join(thisScope, scriptFile))
|
|
scriptScope = thisScope
|
|
scriptScope = thisScope
|
|
|
|
+ break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -252,7 +254,11 @@ func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisu
|
|
}
|
|
}
|
|
|
|
|
|
//Get the content of the script
|
|
//Get the content of the script
|
|
- scriptContentByte, _ := os.ReadFile(scriptFile)
|
|
|
|
|
|
+ scriptContentByte, err := os.ReadFile(scriptFile)
|
|
|
|
+ if err != nil {
|
|
|
|
+ w.Write([]byte("Script load error: " + err.Error()))
|
|
|
|
+ return
|
|
|
|
+ }
|
|
scriptContent := string(scriptContentByte)
|
|
scriptContent := string(scriptContentByte)
|
|
|
|
|
|
g.ExecuteAGIScript(scriptContent, nil, scriptFile, scriptScope, w, r, thisuser)
|
|
g.ExecuteAGIScript(scriptContent, nil, scriptFile, scriptScope, w, r, thisuser)
|