Added http and https prefixes to broserdevurl

pull/41/head
Paulo Truta 2024-12-08 20:00:37 +01:00
parent b5a9a1d85c
commit 6593f67c8b
1 changed files with 30 additions and 3 deletions

View File

@ -18,6 +18,8 @@ import (
"github.com/edgebox-iot/edgeboxctl/internal/system"
"github.com/edgebox-iot/edgeboxctl/internal/utils"
"github.com/joho/godotenv"
_ "github.com/go-sql-driver/mysql" // Mysql Driver
_ "github.com/mattn/go-sqlite3" // SQlite Driver
)
@ -531,6 +533,8 @@ func ExecuteSchedules(tick int) {
log.Println("Fetching Browser Dev Environment Information")
taskGetBrowserDevPassword()
taskGetBrowserDevStatus()
taskCheckSystemUpdates()
ip := taskGetSystemIP()
log.Println("System IP is: " + ip)
@ -560,9 +564,7 @@ func ExecuteSchedules(tick int) {
taskStartWs()
log.Println(taskGetEdgeApps())
taskUpdateSystemLoggerServices()
taskRecoverFromUpdate()
taskCheckSystemUpdates()
taskRecoverFromUpdate()
}
if tick%5 == 0 {
@ -571,6 +573,10 @@ func ExecuteSchedules(tick int) {
log.Println(taskGetStorageDevices())
}
if tick%15 == 0 {
taskGetBrowserDevStatus()
}
if tick%30 == 0 {
// Executing every 30 ticks
log.Println(taskGetEdgeApps())
@ -1150,7 +1156,10 @@ func taskGetBrowserDevStatus() string {
if browserDevStatus == "active" {
fmt.Println("Browser Dev Environment is running")
utils.WriteOption("BROWSERDEV_STATUS", "running")
taskGetBrowserDevUrl()
return "{\"status\": \"running\"}"
} else {
fmt.Println("Browser Dev Environment is not running")
utils.WriteOption("BROWSERDEV_STATUS", "not_running")
@ -1158,6 +1167,24 @@ func taskGetBrowserDevStatus() string {
}
}
func taskGetBrowserDevUrl() string {
url := ""
myEdgeAppServiceEnv, err := godotenv.Read(utils.GetPath(utils.EdgeAppsPath) + "dev/myedgeapp.env")
if err != nil {
log.Println("No myedge.app environment file found. Status is Network-Only")
url = "http://dev." + system.GetHostname() + ".local"
} else {
if myEdgeAppServiceEnv["INTERNET_URL"] != "" {
url = "https://" + myEdgeAppServiceEnv["INTERNET_URL"]
}
}
fmt.Println("Browser Dev Url: " + url)
utils.WriteOption("BROWSERDEV_URL", url)
return url
}
func taskActivateBrowserDev() string {
fmt.Println("Executing taskActivateBrowserDev")
wsPath := utils.GetPath(utils.WsPath)