From 9870b51c268d6c10d7f263426c8e54480ffd7192 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sat, 12 Mar 2022 18:30:59 +0100 Subject: [PATCH] Testing support for mkinitcpio --- lib/set_MKINITCPIO.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 lib/set_MKINITCPIO.sh diff --git a/lib/set_MKINITCPIO.sh b/lib/set_MKINITCPIO.sh new file mode 100755 index 0000000..f4c1f82 --- /dev/null +++ b/lib/set_MKINITCPIO.sh @@ -0,0 +1,25 @@ +#!/bin/bash +function set_MKINITCPIO () { + # Get the config paths + source "$SCRIPTDIR/lib/paths.sh" + + # Grab the current modules but exclude vfio and vendor-reset + CURRENTMODULES=$(grep -P "^MODULES" /etc/mkinitcpio.conf | perl -pe "s/MODULES=\((.+)\)/\1/") + MODULES="$(grep -P "^MODULES" /etc/mkinitcpio.conf | perl -pe "s/MODULES=\((.+)\)/\1/" | perl -pe "s/\s?(vfio_iommu_type1|vfio_pci|vfio_virqfd|vfio|vendor-reset)\s?//g")" + + if [[ $CURRENTMODULES =~ "vendor-reset" ]]; + then + perl -pi -e "s/MODULES=\(${CURRENTMODULES}\)/MODULES=\(vendor-reset vfio vfio_iommu_type1 vfio_pci vfio_virqfd ${MODULES}\)/" "$SCRIPTDIR/$MKINITCPIO" + else + perl -pi -e "s/MODULES=\(${CURRENTMODULES}\)/MODULES=\(vfio vfio_iommu_type1 vfio_pci vfio_virqfd ${MODULES}\)/" "$SCRIPTDIR/$MKINITCPIO" + fi + +} + +function main () { + SCRIPTDIR=$(dirname "$(realpath "$0")" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//") + + set_MKINITCPIO "$1" +} + +main "$1" \ No newline at end of file