Advertisement
vonschutter

vm build function

May 4th, 2021
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1.     count=1
  2.     for i in qemu-utils qemu-tools qemu-kvm qemu-system-x86 virt-install
  3.     do
  4.         write_status "${count}  - Verifying dependencies ( ${i} )..."
  5.         check_dependencies $i &>/dev/null
  6.         count=$((count + 1))
  7.     done
  8.  
  9.     # Lookup specific binaries: use full path since they may just have been added and not in $PATH yet.
  10.     : "${BIN_VIRT_INSTALL:=$(type -p virt-install)}"
  11.     : ${FedoraVersion:="34"}
  12.  
  13.     # Discover if the appropriate VM net interface is (default or br'0 - n')
  14.     VIRT_NET="$(if ls /sys/class/net |grep br |grep -v virbr >/dev/null; then echo "bridge:$(ls /sys/class/net)" |grep br ; else echo default;fi)"
  15.  
  16.        # create image and run installer
  17.        "${BIN_VIRT_INSTALL}" --connect qemu:///system --name VDI_fedora_"${CONFIG}"_"${RANDOM}" \
  18.                --vcpus "${2:-2}" \
  19.                --memory "${3:-2048}" \
  20.                --network "$VIRT_NET" \
  21.                --disk size="${4:-40}" \
  22.         --os-variant="${1:-fedora30}" \
  23.                --initrd-inject="${PRESEED_FILE}" \
  24.         --location="http://www.nic.funet.fi/pub/Linux/INSTALL/fedora/linux/releases/${FedoraVersion}/Everything/x86_64/os/" \
  25.         --extra-args "ks=file:/$(basename $PRESEED_FILE)" \
  26.         --noautoconsole || read -p "An ERROR has occurred. Please press [ENTER] to continue..."
  27.     $RTD_GUI --backtitle "$BRANDING" --title "NOTICE!" --msgbox "The virtual machine is currently being built. You may attach to this server and see the progress at IP: $(hostname -I))" 10 60
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement