2021-04-23 14:02:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-03-11 09:22:50 +00:00
|
|
|
"flag"
|
2021-04-23 14:02:15 +00:00
|
|
|
"os"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
"git.cryptic.systems/volker.raschek/dyndns-client/pkg/config"
|
|
|
|
"git.cryptic.systems/volker.raschek/dyndns-client/pkg/daemon"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-11 09:22:50 +00:00
|
|
|
version string
|
|
|
|
configPath string
|
2021-04-23 14:02:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
switch os.Getenv("DYNDNS_CLIENT_LOGGER_LEVEL") {
|
|
|
|
case "DEBUG", "debug":
|
|
|
|
log.SetLevel(log.DebugLevel)
|
|
|
|
case "WARN", "warn":
|
|
|
|
log.SetLevel(log.WarnLevel)
|
|
|
|
case "ERROR", "error":
|
|
|
|
log.SetLevel(log.ErrorLevel)
|
|
|
|
case "FATAL", "fatal":
|
|
|
|
log.SetLevel(log.FatalLevel)
|
|
|
|
case "INFO", "info":
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
}
|
|
|
|
|
|
|
|
switch os.Getenv("DYNDNS_CLIENT_LOGGER_FORMATTER") {
|
|
|
|
case "JSON", "json":
|
|
|
|
log.SetFormatter(&log.JSONFormatter{})
|
|
|
|
case "TEXT", "text":
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
log.SetFormatter(&log.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-03-11 09:22:50 +00:00
|
|
|
flag.StringVar(&configPath, "config", "/etc/dyndns-client/config.json", "Path to json config")
|
|
|
|
|
2021-04-23 14:02:15 +00:00
|
|
|
log.Infof("version %v", version)
|
|
|
|
|
2022-03-11 09:22:50 +00:00
|
|
|
cnf, err := config.Read(configPath)
|
2021-04-23 14:02:15 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
daemon.Start(cnf)
|
|
|
|
}
|