diff --git a/config/config.go b/config/config.go index fda5ad5e..fe70c72d 100644 --- a/config/config.go +++ b/config/config.go @@ -37,9 +37,9 @@ var Conf Config // Version contains the current gophish version var Version = "0.3" -func init() { +func LoadConfig(filepath string) { // Get the config file - config_file, err := ioutil.ReadFile("./config.json") + config_file, err := ioutil.ReadFile(filepath) if err != nil { fmt.Printf("File error: %v\n", err) } diff --git a/gophish.go b/gophish.go index 9034ca01..81e1e3ec 100644 --- a/gophish.go +++ b/gophish.go @@ -33,6 +33,8 @@ import ( "os" "sync" + "gopkg.in/alecthomas/kingpin.v2" + "github.com/NYTimes/gziphandler" "github.com/gophish/gophish/auth" "github.com/gophish/gophish/config" @@ -42,9 +44,16 @@ import ( "github.com/gorilla/handlers" ) -var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile) +var ( + Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile) + + configPath = kingpin.Flag("config", "Location of config.json.").Default("./config.json").String() +) func main() { + // Parse the CLI flags and load the config + kingpin.Parse() + config.LoadConfig(*configPath) // Setup the global variables and settings err := models.Setup() if err != nil {