From 1e91e30a3f909410cf0f10880f763f2f4767420e Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" Date: Sun, 4 Feb 2024 10:07:45 +0100 Subject: [PATCH] Add RAM option to allow exploring DHCP. --- roles/lmn_vm/files/vm-netboot | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/roles/lmn_vm/files/vm-netboot b/roles/lmn_vm/files/vm-netboot index 723b366..35549ba 100755 --- a/roles/lmn_vm/files/vm-netboot +++ b/roles/lmn_vm/files/vm-netboot @@ -4,18 +4,15 @@ # set -eu -menu=(standard "CLI Standard Debian GNU/Linux" - kde-desktop "KDE Plasma Desktop Debian GNU/Linux" - gnome-desktop "Gnome Desktop Debian GNU/Linux") +menu=(standard "CLI Standard Debian GNU/Linux NFS" + standard-ram "CLI Standard Debian GNU/Linux RAM" + kde-desktop "KDE Plasma Desktop Debian GNU/Linux NFS" + gnome-desktop "Gnome Desktop Debian GNU/Linux NFS") img=$(dialog --clear --backtitle "Virtual Machine Chooser" \ --title "Choose the Virtual Machine to Start" \ - --menu "Start VM:" 12 60 6 \ - "${menu[@]}" 2>&1 >/dev/tty) + --menu "Start VM:" 12 70 6 "${menu[@]}" 2>&1 >/dev/tty) -if [[ -z $img ]] ; then - echo "Starting VM canceled." - exit 1 -fi +## If the menu is canceled, $0 stops here because of set -e mac="$(ip link | grep -A1 "vm-macvtap" | \ sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")" @@ -31,24 +28,27 @@ fi kernel="http://livebox/d-i/n-live/$img/live/vmlinuz" initrd="http://livebox/d-i/n-live/$img/live/initrd.img" -kargs=(boot=live components splash locales=de_DE.UTF-8 keyboard-layouts=de \ - swap=true live-config.timezone=Europe/Berlin netboot=nfs \ - "nfsroot=10.190.1.2:/srv/nfs/debian-live/$img/") +kargs=(boot=live components splash locales=de_DE.UTF-8 keyboard-layouts=de + swap=true live-config.timezone=Europe/Berlin) + +case "$img" in + standard*) + arg+=(--autoconsole=text) + kargs+=(console=ttyS0) + ;;& + *-ram) + kargs+=("fetch=http://10.190.1.2/d-i/n-live/${img%-ram}/live/filesystem.squashfs") + ;; + *) + kargs+=(netboot=nfs "nfsroot=10.190.1.2:/srv/nfs/debian-live/$img/") + ;; +esac type="ethernet,mac=${mac},target.dev=vm-macvtap,xpath1.set=./target/@managed=no" ## FIXME: use passt, needs more settings for correct DNS/gateway # type=user,xpath1.create=./backend,xpath2.set=./backend/@type=passt,xpath3.create=./ip,xpath4.set=./ip/@family=ipv4,xpath5.set=./ip/@address=172.16.1.1,xpath6.set=./ip/@prefix=24,xpath7.create=./portForward,xpath8.set=./portForward/@proto=tcp,xpath9.set=./portForward/range/@start=2001,xpath10.set=./portForward/range/@end=2500,xpath11.set=./portForward/range/@to=1 -case "$img" in - standard) - arg+=("--autoconsole=text") - kargs+=("console=ttyS0") - ;; - *) - ;; -esac - http_proxy='' XDG_CONFIG_HOME="/tmp/${UID}/.config" \ exec virt-install \ --name "$img" \