Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cmd/machine-config-daemon/pivot.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func run(_ *cobra.Command, args []string) error {
flag.Set("logtostderr", "true")
flag.Parse()

glog.Info("pivot starting")

var container string
if fromEtcPullSpec || len(args) == 0 {
fromEtcPullSpec = true
Expand Down Expand Up @@ -235,25 +237,33 @@ func run(_ *cobra.Command, args []string) error {
return nil
}

rebootRequest := ""
if reboot {
glog.Infof("Rebooting as requested by cmdline flag")
rebootRequest = "Rebooting as requested by cmdline flag"
} else {
// Otherwise see if it's specified by the file
_, err = os.Stat(runPivotRebootFile)
if err != nil && !os.IsNotExist(err) {
return errors.Wrapf(err, "Checking %s", runPivotRebootFile)
}
if err == nil {
glog.Infof("Rebooting due to %s", runPivotRebootFile)
reboot = true
rebootRequest = fmt.Sprintf("Rebooting due to %s", runPivotRebootFile)
}
}
if reboot {
if rebootRequest != "" {
glog.Infof("%s", rebootRequest)
logger := exec.Command("logger")
logger.Stdin = strings.NewReader(rebootRequest)
if err := logger.Run(); err != nil {
glog.Errorf("failed to invoke logger: %v", err)
}
// Reboot the machine if asked to do so
err := exec.Command("systemctl", "reboot").Run()
if err != nil {
return errors.Wrapf(err, "rebooting")
}
} else {
glog.Info("Operation complete; no reboot requested")
}
return nil
}
Expand Down