From 5ccf9fdcd327052cee5205c69e422ca09ce1f7b7 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Tue, 8 Mar 2016 07:09:26 -0800 Subject: [PATCH] ctwatch: allow state dir to be set by $CTWATCH_STATE_DIR --- cmd/ctwatch/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/ctwatch/main.go b/cmd/ctwatch/main.go index 2fe1ebf..eca2e4f 100644 --- a/cmd/ctwatch/main.go +++ b/cmd/ctwatch/main.go @@ -12,7 +12,15 @@ import ( "src.agwa.name/ctwatch/cmd" ) -var stateDir = flag.String("state_dir", cmd.DefaultStateDir("ctwatch"), "Directory for storing state") +func DefaultStateDir () string { + if envVar := os.Getenv("CTWATCH_STATE_DIR"); envVar != "" { + return envVar + } else { + return cmd.DefaultStateDir("ctwatch") + } +} + +var stateDir = flag.String("state_dir", DefaultStateDir(), "Directory for storing state") var watchDomains []string var watchDomainSuffixes []string