`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).
18 lines
345 B
Ruby
Executable File
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
|