From adb12c43b250e10c51c3864c6f99e5d6de154d61 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 5 Nov 2020 16:52:58 -0700 Subject: [PATCH] load env from specific file, add comments --- cmd/telebit/telebit.go | 10 ++++++++++ internal/service/svc_windows.go | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/cmd/telebit/telebit.go b/cmd/telebit/telebit.go index d72ae62..66a4415 100644 --- a/cmd/telebit/telebit.go +++ b/cmd/telebit/telebit.go @@ -36,6 +36,7 @@ import ( "github.com/go-acme/lego/v3/challenge" "github.com/go-acme/lego/v3/providers/dns/duckdns" "github.com/go-acme/lego/v3/providers/dns/godaddy" + "github.com/joho/godotenv" _ "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") // TODO replace the websocket connection with a mock server 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") 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)") @@ -143,6 +145,14 @@ func main() { 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) if len(spfRecords) > 0 { fmt.Println( diff --git a/internal/service/svc_windows.go b/internal/service/svc_windows.go index c0ab48e..9f91b1d 100644 --- a/internal/service/svc_windows.go +++ b/internal/service/svc_windows.go @@ -75,5 +75,13 @@ func install(name, desc, exepath string) error { 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 }