Skip to content
This repository has been archived by the owner on Feb 27, 2018. It is now read-only.

Commit

Permalink
Merge pull request #193 from michaelneale/master
Browse files Browse the repository at this point in the history
Upgrade the image - preserving machine state
  • Loading branch information
Sven Dowideit authored and Sven Dowideit committed Jul 18, 2014
2 parents a1ed37f + 3ee246e commit b19e4eb
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 b19e4eb

Please sign in to comment.