diff --git a/src/hooks/hook-ethernet-dhcp.sh b/src/hooks/hook-ethernet-dhcp.sh index 8ecf948..8af9661 100644 --- a/src/hooks/hook-ethernet-dhcp.sh +++ b/src/hooks/hook-ethernet-dhcp.sh @@ -3,11 +3,15 @@ set -e # setup systemd-resolved -systemctl start systemd-resolved.service +systemctl start systemd-resolved.service || return systemctl enable systemd-resolved.service ln -sf /var/run/systemd/resolve/resolv.conf /etc/resolv.conf +# determine first ethernet device +eth="$(basename "$(find /sys/class/net/ -mindepth 1 -maxdepth 1 -iname 'e*' | head -n1)")" +[ -n "$eth" ] || eth="eth0" + # setup netctl for ethernet-dhcp -cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/ -netctl start ethernet-dhcp +sed "s/eth0/$eth/" /etc/netctl/examples/ethernet-dhcp > /etc/netctl/ethernet-dhcp +netctl start ethernet-dhcp || return netctl enable ethernet-dhcp diff --git a/src/pvmboot.sh b/src/pvmboot.sh index aaa4aeb..0c89e37 100644 --- a/src/pvmboot.sh +++ b/src/pvmboot.sh @@ -193,6 +193,9 @@ main() { qemu_args+=("$@") (set -x; qemu-system-"$arch" "${qemu_args[@]}") + + # clean up the terminal, in case SeaBIOS did something weird + echo -n "[?7h" pvm_umount } diff --git a/src/pvmbootstrap.sh b/src/pvmbootstrap.sh index 4993e8a..b964ef3 100644 --- a/src/pvmbootstrap.sh +++ b/src/pvmbootstrap.sh @@ -193,9 +193,17 @@ EOF # install a boot loader case "$arch" in i686|x86_64) - # install grub to the VM - sudo sed -i 's/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0"/' \ + # enable serial console + local field=GRUB_CMDLINE_LINUX_DEFAULT + local value="console=tty0 console=ttyS0" + sudo sed -i "s/.*$field=.*/$field=\"$value\"/" \ "$workdir"/etc/default/grub || return + # disable boot menu timeout + local field=GRUB_TIMEOUT + local value=0 + sudo sed -i "s/.*$field=.*/$field=$value/" \ + "$workdir"/etc/default/grub || return + # install grub to the VM sudo arch-chroot "$workdir" grub-install --target=i386-pc "$loopdev" || return sudo arch-chroot "$workdir" grub-mkconfig -o /boot/grub/grub.cfg || return ;; @@ -248,6 +256,8 @@ done rm -rf /root/hooks rm -f /root/hooks.sh rm -f /usr/lib/systemd/system/preinit.service + +echo "preinit hooks successful" EOF # create a preinit service to run the hooks @@ -275,14 +285,26 @@ EOF # boot the machine, and run the preinit scripts local qemu_flags=(-no-reboot) + local pvmboot if [ -f "./src/pvmboot.sh" ]; then - DISPLAY='' bash ./src/pvmboot.sh "$file" "${qemu_flags[@]}" || return + pvmboot=(bash ./src/pvmboot.sh) elif type -p pvmboot &>/dev/null; then - DISPLAY='' pvmboot "$file" "${qemu_flags[@]}" || return + pvmboot=(pvmboot) else error "%s: pvmboot not available -- unable to run hooks" "$file" return "$EXIT_FAILURE" fi + + exec 3>&1 + DISPLAY='' "${pvmboot[@]}" "$file" "${qemu_flags[@]}" \ + | tee /dev/fd/3 | grep -q "preinit hooks successful" + local res=$? + exec 3>&- + + if [ "$res" -ne 0 ]; then + error "%s: failed to complete preinit hooks" "$file" + return "$res" + fi } pvm_cleanup() {