2023-02-23 14:28:47 +00:00
|
|
|
#!/bin/sh
|
2023-06-30 19:09:34 +00:00
|
|
|
if [ $(id -u) -eq 0 ]
|
|
|
|
then
|
|
|
|
_acp_vm_root=/srv/virt/images
|
|
|
|
_acp_vm_session=qemu:///system
|
|
|
|
else
|
2023-09-21 13:50:08 +00:00
|
|
|
_acp_vm_root="$HOME/data/virt/images"
|
2023-06-30 19:09:34 +00:00
|
|
|
_acp_vm_session=qemu:///session
|
|
|
|
fi
|
2023-02-23 14:33:20 +00:00
|
|
|
_acp_vm_name=${1:---help}
|
2023-08-12 00:08:32 +00:00
|
|
|
_acp_vm_distro=$(. /etc/os-release; echo $ID)
|
2023-02-23 14:28:47 +00:00
|
|
|
|
2023-02-23 14:35:06 +00:00
|
|
|
case "$_acp_vm_name" in
|
2023-02-23 14:28:47 +00:00
|
|
|
"--help" | -*)
|
|
|
|
echo "Usage: virtinst vmname --cdrom install.iso [other virt-install options]" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Create the directory if it doesn't exist already.
|
|
|
|
if ! [ -d "$_acp_vm_root" ]
|
|
|
|
then
|
|
|
|
mkdir -p "$_acp_vm_root"
|
|
|
|
fi
|
|
|
|
|
2023-08-12 00:08:32 +00:00
|
|
|
case "$_acp_vm_distro" in
|
|
|
|
"debian")
|
|
|
|
_acp_vm_boot=loader=/usr/share/OVMF/OVMF_CODE.fd,loader.readonly=yes,loader.type=pflash,nvram.template=/usr/share/OVMF/OVMF_VARS.fd,loader_secure=no
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_acp_vm_boot=uefi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-12-10 21:17:26 +00:00
|
|
|
if [ -r "$_acp_vm_root/$_acp_vm_name.raw" ]
|
|
|
|
then
|
|
|
|
_acp_vm_disk=$_acp_vm_root/$_acp_vm_name.raw
|
|
|
|
else
|
|
|
|
_acp_vm_disk=$_acp_vm_root/$_acp_vm_name.qcow2
|
|
|
|
fi
|
|
|
|
|
2023-06-30 19:09:34 +00:00
|
|
|
# To get a list of valid osinfo options, run:
|
|
|
|
# virt-install --osinfo list
|
2023-02-23 14:28:47 +00:00
|
|
|
virt-install --connect $_acp_vm_session \
|
2023-06-30 19:09:34 +00:00
|
|
|
--osinfo linux2022 \
|
2023-08-12 00:08:32 +00:00
|
|
|
--boot $_acp_vm_boot \
|
2023-02-23 14:28:47 +00:00
|
|
|
--cpu host-passthrough \
|
2023-12-10 21:17:26 +00:00
|
|
|
--disk "$_acp_vm_disk,size=20" \
|
2023-02-23 14:28:47 +00:00
|
|
|
--graphics vnc \
|
|
|
|
--console pty,target.type=virtio \
|
2023-09-25 19:22:51 +00:00
|
|
|
--serial pty \
|
2023-02-23 14:28:47 +00:00
|
|
|
--channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \
|
|
|
|
--video virtio \
|
|
|
|
--autoconsole none \
|
|
|
|
--name "$@"
|