map-dots/run/common.go

24 lines
636 B
Go
Raw Permalink Normal View History

2023-08-11 14:32:44 +01:00
package run
import (
"fmt"
"os"
2023-08-11 14:38:49 +01:00
"git.fjla.uk/fred.boniface/map-dots/log"
2023-08-11 14:32:44 +01:00
)
func envCheck() {
log.Msg.Debug("reading Traccar credentials from environment")
user := os.Getenv("TRACCAR_USER")
pass := os.Getenv("TRACCAR_PASS")
2023-08-11 14:53:28 +01:00
url := os.Getenv("TRACCAR_URL")
2023-08-11 14:32:44 +01:00
2023-08-11 14:53:28 +01:00
if user == "" || pass == "" || url == "" {
2023-08-11 17:38:31 +01:00
fmt.Println("To use Traccar, you must set the environment variables:\n'TRACCAR_USER', 'TRACCAR_PASS', 'TRACCAR_URL' and for CLI use only 'TRACCAR_DEVID'")
2023-08-11 14:32:44 +01:00
os.Stdout.Sync() // Flush the output buffer
log.Msg.Fatal("Unable to read values from environment")
}
2023-08-11 14:53:28 +01:00
log.Msg.Debug("Traccar credentials exist in environment")
2023-08-11 14:32:44 +01:00
}