From 5160fd50cf2bf09700c20236cac992a7a85fc943 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 28 Mar 2017 16:07:09 -0400 Subject: Use pxelinux "ipappend" option to choose rootfs source This fixes the issue described in the first 'netkeys' commit, where the network would need to be available even when it was not used. The "ipappend" option results in a $BOOTIF variable in the initrd environment. This variable is now used to determine whether to wait on the network for a rootfs & keys, or to wait on the boot device becoming available to determine whether it has the keys. That is, there may or may not be a boot device which may or may not have keys and/or rootfs, but we will always know for sure whether it does, therefore there are no races and no waiting on the network unnecessarily. The qemu.sh script was updated to provide the BOOTIF variable when PXE boot is emulated. --- initramfs-tools/scripts/samizdat | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'initramfs-tools') diff --git a/initramfs-tools/scripts/samizdat b/initramfs-tools/scripts/samizdat index 515b724..a42b321 100644 --- a/initramfs-tools/scripts/samizdat +++ b/initramfs-tools/scripts/samizdat @@ -8,20 +8,29 @@ mountroot() samizdat_install_udev_rules if [ "${nbdroot%%,*}" ]; then - # I guess this isn't getting called otherwise? I don't know why this should - # be necessary, but it is. - sh /scripts/local-top/nbd >/dev/null 2>&1 + (. common.sh + sh /scripts/local-top/nbd >/dev/null 2>&1; + bootdone nbd-script) & fi - if keys_via_network; then - wait_for_gnupghome_tar "$tftp_key_server" + if ! cdrom_has_keys && keys_via_network; then + bootwait nbd-script + wait_for_gnupghome_tar "$tftp_key_server" fi + bootwait samizdat-gpg bootmenu bootwait root-mounted chvt 1 } +cdrom_has_keys() +{ + [ ! "$BOOTIF" ] || return + bootwait samizdat-cdrom + [ -d /cdrom/gnupghome ] +} + # Sets $tftp_key_server or returns false. keys_via_network() { -- cgit v1.2.3