diff --git a/cmd/main.go b/cmd/main.go index 313dfcb..4b050fb 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -51,7 +51,6 @@ func main() { app.Commands = []cli.Command{} app.Commands = append(app.Commands, (&commands.Start{}).Commands()...) app.Commands = append(app.Commands, (&commands.Stop{}).Commands()...) - app.Commands = append(app.Commands, (&commands.Restart{}).Commands()...) app.Commands = append(app.Commands, (&commands.Upgrade{}).Commands()...) app.Commands = append(app.Commands, (&commands.Status{}).Commands()...) app.Commands = append(app.Commands, (&commands.Config{}).Commands()...) diff --git a/commands/restart.go b/commands/restart.go deleted file mode 100644 index 3e9f238..0000000 --- a/commands/restart.go +++ /dev/null @@ -1,53 +0,0 @@ -package commands - -import ( - "fmt" - "time" - - "github.com/phase2/rig/util" - "github.com/urfave/cli" -) - -// Restart is the command for shutting down and starting a Docker Machine -type Restart struct { - BaseCommand -} - -// Commands returns the operations supported by this command -func (cmd *Restart) Commands() []cli.Command { - return []cli.Command{ - { - Name: "restart", - Usage: "Restart the docker-machine", - Before: cmd.Before, - Action: cmd.Run, - }, - } -} - -// Run executes the `rig restart` command -func (cmd *Restart) Run(c *cli.Context) error { - if util.SupportsNativeDocker() || cmd.machine.Exists() { - if util.SupportsNativeDocker() { - cmd.out.Spin("Restarting Outrigger services") - } else { - cmd.out.Spin(fmt.Sprintf("Restarting Outrigger machine '%s' and services", cmd.machine.Name)) - } - - stop := Stop{cmd.BaseCommand} - if err := stop.Run(c); err != nil { - return err - } - - time.Sleep(time.Duration(5) * time.Second) - - start := Start{cmd.BaseCommand} - if err := start.Run(c); err != nil { - return err - } - } else { - return cmd.Failure(fmt.Sprintf("No machine named '%s' exists.", cmd.machine.Name), "MACHINE-NOT-FOUND", 12) - } - - return cmd.Success("Restart successful") -} diff --git a/commands/start.go b/commands/start.go index 34a66a2..7a15271 100644 --- a/commands/start.go +++ b/commands/start.go @@ -99,9 +99,6 @@ func (cmd *Start) Run(c *cli.Context) error { cmd.machine.SetEnv() cmd.out.Info("Docker Machine (%s) Created", cmd.machine.Name) - dns := DNS{cmd.BaseCommand} - dns.StartDNS(cmd.machine, c.String("nameservers")) // nolint: gosec - // NFS mounts are Mac-only. if util.IsMac() { cmd.out.Spin("Enabling NFS file sharing...") @@ -138,8 +135,15 @@ func (cmd *Start) Run(c *cli.Context) error { } cmd.out.Info("/data filesystem is ready") - // Route configuration needs to be finalized after NFS-triggered reboots. + // When the Docker daemon runs inside boot2docker, it disables packet forwarding to containers + // we need to turn this back on. + // Reference: https://github.com/boot2docker/boot2docker/issues/1364 + util.Command("docker-machine", "ssh", cmd.machine.Name, "sudo iptables -P FORWARD ACCEPT").Run() + + // DNS & Route configuration needs to be finalized after NFS-triggered reboots. // This rebooting may change key details such as IP Address of the Dev machine. + dns := DNS{cmd.BaseCommand} + dns.StartDNS(cmd.machine, c.String("nameservers")) // nolint: gosec dns.ConfigureRoutes(cmd.machine) cmd.out.Verbose("Use docker-machine to interact with your virtual machine.") diff --git a/gometalinter.json b/gometalinter.json index 6ef0f4b..297203f 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -1,3 +1,6 @@ { - "Disable": ["errcheck"] + "Disable": ["errcheck"], + "Linters": { + "gosec": { "Command": "gosec -exclude=G104" } + } } \ No newline at end of file