Files
ubicloud/rhizome/host/bin/reboot-host
Hadi Moshayedi 4c6ba79908 Add a binary in rhizome to reboot host.
`rhizome/host/bin/reboot-host` takes a boot id as an argument and if
matches the current boot id, then issues a reboot. Otherwise it prints
the current boot id to stdout.

This will be used by the control plane in a loop which will send reboot
messages to rhizome until we are sure reboot succeeded (i.e boot id
changed).
2023-10-03 12:48:52 -07:00

18 lines
345 B
Ruby
Executable File

#!/bin/env ruby
# frozen_string_literal: true
require_relative "../../common/lib/util"
unless (previous_boot_id = ARGV.shift)
puts "expected previous_boot_id as argument"
exit 1
end
boot_id = File.read("/proc/sys/kernel/random/boot_id").strip
if boot_id == previous_boot_id
r("sudo systemctl reboot")
else
$stdout.write(boot_id)
end