Implement reading password from file
This commit is contained in:
parent
09785448e2
commit
f7110da643
2 changed files with 22 additions and 6 deletions
|
|
@ -10,6 +10,8 @@ Usage of ./vodafone-station-exporter:
|
||||||
Print version and exit
|
Print version and exit
|
||||||
-vodafone.station-password string
|
-vodafone.station-password string
|
||||||
Password for logging into the Vodafone station (default "How is the default password calculated? mhmm")
|
Password for logging into the Vodafone station (default "How is the default password calculated? mhmm")
|
||||||
|
-vodafone.station-password-file string
|
||||||
|
File that contains the password for logging into the Vodafone station
|
||||||
-vodafone.station-url string
|
-vodafone.station-url string
|
||||||
Vodafone station URL. For bridge mode this is 192.168.100.1 (note: Configure a route if using bridge mode) (default "http://192.168.0.1")
|
Vodafone station URL. For bridge mode this is 192.168.100.1 (note: Configure a route if using bridge mode) (default "http://192.168.0.1")
|
||||||
-web.listen-address string
|
-web.listen-address string
|
||||||
|
|
|
||||||
14
main.go
14
main.go
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.0.1"
|
const version = "0.0.1"
|
||||||
|
|
@ -32,6 +33,7 @@ var (
|
||||||
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics")
|
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics")
|
||||||
vodafoneStationUrl = flag.String("vodafone.station-url", "http://192.168.0.1", "Vodafone station URL. For bridge mode this is 192.168.100.1 (note: Configure a route if using bridge mode)")
|
vodafoneStationUrl = flag.String("vodafone.station-url", "http://192.168.0.1", "Vodafone station URL. For bridge mode this is 192.168.100.1 (note: Configure a route if using bridge mode)")
|
||||||
vodafoneStationPassword = flag.String("vodafone.station-password", "How is the default password calculated? mhmm", "Password for logging into the Vodafone station")
|
vodafoneStationPassword = flag.String("vodafone.station-password", "How is the default password calculated? mhmm", "Password for logging into the Vodafone station")
|
||||||
|
vodafoneStationPasswordFile = flag.String("vodafone.station-password-file", "", "Path to a file containing the Vodafone station password (overrides -vodafone.station-password)")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -40,6 +42,18 @@ func main() {
|
||||||
cfg := &promslog.Config{}
|
cfg := &promslog.Config{}
|
||||||
logger = promslog.New(cfg)
|
logger = promslog.New(cfg)
|
||||||
|
|
||||||
|
// Handle password from file if provided
|
||||||
|
if *vodafoneStationPasswordFile != "" {
|
||||||
|
data, err := os.ReadFile(*vodafoneStationPasswordFile)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Failed to read password file", slog.String("err", err.Error()))
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
pw := string(data)
|
||||||
|
pw = strings.TrimSpace(pw)
|
||||||
|
vodafoneStationPassword = &pw
|
||||||
|
}
|
||||||
|
|
||||||
if *showMetrics {
|
if *showMetrics {
|
||||||
describeMetrics()
|
describeMetrics()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue