load env from specific file, add comments

This commit is contained in:
AJ ONeal 2020-11-05 16:52:58 -07:00
parent d174b4739f
commit adb12c43b2
2 changed files with 18 additions and 0 deletions

View File

@ -36,6 +36,7 @@ import (
"github.com/go-acme/lego/v3/challenge" "github.com/go-acme/lego/v3/challenge"
"github.com/go-acme/lego/v3/providers/dns/duckdns" "github.com/go-acme/lego/v3/providers/dns/duckdns"
"github.com/go-acme/lego/v3/providers/dns/godaddy" "github.com/go-acme/lego/v3/providers/dns/godaddy"
"github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
) )
@ -114,6 +115,7 @@ func main() {
spfDomain := flag.String("spf-domain", "", "domain with SPF-like list of IP addresses which are allowed to connect to clients") spfDomain := flag.String("spf-domain", "", "domain with SPF-like list of IP addresses which are allowed to connect to clients")
// TODO replace the websocket connection with a mock server // TODO replace the websocket connection with a mock server
vendorID := flag.String("vendor-id", "", "a unique identifier for a deploy target environment") vendorID := flag.String("vendor-id", "", "a unique identifier for a deploy target environment")
envpath := flag.String("env", "", "path to .env file")
email := flag.String("acme-email", "", "email to use for Let's Encrypt / ACME registration") email := flag.String("acme-email", "", "email to use for Let's Encrypt / ACME registration")
certpath := flag.String("acme-storage", "./acme.d/", "path to ACME storage directory") certpath := flag.String("acme-storage", "./acme.d/", "path to ACME storage directory")
acmeAgree := flag.Bool("acme-agree", false, "agree to the terms of the ACME service provider (required)") acmeAgree := flag.Bool("acme-agree", false, "agree to the terms of the ACME service provider (required)")
@ -143,6 +145,14 @@ func main() {
dbg.Debug = *verbose dbg.Debug = *verbose
} }
if len(*envpath) > 0 {
if err := godotenv.Load(*envpath); nil != err {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(exitBadArguments)
return
}
}
spfRecords := iplist.Init(*spfDomain) spfRecords := iplist.Init(*spfDomain)
if len(spfRecords) > 0 { if len(spfRecords) > 0 {
fmt.Println( fmt.Println(

View File

@ -75,5 +75,13 @@ func install(name, desc, exepath string) error {
return fmt.Errorf("could not install system service: %v", err) return fmt.Errorf("could not install system service: %v", err)
} }
/*
//err = s.Start("is", "manual-started")
err = s.Start("is", "auto-started")
if err != nil {
return fmt.Errorf("could not start service: %v", err)
}
*/
return nil return nil
} }