test: Add support for non-luks and seprate home

This commit is contained in:
2025-10-11 00:11:13 +02:00
parent 2b0ab9651e
commit e322bf65fc

55
test.sh
View File

@@ -127,6 +127,10 @@ send_mon() {
install_from_iso() { install_from_iso() {
local hostname="${1}" local hostname="${1}"
shift shift
local lukscfg="${1}"
shift
local homecfg="${1}"
shift
local hostqemuopts=("$@") local hostqemuopts=("$@")
rm -rf "${tmpdir:?}"/* rm -rf "${tmpdir:?}"/*
@@ -186,10 +190,23 @@ EOF
mkdir /repo/ mkdir /repo/
mount /dev/disk/by-label/REPO /repo/ mount /dev/disk/by-label/REPO /repo/
printf 'lukspw\nlukspw\nrootpw\nrootpw\n' | \ if [[ "${lukscfg}" == "luks" ]] ; then
/repo/install_scripts/"${hostname}".sh printf 'lukspw\nlukspw\nrootpw\nrootpw\n' | \
/repo/install_scripts/"${hostname}".sh
mount /dev/mapper/vgbase-root /mnt
if [[ "${homecfg}" == "separate" ]] ; then
mount /dev/mapper/vgbase-home /mnt/home
fi
else
printf 'rootpw\nrootpw\n' | \
/repo/install_scripts/"${hostname}".sh
mount /dev/disk/by-partlabel/root /mnt
if [[ "${homecfg}" == "separate" ]] ; then
mount /dev/disk/by-partlabel/home /mnt/home
fi
fi
mount /dev/mapper/vgbase-root /mnt
cat << SPECIALS > /tmp/specials.sh cat << SPECIALS > /tmp/specials.sh
if [[ "\\\$(tty)" == "/dev/tty1" ]] ; then if [[ "\\\$(tty)" == "/dev/tty1" ]] ; then
@@ -209,7 +226,7 @@ SPECIALS
rsync -rl /repo/ /mnt/var/lib/dotfiles/ rsync -rl /repo/ /mnt/var/lib/dotfiles/
umount /mnt umount --recursive /mnt
poweroff poweroff
EOF EOF
@@ -220,6 +237,10 @@ EOF
configure_new_system() { configure_new_system() {
local hostname="${1}" local hostname="${1}"
shift shift
local lukscfg="${1}"
shift
local homecfg="${1}"
shift
local hostqemuopts=("${@}") local hostqemuopts=("${@}")
opts=( opts=(
@@ -231,24 +252,36 @@ configure_new_system() {
qemu-system-x86_64 -name "${hostname}" "${qemuopts[@]}" "${hostqemuopts[@]}" "${opts[@]}" & qemu-system-x86_64 -name "${hostname}" "${qemuopts[@]}" "${hostqemuopts[@]}" "${opts[@]}" &
# 5s for grub timeout, 5s for kernel boot if [[ "${lukscfg}" == "luks" ]] ; then
echo waiting for luks password prompt ... # 5s for grub timeout, 5s for kernel boot
sleep 10s echo waiting for luks password prompt ...
echo 'lukspw' | send_mon "${mon_sock}" sleep 10s
echo 'lukspw' | send_mon "${mon_sock}"
fi
echo waiting for boot ... echo waiting for boot ...
sleep 10s sleep 10s
wait wait
} }
machines=(ares neptune dionysus hera) declare -A machinecfg
machinecfg["ares"]="luks|combined"
machinecfg["neptune"]="luks|combined"
machinecfg["dionysus"]="luks|combined"
machinecfg["hera"]="noluks|separate"
if (($# > 0)); then if (($# > 0)); then
machines=("${@}") machines=("${@}")
else
machines=("${!machinecfg[@]}")
fi fi
download_iso download_iso
for hostname in "${machines[@]}"; do for hostname in "${machines[@]}"; do
IFS='|' read -r -a cfg <<< "${machinecfg[${hostname}]}"
lukscfg="${cfg[0]}"
homecfg="${cfg[1]}"
case "${hostname}" in case "${hostname}" in
ares) ares)
hostqemuopts=( hostqemuopts=(
@@ -284,6 +317,6 @@ for hostname in "${machines[@]}"; do
;; ;;
esac esac
[[ ! "${hostqemuopts[*]}" ]] && exit 1 [[ ! "${hostqemuopts[*]}" ]] && exit 1
install_from_iso "${hostname}" "${hostqemuopts[@]}" install_from_iso "${hostname}" "${lukscfg}" "${homecfg}" "${hostqemuopts[@]}"
configure_new_system "${hostname}" "${hostqemuopts[@]}" configure_new_system "${hostname}" "${lukscfg}" "${homecfg}" "${hostqemuopts[@]}"
done done