Skip to content

Commit

Permalink
Upgrade the image - preserving VM state (restarting if it was running)
Browse files Browse the repository at this point in the history
Machine will be restarted after successful download if necessary.
Docker-DCO-1.1-Signed-off-by: Michael Neale [email protected] (github: michaelneale)
  • Loading branch information
michaelneale committed Jul 16, 2014
1 parent 8dd1935 commit 3ee246e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ nbproject
*.sublime-project
*.sublime-workspace
*.swp
boot2docker-cli
14 changes: 14 additions & 0 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ func cmdPoweroff() int {
return 0
}

// Upgrade the boot2docker iso - preserving server state
func cmdUpgrade() int {
m, err := vbx.GetMachine(B2D.VM)
if err == nil && m.State == vbx.Running {
if cmdDownload() == 0 && cmdStop() == 0 {
return cmdUp()
} else {
return 0
}
} else {
return cmdDownload()
}
}

// Gracefully stop and then start the VM.
func cmdRestart() int {
m, err := vbx.GetMachine(B2D.VM)
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ func config() (*flag.FlagSet, error) {
}

func usageShort() {
errf("Usage: %s [<options>] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|ip|delete|destroy|download|version} [<args>]\n", os.Args[0])

errf("Usage: %s [<options>] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|ip|delete|destroy|download|upgrade|version} [<args>]\n", os.Args[0])
}

func usageLong(flags *flag.FlagSet) {
Expand All @@ -215,6 +214,7 @@ Commands:
ip Display the IP address of the VM's Host-only network.
status Display current state of VM.
download Download boot2docker ISO image.
upgrade Upgrade the boot2docker ISO image (if vm is running it will be stopped and started).
version Display version information.
Options:
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func run() int {
return cmdSSH()
case "ip":
return cmdIP()
case "upgrade":
return cmdUpgrade()
case "version":
outf("Client version: %s\nGit commit: %s\n", Version, GitSHA)
return 0
Expand Down

0 comments on commit 3ee246e

Please sign in to comment.