diff --git a/gophish.go b/gophish.go index 08a1a83f..71ae7e8c 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 ( + "fmt" "io/ioutil" "os" "os/signal" @@ -40,9 +41,17 @@ import ( "github.com/gophish/gophish/models" ) +const ( + modeAll string = "all" + modeAdmin string = "admin" + modePhish string = "phish" +) + var ( configPath = kingpin.Flag("config", "Location of config.json.").Default("./config.json").String() disableMailer = kingpin.Flag("disable-mailer", "Disable the mailer (for use with multi-system deployments)").Bool() + mode = kingpin.Flag("mode", fmt.Sprintf("Run the binary in one of the modes (%s, %s or %s)", modeAll, modeAdmin, modePhish)). + Default("all").Enum(modeAll, modeAdmin, modePhish) ) func main() { @@ -102,18 +111,25 @@ func main() { phishServer := controllers.NewPhishingServer(phishConfig) imapMonitor := imap.NewMonitor() - - go adminServer.Start() - go phishServer.Start() - go imapMonitor.Start() + if *mode == "admin" || *mode == "all" { + go adminServer.Start() + go imapMonitor.Start() + } + if *mode == "phish" || *mode == "all" { + go phishServer.Start() + } // Handle graceful shutdown c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c log.Info("CTRL+C Received... Gracefully shutting down servers") - adminServer.Shutdown() - phishServer.Shutdown() - imapMonitor.Shutdown() + if *mode == modeAdmin || *mode == modeAll { + adminServer.Shutdown() + imapMonitor.Shutdown() + } + if *mode == modePhish || *mode == modeAll { + phishServer.Shutdown() + } }