mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-24 05:41:43 +02:00
[WIP] Support for cloud version (#17)
* Added build-cloud to Makefile * Fix env var key GOOS * Added taskSetReleaseVersion for edgeboxctl version option write into DB * taskGetSystemUptime to run every 5 ticks * Added support for detecting main disk in cloud version * Added missing import * Finding main device in test * Refactored GetDevices and test to use release_version * Added utils.getIP function, set to run as a 60 tick scheduled task * Added taskEnablePublicDashboard and taskDisablePublicDashboard * Added utils.WriteOption and refactor, added enablePublicDashb0oard * Finalizing online support for dashboard, cloud version support * Added task SetupCloudOptions * Added couple of func description comments * Early return statement (thanks @inverse) * Using IsPublicDashboard in DisablePublicDashboard func * Added constants for release version and device types, added diagnostics.GetReleaseVersion * Removed codecov from test action
This commit is contained in:
@@ -3,6 +3,7 @@ package utils
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@@ -112,6 +113,14 @@ func GetPath(pathKey string) string {
|
||||
}
|
||||
|
||||
switch pathKey {
|
||||
case "cloudEnvFileLocation":
|
||||
|
||||
if env["CLOUD_ENV_FILE_LOCATION"] != "" {
|
||||
targetPath = env["CLOUD_ENV_FILE_LOCATION"]
|
||||
} else {
|
||||
targetPath = "/home/system/components/edgeboxctl/cloud.env"
|
||||
}
|
||||
|
||||
case "apiEnvFileLocation":
|
||||
|
||||
if env["API_ENV_FILE_LOCATION"] != "" {
|
||||
@@ -120,6 +129,14 @@ func GetPath(pathKey string) string {
|
||||
targetPath = "/home/system/components/api/edgebox.env"
|
||||
}
|
||||
|
||||
case "apiPath":
|
||||
|
||||
if env["API_PATH"] != "" {
|
||||
targetPath = env["APT_PATH"]
|
||||
} else {
|
||||
targetPath = "/home/system/components/api/"
|
||||
}
|
||||
|
||||
case "edgeAppsPath":
|
||||
|
||||
if env["EDGEAPPS_PATH"] != "" {
|
||||
@@ -145,3 +162,27 @@ func GetPath(pathKey string) string {
|
||||
return targetPath
|
||||
|
||||
}
|
||||
|
||||
// WriteOption : Writes a key value pair option into the api shared database
|
||||
func WriteOption(optionKey string, optionValue string) {
|
||||
|
||||
db, err := sql.Open("sqlite3", GetSQLiteDbConnectionDetails())
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
formatedDatetime := GetSQLiteFormattedDateTime(time.Now())
|
||||
|
||||
_, err = statement.Exec(optionKey, optionValue, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
db.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user