Added config.json CLI flag: --config

This commit is contained in:
Jordan Wright 2017-06-09 00:14:03 -05:00
parent 17bf53a6e2
commit 772fe28c06
2 changed files with 12 additions and 3 deletions

View file

@ -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)
}

View file

@ -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 {