diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-25 17:16:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-25 17:16:13 +0200 |
commit | 6aead8d49c6aa020ef6630d25f30df9df1ace5d2 (patch) | |
tree | 48cad6fbfa19e0155c1d90ee452ec56c360ef8d9 /bootstrap | |
parent | 864fc1c2e0597606ec8e2e04ae3150144aa3ed39 (diff) |
Implement buildid monitoring and automatic reboot
Diffstat (limited to 'bootstrap')
-rwxr-xr-x | bootstrap | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -366,6 +366,15 @@ fi # if [ "$stage" -le "5" ]; then + # Generate buildid and store it in /etc/os-release and in buildos-buildid. + # These are used by the monitor to detect when it's time to reboot. + # + # Note that /etc/os-release is a symlink to /usr/lib/os-release. + # + buildid="$(uuidgen)" + + sudo tee -a "$root/etc/os-release" >/dev/null <<<"BUILD_ID=\"$buildid\"" + # Install init and buildos monitor. # sudo install -m 755 ./init "$root/" @@ -379,6 +388,7 @@ if [ "$stage" -le "5" ]; then cd "$root" sudo cpio -o -H newc <<EOF | \ gzip -9 > "$owd/buildos-init.cpio.gz" +usr/lib/os-release init usr/sbin/buildos usr/lib/systemd/system/buildos.service @@ -391,19 +401,19 @@ EOF # Copy the kernel image next to the initramfs for convenience. # cp "$root/vmlinuz" buildos-image + echo "$buildid" >buildos-buildid subvol_snapshot -r "$root" "$root-5" fi # Test. # -# To test PXE boot, replace -kernel/-initrd with '-boot n'. -# - if [ ! -e /tmp/buildos-disk ]; then qemu-img create -f raw /tmp/buildos-disk 100M fi +# To test PXE boot, replace -kernel/-initrd/-append with '-boot n'. +# sudo kvm \ -m 8G \ -device "e1000,netdev=net0,mac=$macaddr" \ @@ -411,5 +421,7 @@ sudo kvm \ -device "virtio-scsi-pci,id=scsi" \ -device "scsi-hd,drive=disk1" \ -drive "if=none,id=disk1,file=/tmp/buildos-disk,format=raw" \ - -kernel buildos-image -initrd buildos-initrd \ - -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build2.org" + -boot n + +# -kernel buildos-image -initrd buildos-initrd \ +# -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build2.org" |