diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..bed5bd70 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.4-dev \ No newline at end of file diff --git a/config/config.go b/config/config.go index fe70c72d..86b9144a 100644 --- a/config/config.go +++ b/config/config.go @@ -35,15 +35,17 @@ type Config struct { var Conf Config // Version contains the current gophish version -var Version = "0.3" +var Version = "" +// LoadConfig loads the configuration from the specified filepath func LoadConfig(filepath string) { // Get the config file - config_file, err := ioutil.ReadFile(filepath) + configFile, err := ioutil.ReadFile(filepath) if err != nil { fmt.Printf("File error: %v\n", err) } - json.Unmarshal(config_file, &Conf) + json.Unmarshal(configFile, &Conf) + // Choosing the migrations directory based on the database used. Conf.MigrationsPath = Conf.MigrationsPath + Conf.DBName } diff --git a/gophish.go b/gophish.go index 81e1e3ec..e46daf17 100644 --- a/gophish.go +++ b/gophish.go @@ -26,6 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import ( + "io/ioutil" "compress/gzip" "fmt" "log" @@ -51,11 +52,22 @@ var ( ) func main() { + // Load the version + version, err := ioutil.ReadFile("./VERSION") + if err != nil { + Logger.Fatalln(err) + } + kingpin.Version(string(version)) + // Parse the CLI flags and load the config + kingpin.CommandLine.HelpFlag.Short('h') kingpin.Parse() + + // Load the config config.LoadConfig(*configPath) + config.Version = string(version) // Setup the global variables and settings - err := models.Setup() + err = models.Setup() if err != nil { fmt.Println(err) }