Shell script for automation, working on it

pull/15/head
QaidVoid 4 years ago
parent 5c5ae77e2f
commit b5f1b09445

@ -1,14 +1,14 @@
## Automated Setup
###### Not well-tested. Only supports systemd init system. Installs packages, enables iommu and creates libvirt hooks for now.
###### Halted till December.
###### TODO: upstart, openrc, sysv support. Automatic VM creation and passthrough support. Libvirt script for window managers.
```sh
make
sudo ./passthrough
###### UNTESTED.. DO NOT USE...
###### FEATURES: Enable IOMMU, Copy Libvirt scripts from scripts folder to libvirt hooks path..
##### TODO: EVERYTHING
OR
##### Replace win10 to your domain name for VM..
##### Configure scripts/qemu.d/win10/prepare/begin/begin.sh
##### Configure scripts/qemu.d/win10/release/end/end.sh
sudo make run
```sh
sudo ./setup.sh
```
## Manual Setup
@ -42,7 +42,7 @@ sudo make run
<summary><b>Install required tools</b></summary>
```sh
sudo pacman -S qemu libvirt edk2-ovmf virt-manager dnsmasq ebtables iptables
sudo pacman -S qemu libvirt edk2-ovmf virt-manager dnsmasq ebtables
```
</details>
@ -257,4 +257,4 @@ sudo make run
> [Single GPU Passthrough by joeknock90](https://github.com/joeknock90/Single-GPU-Passthrough)<br/>
> [Single GPU Passthrough by YuriAlek](https://gitlab.com/YuriAlek/vfio)<br/>
> [ArchLinux PCI Passthrough](https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF)<br/>
> [Gentoo GPU Passthrough](https://wiki.gentoo.org/wiki/GPU_passthrough_with_libvirt_qemu_kvm)<br/>
> [Gentoo GPU Passthrough](https://wiki.gentoo.org/wiki/GPU_passthrough_with_libvirt_qemu_kvm)<br/>

@ -0,0 +1,3 @@
KEYTWO="val1 val2 val3"
KEYTHREE="val1 val2 val3"
GRUB_CMDLINE_LINUX_DEFAULT="val1 val2 val3val4 val4"

@ -0,0 +1,19 @@
#!/bin/bash
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
MISC="${@:4}"
BASEDIR="$(dirname $0)"
HOOKPATH="$BASEDIR/qemu.d/$GUEST_NAME/$HOOK_NAME/$STATE_NAME"
set -e # If a script exits with an error, we should as well.
if [ -f "$HOOKPATH" ]; then
eval \""$HOOKPATH"\" "$@"
elif [ -d "$HOOKPATH" ]; then
while read file; do
eval \""$file"\" "$@"
done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)"
fi

@ -0,0 +1,22 @@
#!/bin/bash
set -x
# Stop display manager
systemctl stop display-manager
# Unbind EFI Framebuffer
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
# Unload NVIDIA kernel modules
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
# Unload AMD kernel module
# modprobe -r amdgpu
# Detach GPU devices from host
# Use your GPU and HDMI Audio PCI host device
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1
# Load vfio module
modprobe vfio-pci

@ -0,0 +1,25 @@
#!/bin/bash
set -x
# Unload vfio module
modprobe -r vfio-pci
# Attach GPU devices to host
# Use your GPU and HDMI Audio PCI host device
virsh nodedev-reattach pci_0000_01_00_0
virsh nodedev-reattach pci_0000_01_00_1
# Rebind framebuffer to host
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
# Load NVIDIA kernel modules
modprobe nvidia_drm
modprobe nvidia_modeset
modprobe nvidia_uvm
modprobe nvidia
# Load AMD kernel module
# modprobe amdgpu
# Restart Display Manager
systemctl start display-manager

@ -0,0 +1,33 @@
if [[ -z lspcu | grep Virtualization ]]; then
echo "ERROR: Virtualization isn't supported in this system"
exit 1
fi
if [[ -z dmesg | grep 'IOMMU enabled' ]]; then
echo "IOMMU isn't enabled. Enabling IOMMU... "
if [[ -f /boot/grub/grub.cfg ]]; then
echo "Loading GRUB configuration.. "
config=/etc/default/grub
if [[ lscpu | grep GenuineIntel ]]; then
if [[ -z sed -n 's/^GRUB_CMDLINE_LINUX_DEFAULT=//p' $config | grep intel_iommu=on ]]; then
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/GRUB_CMDLINE_LINUX_DEFAULT="\1 intel_iommu=on"/' $config
fi
else
if [[ -z sed -n 's/^GRUB_CMDLINE_LINUX_DEFAULT=//p' $config | grep amd_iommu=on ]]; then
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/GRUB_CMDLINE_LINUX_DEFAULT="\1 amd_iommu=on"/' $config
fi
elif [[ -f /boot/loader/loader.conf ]]; then
echo "Loading systemd-boot configuration... "
echo "Add intel_iommu=on or amd_iommu=on depending on your CPU to options in boot entry.."
# TODO
fi
echo "IOMMU enabled.."
echo "Please reboot your system to continue.."
exit 1
fi
echo "COPYING LIBVIRT SCRIPTS"
cp scripts/* /etc/libvirt/hooks/
echo "CONFIGURATION FINISHED.."
# TODO MORE OPTIONS
Loading…
Cancel
Save