checking preinit hooks return value, fixing ethernet-dhcp hook for interfaces that are not eth0
This commit is contained in:
parent
bc7a570477
commit
1c59af21a6
@ -3,11 +3,15 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# setup systemd-resolved
|
# setup systemd-resolved
|
||||||
systemctl start systemd-resolved.service
|
systemctl start systemd-resolved.service || return
|
||||||
systemctl enable systemd-resolved.service
|
systemctl enable systemd-resolved.service
|
||||||
ln -sf /var/run/systemd/resolve/resolv.conf /etc/resolv.conf
|
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
|
# setup netctl for ethernet-dhcp
|
||||||
cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/
|
sed "s/eth0/$eth/" /etc/netctl/examples/ethernet-dhcp > /etc/netctl/ethernet-dhcp
|
||||||
netctl start ethernet-dhcp
|
netctl start ethernet-dhcp || return
|
||||||
netctl enable ethernet-dhcp
|
netctl enable ethernet-dhcp
|
||||||
|
@ -193,6 +193,9 @@ main() {
|
|||||||
qemu_args+=("$@")
|
qemu_args+=("$@")
|
||||||
|
|
||||||
(set -x; qemu-system-"$arch" "${qemu_args[@]}")
|
(set -x; qemu-system-"$arch" "${qemu_args[@]}")
|
||||||
|
|
||||||
|
# clean up the terminal, in case SeaBIOS did something weird
|
||||||
|
echo -n "[?7h[0m"
|
||||||
pvm_umount
|
pvm_umount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,9 +193,17 @@ EOF
|
|||||||
# install a boot loader
|
# install a boot loader
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
i686|x86_64)
|
i686|x86_64)
|
||||||
# install grub to the VM
|
# enable serial console
|
||||||
sudo sed -i 's/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0"/' \
|
local field=GRUB_CMDLINE_LINUX_DEFAULT
|
||||||
|
local value="console=tty0 console=ttyS0"
|
||||||
|
sudo sed -i "s/.*$field=.*/$field=\"$value\"/" \
|
||||||
"$workdir"/etc/default/grub || return
|
"$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-install --target=i386-pc "$loopdev" || return
|
||||||
sudo arch-chroot "$workdir" grub-mkconfig -o /boot/grub/grub.cfg || return
|
sudo arch-chroot "$workdir" grub-mkconfig -o /boot/grub/grub.cfg || return
|
||||||
;;
|
;;
|
||||||
@ -248,6 +256,8 @@ done
|
|||||||
rm -rf /root/hooks
|
rm -rf /root/hooks
|
||||||
rm -f /root/hooks.sh
|
rm -f /root/hooks.sh
|
||||||
rm -f /usr/lib/systemd/system/preinit.service
|
rm -f /usr/lib/systemd/system/preinit.service
|
||||||
|
|
||||||
|
echo "preinit hooks successful"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# create a preinit service to run the hooks
|
# create a preinit service to run the hooks
|
||||||
@ -275,14 +285,26 @@ EOF
|
|||||||
|
|
||||||
# boot the machine, and run the preinit scripts
|
# boot the machine, and run the preinit scripts
|
||||||
local qemu_flags=(-no-reboot)
|
local qemu_flags=(-no-reboot)
|
||||||
|
local pvmboot
|
||||||
if [ -f "./src/pvmboot.sh" ]; then
|
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
|
elif type -p pvmboot &>/dev/null; then
|
||||||
DISPLAY='' pvmboot "$file" "${qemu_flags[@]}" || return
|
pvmboot=(pvmboot)
|
||||||
else
|
else
|
||||||
error "%s: pvmboot not available -- unable to run hooks" "$file"
|
error "%s: pvmboot not available -- unable to run hooks" "$file"
|
||||||
return "$EXIT_FAILURE"
|
return "$EXIT_FAILURE"
|
||||||
fi
|
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() {
|
pvm_cleanup() {
|
||||||
|
Loading…
Reference in New Issue
Block a user