add directory paths into a config file

This commit is contained in:
HikariKnight 2022-02-27 17:18:59 +01:00
parent 3b6f09ab59
commit 6b773a22e2
No known key found for this signature in database
GPG key ID: E8B239063B022F5A
4 changed files with 74 additions and 16 deletions

View file

@ -2,6 +2,9 @@
function get_GROUP () {
clear
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
printf "
For this card to be passthrough-able, it must contain only:
* The GPU/Graphic card
@ -27,18 +30,18 @@ read -p "Enter the ids for all devices you want to passthrough: " GPU_DEVID
if [[ $GPU_DEVID =~ : ]];
then
# Make the directory
mkdir "$SCRIPTDIR/config"
# Get the PCI ids
PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
echo "# This is an autogenerated file that stubs your graphic card for use with vfio" > "$SCRIPTDIR/config/vfio.conf"
echo "options vfio_pci ids=$GPU_DEVID" >> "$SCRIPTDIR/config/vfio.conf"
echo "GPU_PCI_ID=($PCI_ID)" > "$SCRIPTDIR/config/qemu-vfio_vars.conf"
echo "USB_CTL_ID=\"\"" >> "$SCRIPTDIR/config/qemu-vfio_vars.conf"
local PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
# Write the currently unused vfio config for quickemu
printf "GPU_PCI_ID=($PCI_ID)
USB_CTL_ID=\"\"" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
# Get the PCI_ID
local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID
else
exec "$SCRIPTDIR/lib/get_GPU.sh"
fi
@ -46,8 +49,9 @@ fi
}
function main () {
SCRIPTDIR=$(dirname `which $0`)
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//")
SCRIPTDIR="$SCRIPTDIR/.."
get_GROUP $1
}

View file

@ -2,6 +2,9 @@
function get_USB_CTL_GROUP () {
clear
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
printf "
For this USB controller device to be passthrough-able, it must be the ONLY device in this group!
@ -23,7 +26,7 @@ then
# Get the PCI ids
PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4)
exec perl -pi -e "s/USB_CTL_ID=\"\"/USB_CTL_ID=\"$PCI_ID\"/" "$SCRIPTDIR/config/qemu-vfio_vars.conf"
exec perl -pi -e "s/USB_CTL_ID=\"\"/USB_CTL_ID=\"$PCI_ID\"/" "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
else
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
fi
@ -31,8 +34,9 @@ fi
}
function main () {
SCRIPTDIR=$(dirname `which $0`)
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//")
SCRIPTDIR="$SCRIPTDIR/.."
get_USB_CTL_GROUP $1
}

6
lib/paths.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/bash
MODPROBE="config/etc/modprobe.d"
INITRAMFS="config/etc/initramfs-tools"
MODULES="config/etc/modules"
DEFAULT="config/etc/default"
QUICKEMU="config/quickemu"