mirror of
https://github.com/rancher/os.git
synced 2025-08-01 06:59:05 +00:00
Add flag to not reboot after OS upgrade
This commit is contained in:
parent
45d9c54b9a
commit
420d3290c8
@ -44,6 +44,10 @@ func osSubcommands() []cli.Command {
|
||||
Name: "force, f",
|
||||
Usage: "do not prompt for input",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-reboot",
|
||||
Usage: "do not reboot after upgrade",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -140,7 +144,7 @@ func osUpgrade(c *cli.Context) {
|
||||
log.Fatal("Failed to find latest image")
|
||||
}
|
||||
}
|
||||
startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"))
|
||||
startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot"))
|
||||
}
|
||||
|
||||
func osVersion(c *cli.Context) {
|
||||
@ -157,7 +161,7 @@ func yes(in *bufio.Reader, question string) bool {
|
||||
return strings.ToLower(line[0:1]) == "y"
|
||||
}
|
||||
|
||||
func startUpgradeContainer(image string, stage, force bool) {
|
||||
func startUpgradeContainer(image string, stage, force, reboot bool) {
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
|
||||
container := docker.NewContainer(config.DOCKER_SYSTEM_HOST, &config.ContainerConfig{
|
||||
@ -215,7 +219,7 @@ func startUpgradeContainer(image string, stage, force bool) {
|
||||
}
|
||||
|
||||
if exit == 0 {
|
||||
if force || yes(in, "Continue with reboot") {
|
||||
if reboot && (force || yes(in, "Continue with reboot")) {
|
||||
log.Info("Rebooting")
|
||||
power.Reboot()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user