Skip to content

Commit 807b493

Browse files
committed
Don't exit if reboot command fails
1 parent 398cc88 commit 807b493

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ func main() {
396396
"apt install -y gawk",
397397
fmt.Sprintf("chmod +x %s", installScriptTarget),
398398
installCommand,
399-
"systemctl reboot",
400399
}
401400
for _, command := range commands {
402401
log.Printf("running command '%s'\n", command)
@@ -421,6 +420,16 @@ func main() {
421420
}
422421
}
423422

423+
// run reboot command
424+
cmd, err := sshClient.Command("reboot now")
425+
if err != nil {
426+
log.Fatalf("error creating goph.Cmd for reboot command: %v\n", err)
427+
}
428+
err = cmd.Run()
429+
if err != nil {
430+
log.Printf("reboot command failed, VM probably rebooted anyways: %v\n", err)
431+
}
432+
424433
log.Println("------")
425434
log.Printf("successfully (re)installed %s, ID: %d IPv4: %s IPv6: %s\n", server.Name, server.ID, server.PublicNet.IPv4.IP.String(), server.PublicNet.IPv6.IP.String())
426435
}

0 commit comments

Comments
 (0)