diff --git a/lib/set_MODULES.sh b/lib/set_MODULES.sh new file mode 100644 index 0000000..ca8c258 --- /dev/null +++ b/lib/set_MODULES.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +function set_MODULES () { + # Get the config paths + source "$SCRIPTDIR/lib/paths.sh" + + # Write "/etc/modules" + printf "vfio +vfio_iommu_type1 +vfio_pci ids=$1 +vfio_virqfd +" >> "$SCRIPTDIR/$MODULES" + + # Write "/etc/initramfs-tools/modules" + printf "vfio +vfio_iommu_type1 +vfio_pci +vfio_virqfd +" >> "$SCRIPTDIR/$INITRAMFS/modules" + + # Assign the GPU device ids to a variable + GPU_DEVID="$1" + + # Ask if we shall disable video output on this card + read "Do you want to force disable video output in linux on this card? [Y/n]: " DISABLE_VGA + case "${DISABLE_VGA}" in + [Yy]*) + GPU_DEVID="$GPU_DEVID disable_vga=1" + ;; + [Nn]*) + echo "" + ;; + *) + GPU_DEVID="$GPU_DEVID disable_vga=1" + ;; + esac + + # Write the vfio modprobe config + printf "# This is an autogenerated file that stubs your graphic card for use with vfio +# This file should be placed inside /etc/modprobe.d/ +options vfio_pci ids=$GPU_DEVID +softdep nvidia pre: vfio vfio_pci +softdep nouveau pre: vfio vfio_pci +softdep amdgpu pre: vfio vfio_pci +softdep radeon pre: vfio vfio_pci +" > "$SCRIPTDIR/$MODPROBE/vfio.conf" + + exec "$SCRIPTDIR/lib/get_USB_CTL.sh" +} + + +function main () { + SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//") + SCRIPTDIR="$SCRIPTDIR/.." + set_MODULES $1 +} + +main $1