Split up scripts to reuse parts for other initramfs systems

This commit is contained in:
HikariKnight 2022-03-12 14:39:05 +01:00
parent 9ab572032d
commit 898e1f7347
No known key found for this signature in database
GPG key ID: E8B239063B022F5A
4 changed files with 103 additions and 52 deletions

37
lib/set_MODPROBE.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
function set_MODPROBE () {
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
# Assign the GPU device ids to a variable
GPU_DEVID="$1"
# If VGA is disabled
if grep -q "vfio_pci.disable_vga=1" "$SCRIPTDIR/config/kernel_args" ;
then
# Modify our GPU_DEVID line to containe disable_vga=1
GPU_DEVID="${GPU_DEVID} disable_vga=1"
fi
# 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/
# Uncomment the line below to \"hardcode\" your graphic card to be bound to the vfio-pci driver.
# In most cases this should not be neccessary, it will also prevent you from turning off vfio in the bootloader.
#options vfio_pci ids=%s
# Make sure vfio_pci is loaded before these modules: nvidia, nouveau, amdgpu and radeon
softdep nvidia pre: vfio vfio_pci
softdep nouveau pre: vfio vfio_pci
softdep amdgpu pre: vfio vfio_pci
softdep radeon pre: vfio vfio_pci
" "${GPU_DEVID}" > "$SCRIPTDIR/$MODPROBE/vfio.conf"
}
function main () {
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
set_MODPROBE "$1"
}
main "$1"