Leverage release as version
parent
8be566afb9
commit
03f7ac8468
25
Makefile
25
Makefile
|
@ -9,25 +9,10 @@ GOOS := $(shell go env GOOS)
|
||||||
GOARCH := $(shell go env GOARCH)
|
GOARCH := $(shell go env GOARCH)
|
||||||
|
|
||||||
|
|
||||||
build-all:
|
build-all: clean
|
||||||
GOOS=linux GOARCH=amd64 make build
|
GOOS=linux GOARCH=amd64 make build
|
||||||
GOOS=linux GOARCH=arm make build
|
GOOS=linux GOARCH=arm make build
|
||||||
|
GOOS=linux GOARCH=arm64 make build
|
||||||
build-prod:
|
|
||||||
GOOS=linux GOARCH=arm RELEASE=prod make build
|
|
||||||
|
|
||||||
build-cloud:
|
|
||||||
GOOS=linux GOARCH=amd64 RELEASE=cloud make build
|
|
||||||
|
|
||||||
build-arm64:
|
|
||||||
GOOS=linux GOARCH=arm64 RELEASE=prod make build
|
|
||||||
|
|
||||||
build-armhf:
|
|
||||||
GOOS=linux GOARCH=arm RELEASE=prod make build
|
|
||||||
|
|
||||||
build-amd64:
|
|
||||||
GOOS=linux GOARCH=amd64 RELEASE=prod make build
|
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "Building ${GOOS}-${GOARCH}"
|
@echo "Building ${GOOS}-${GOARCH}"
|
||||||
|
@ -57,11 +42,7 @@ install:
|
||||||
@echo "Edgeboxctl installed successfully"
|
@echo "Edgeboxctl installed successfully"
|
||||||
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
|
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
|
||||||
|
|
||||||
install-prod: build-prod install
|
build-install: build install
|
||||||
install-cloud: build-cloud install
|
|
||||||
install-arm64: build-arm64 install
|
|
||||||
install-armhf: build-armhf install
|
|
||||||
install-amd64: build-amd64 install
|
|
||||||
|
|
||||||
start:
|
start:
|
||||||
systemctl start edgeboxctl
|
systemctl start edgeboxctl
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
package diagnostics
|
package diagnostics
|
||||||
|
|
||||||
type ReleaseVersion string
|
|
||||||
|
|
||||||
var Version string
|
var Version string
|
||||||
var Commit string
|
var Commit string
|
||||||
var BuildDate string
|
var BuildDate string
|
||||||
|
|
||||||
const (
|
|
||||||
DEV_VERSION ReleaseVersion = "dev"
|
|
||||||
PROD_VERSION ReleaseVersion = "prod"
|
|
||||||
CLOUD_VERSION ReleaseVersion = "cloud"
|
|
||||||
OTHER_VERSION ReleaseVersion = "other"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetReleaseVersion() ReleaseVersion {
|
|
||||||
return ReleaseVersion(Version)
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/edgebox-iot/edgeboxctl/internal/diagnostics"
|
|
||||||
"github.com/edgebox-iot/edgeboxctl/internal/utils"
|
"github.com/edgebox-iot/edgeboxctl/internal/utils"
|
||||||
"github.com/shirou/gopsutil/disk"
|
"github.com/shirou/gopsutil/disk"
|
||||||
)
|
)
|
||||||
|
@ -75,20 +74,9 @@ const (
|
||||||
DISK_TYPE_VDA DeviceIdentifier = "vda"
|
DISK_TYPE_VDA DeviceIdentifier = "vda"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDeviceIdentifier(release_version diagnostics.ReleaseVersion) DeviceIdentifier {
|
|
||||||
switch release_version {
|
|
||||||
case diagnostics.CLOUD_VERSION:
|
|
||||||
return DISK_TYPE_VDA
|
|
||||||
case diagnostics.PROD_VERSION:
|
|
||||||
return DISK_TYPE_MCBLK
|
|
||||||
}
|
|
||||||
|
|
||||||
return DISK_TYPE_SDA
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDevices : Returns a list of all available sotrage devices in structs filled with information
|
|
||||||
func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
|
|
||||||
|
|
||||||
|
// GetDevices : Returns a list of all available storage devices in structs filled with information
|
||||||
|
func GetDevices() []Device {
|
||||||
var devices []Device
|
var devices []Device
|
||||||
|
|
||||||
cmdArgs := []string{"--raw", "--bytes", "--noheadings"}
|
cmdArgs := []string{"--raw", "--bytes", "--noheadings"}
|
||||||
|
@ -100,8 +88,6 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
|
||||||
firstDevice := true
|
firstDevice := true
|
||||||
currentDeviceInUseFlag := false
|
currentDeviceInUseFlag := false
|
||||||
|
|
||||||
mainDiskID := GetDeviceIdentifier(release_version)
|
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
// 1 Device is represented here. Extract words in order for filling a Device struct
|
// 1 Device is represented here. Extract words in order for filling a Device struct
|
||||||
// Example deviceRawInfo: "mmcblk0 179:0 0 29.7G 0 disk"
|
// Example deviceRawInfo: "mmcblk0 179:0 0 29.7G 0 disk"
|
||||||
|
@ -153,14 +139,9 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
|
||||||
Status: DeviceStatus{ID: 1, Description: "healthy"},
|
Status: DeviceStatus{ID: 1, Description: "healthy"},
|
||||||
}
|
}
|
||||||
|
|
||||||
if device.ID == mainDiskID {
|
|
||||||
device.MainDevice = true
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDevice = device
|
currentDevice = device
|
||||||
|
|
||||||
} else if isPartition {
|
} else if isPartition {
|
||||||
|
|
||||||
mountpoint := ""
|
mountpoint := ""
|
||||||
if len(deviceRawInfo) >= 7 {
|
if len(deviceRawInfo) >= 7 {
|
||||||
mountpoint = deviceRawInfo[6]
|
mountpoint = deviceRawInfo[6]
|
||||||
|
|
|
@ -82,6 +82,7 @@ func SetupCloudOptions() {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error loading .env file for cloud version setup")
|
fmt.Println("Error loading .env file for cloud version setup")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if cloudEnv["NAME"] != "" {
|
if cloudEnv["NAME"] != "" {
|
||||||
|
|
|
@ -164,213 +164,208 @@ func ExecuteTask(task Task) Task {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if diagnostics.GetReleaseVersion() == diagnostics.DEV_VERSION {
|
log.Println("Task: " + task.Task)
|
||||||
log.Printf("Dev environemnt. Not executing tasks.")
|
log.Println("Args: " + task.Args.String)
|
||||||
} else {
|
switch task.Task {
|
||||||
log.Println("Task: " + task.Task)
|
case "setup_backups":
|
||||||
log.Println("Args: " + task.Args.String)
|
|
||||||
switch task.Task {
|
|
||||||
case "setup_backups":
|
|
||||||
|
|
||||||
log.Println("Setting up Backups Destination...")
|
log.Println("Setting up Backups Destination...")
|
||||||
var args taskSetupBackupsArgs
|
var args taskSetupBackupsArgs
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error reading arguments of setup_backups task.")
|
log.Println("Error reading arguments of setup_backups task.")
|
||||||
} else {
|
} else {
|
||||||
taskResult := taskSetupBackups(args)
|
taskResult := taskSetupBackups(args)
|
||||||
taskResultBool := true
|
|
||||||
// Check if returned taskResult string contains "error"
|
|
||||||
if strings.Contains(taskResult, "error") {
|
|
||||||
taskResultBool = false
|
|
||||||
}
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "start_backup":
|
|
||||||
|
|
||||||
log.Println("Backing up Edgebox...")
|
|
||||||
taskResult := taskBackup()
|
|
||||||
taskResultBool := true
|
taskResultBool := true
|
||||||
// Check if returned taskResult string contains "error"
|
// Check if returned taskResult string contains "error"
|
||||||
if strings.Contains(taskResult, "error") {
|
if strings.Contains(taskResult, "error") {
|
||||||
taskResultBool = false
|
taskResultBool = false
|
||||||
}
|
}
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
||||||
|
|
||||||
case "restore_backup":
|
|
||||||
log.Println("Attempting to Restore Last Backup to Edgebox")
|
|
||||||
taskResult := taskRestoreBackup()
|
|
||||||
taskResultBool := true
|
|
||||||
// Check if returned taskResult string contains "error"
|
|
||||||
if strings.Contains(taskResult, "error") {
|
|
||||||
taskResultBool = false
|
|
||||||
}
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
|
||||||
|
|
||||||
case "setup_tunnel":
|
|
||||||
|
|
||||||
log.Println("Setting up Cloudflare Tunnel...")
|
|
||||||
var args taskSetupTunnelArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of setup_tunnel task: %s", err)
|
|
||||||
status := "{\"status\": \"error\", \"message\": \"The Domain Name you are going to Authorize must be provided beforehand! Please insert a domain name and try again.\"}"
|
|
||||||
utils.WriteOption("TUNNEL_STATUS", status)
|
|
||||||
} else {
|
|
||||||
taskResult := taskSetupTunnel(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "start_tunnel":
|
|
||||||
|
|
||||||
log.Println("Starting Cloudflare Tunnel...")
|
|
||||||
taskResult := taskStartTunnel()
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
|
|
||||||
case "stop_tunnel":
|
|
||||||
|
|
||||||
log.Println("Stopping Cloudflare Tunnel...")
|
|
||||||
taskResult := taskStopTunnel()
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
|
|
||||||
case "disable_tunnel":
|
|
||||||
|
|
||||||
log.Println("Disabling Cloudflare Tunnel...")
|
|
||||||
taskResult := taskDisableTunnel()
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
|
|
||||||
case "install_edgeapp":
|
|
||||||
|
|
||||||
log.Println("Installing EdgeApp...")
|
|
||||||
var args taskInstallEdgeAppArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of install_edgeapp task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskInstallEdgeApp(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "remove_edgeapp":
|
|
||||||
|
|
||||||
log.Println("Removing EdgeApp...")
|
|
||||||
var args taskRemoveEdgeAppArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of remove_edgeapp task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskRemoveEdgeApp(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "start_edgeapp":
|
|
||||||
|
|
||||||
log.Println("Starting EdgeApp...")
|
|
||||||
var args taskStartEdgeAppArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of start_edgeapp task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskStartEdgeApp(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "stop_edgeapp":
|
|
||||||
|
|
||||||
log.Println("Stopping EdgeApp...")
|
|
||||||
var args taskStopEdgeAppArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of stop_edgeapp task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskStopEdgeApp(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "set_edgeapp_options":
|
|
||||||
|
|
||||||
log.Println("Setting EdgeApp Options...")
|
|
||||||
var args taskSetEdgeAppOptionsArgs
|
|
||||||
// {"id":"podgrab","options":{"PODGRAB_PASSWORD":"fumarmata"}}
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of set_edgeapp_options task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskSetEdgeAppOptions(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "set_edgeapp_basic_auth":
|
|
||||||
|
|
||||||
log.Println("Settig EdgeApp Basic Authentication...")
|
|
||||||
var args taskSetEdgeAppBasicAuthArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of set_edgeapp_basic_auth task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskSetEdgeAppBasicAuth(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "remove_edgeapp_basic_auth":
|
|
||||||
|
|
||||||
log.Println("Removing EdgeApp Basic Authentication...")
|
|
||||||
var args taskRemoveEdgeAppBasicAuthArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of remove_edgeapp_basic_auth task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskRemoveEdgeAppBasicAuth(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "enable_online":
|
|
||||||
|
|
||||||
log.Println("Enabling online access to EdgeApp...")
|
|
||||||
var args taskEnableOnlineArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of enable_online task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskEnableOnline(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "disable_online":
|
|
||||||
|
|
||||||
log.Println("Disabling online access to EdgeApp...")
|
|
||||||
var args taskDisableOnlineArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of enable_online task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskDisableOnline(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "enable_public_dashboard":
|
|
||||||
|
|
||||||
log.Println("Enabling online access to Dashboard...")
|
|
||||||
var args taskEnablePublicDashboardArgs
|
|
||||||
err := json.Unmarshal([]byte(task.Args.String), &args)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading arguments of enable_public_dashboard task: %s", err)
|
|
||||||
} else {
|
|
||||||
taskResult := taskEnablePublicDashboard(args)
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "disable_public_dashboard":
|
|
||||||
|
|
||||||
log.Println("Disabling online access to Dashboard...")
|
|
||||||
taskResult := taskDisablePublicDashboard()
|
|
||||||
task.Result = sql.NullString{String: taskResult, Valid: true}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "start_backup":
|
||||||
|
|
||||||
|
log.Println("Backing up Edgebox...")
|
||||||
|
taskResult := taskBackup()
|
||||||
|
taskResultBool := true
|
||||||
|
// Check if returned taskResult string contains "error"
|
||||||
|
if strings.Contains(taskResult, "error") {
|
||||||
|
taskResultBool = false
|
||||||
|
}
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
||||||
|
|
||||||
|
case "restore_backup":
|
||||||
|
log.Println("Attempting to Restore Last Backup to Edgebox")
|
||||||
|
taskResult := taskRestoreBackup()
|
||||||
|
taskResultBool := true
|
||||||
|
// Check if returned taskResult string contains "error"
|
||||||
|
if strings.Contains(taskResult, "error") {
|
||||||
|
taskResultBool = false
|
||||||
|
}
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: taskResultBool}
|
||||||
|
|
||||||
|
case "setup_tunnel":
|
||||||
|
|
||||||
|
log.Println("Setting up Cloudflare Tunnel...")
|
||||||
|
var args taskSetupTunnelArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of setup_tunnel task: %s", err)
|
||||||
|
status := "{\"status\": \"error\", \"message\": \"The Domain Name you are going to Authorize must be provided beforehand! Please insert a domain name and try again.\"}"
|
||||||
|
utils.WriteOption("TUNNEL_STATUS", status)
|
||||||
|
} else {
|
||||||
|
taskResult := taskSetupTunnel(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "start_tunnel":
|
||||||
|
|
||||||
|
log.Println("Starting Cloudflare Tunnel...")
|
||||||
|
taskResult := taskStartTunnel()
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
|
||||||
|
case "stop_tunnel":
|
||||||
|
|
||||||
|
log.Println("Stopping Cloudflare Tunnel...")
|
||||||
|
taskResult := taskStopTunnel()
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
|
||||||
|
case "disable_tunnel":
|
||||||
|
|
||||||
|
log.Println("Disabling Cloudflare Tunnel...")
|
||||||
|
taskResult := taskDisableTunnel()
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
|
||||||
|
case "install_edgeapp":
|
||||||
|
|
||||||
|
log.Println("Installing EdgeApp...")
|
||||||
|
var args taskInstallEdgeAppArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of install_edgeapp task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskInstallEdgeApp(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "remove_edgeapp":
|
||||||
|
|
||||||
|
log.Println("Removing EdgeApp...")
|
||||||
|
var args taskRemoveEdgeAppArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of remove_edgeapp task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskRemoveEdgeApp(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "start_edgeapp":
|
||||||
|
|
||||||
|
log.Println("Starting EdgeApp...")
|
||||||
|
var args taskStartEdgeAppArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of start_edgeapp task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskStartEdgeApp(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "stop_edgeapp":
|
||||||
|
|
||||||
|
log.Println("Stopping EdgeApp...")
|
||||||
|
var args taskStopEdgeAppArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of stop_edgeapp task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskStopEdgeApp(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "set_edgeapp_options":
|
||||||
|
|
||||||
|
log.Println("Setting EdgeApp Options...")
|
||||||
|
var args taskSetEdgeAppOptionsArgs
|
||||||
|
// {"id":"podgrab","options":{"PODGRAB_PASSWORD":"fumarmata"}}
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of set_edgeapp_options task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskSetEdgeAppOptions(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "set_edgeapp_basic_auth":
|
||||||
|
|
||||||
|
log.Println("Settig EdgeApp Basic Authentication...")
|
||||||
|
var args taskSetEdgeAppBasicAuthArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of set_edgeapp_basic_auth task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskSetEdgeAppBasicAuth(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "remove_edgeapp_basic_auth":
|
||||||
|
|
||||||
|
log.Println("Removing EdgeApp Basic Authentication...")
|
||||||
|
var args taskRemoveEdgeAppBasicAuthArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of remove_edgeapp_basic_auth task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskRemoveEdgeAppBasicAuth(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "enable_online":
|
||||||
|
|
||||||
|
log.Println("Enabling online access to EdgeApp...")
|
||||||
|
var args taskEnableOnlineArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of enable_online task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskEnableOnline(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "disable_online":
|
||||||
|
|
||||||
|
log.Println("Disabling online access to EdgeApp...")
|
||||||
|
var args taskDisableOnlineArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of enable_online task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskDisableOnline(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "enable_public_dashboard":
|
||||||
|
|
||||||
|
log.Println("Enabling online access to Dashboard...")
|
||||||
|
var args taskEnablePublicDashboardArgs
|
||||||
|
err := json.Unmarshal([]byte(task.Args.String), &args)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading arguments of enable_public_dashboard task: %s", err)
|
||||||
|
} else {
|
||||||
|
taskResult := taskEnablePublicDashboard(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "disable_public_dashboard":
|
||||||
|
|
||||||
|
log.Println("Disabling online access to Dashboard...")
|
||||||
|
taskResult := taskDisablePublicDashboard()
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
statement, err = db.Prepare("Update task SET status = ?, result = ?, updated = ? WHERE ID = ?;") // Prepare SQL Statement
|
statement, err = db.Prepare("Update task SET status = ?, result = ?, updated = ? WHERE ID = ?;") // Prepare SQL Statement
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
|
@ -427,10 +422,9 @@ func ExecuteSchedules(tick int) {
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if diagnostics.GetReleaseVersion() == diagnostics.CLOUD_VERSION {
|
|
||||||
log.Println("Setting up cloud version options (name, email, api token)")
|
log.Println("Setting up cloud version options (name, email, api token)")
|
||||||
taskSetupCloudOptions()
|
taskSetupCloudOptions()
|
||||||
}
|
|
||||||
|
|
||||||
// Executing on startup (first tick). Schedules run before tasks in the SystemIterator
|
// Executing on startup (first tick). Schedules run before tasks in the SystemIterator
|
||||||
uptime := taskGetSystemUptime()
|
uptime := taskGetSystemUptime()
|
||||||
|
@ -1196,7 +1190,7 @@ func taskGetSystemUptime() string {
|
||||||
func taskGetStorageDevices() string {
|
func taskGetStorageDevices() string {
|
||||||
fmt.Println("Executing taskGetStorageDevices")
|
fmt.Println("Executing taskGetStorageDevices")
|
||||||
|
|
||||||
devices := storage.GetDevices(diagnostics.GetReleaseVersion())
|
devices := storage.GetDevices()
|
||||||
devicesJSON, _ := json.Marshal(devices)
|
devicesJSON, _ := json.Marshal(devices)
|
||||||
|
|
||||||
utils.WriteOption("STORAGE_DEVICES_LIST", string(devicesJSON))
|
utils.WriteOption("STORAGE_DEVICES_LIST", string(devicesJSON))
|
||||||
|
|
Loading…
Reference in New Issue