2022-01-08 15:24:17 +00:00
|
|
|
#!/bin/sh
|
2021-12-28 17:03:43 +00:00
|
|
|
|
2022-01-08 16:56:42 +00:00
|
|
|
if [ "$(lsb_release -si)" = "Arch" ] || [ "$(lsb_release -si)" = "Artix" ]; then
|
|
|
|
echo "This script must be run on either Arch Linux or Artix Linux. Quitting..."
|
|
|
|
fi
|
|
|
|
|
2022-01-02 23:39:35 +00:00
|
|
|
if [ $(id -u) -ne 0 ]; then
|
2021-12-28 17:03:43 +00:00
|
|
|
echo "This script must be run as root. Quitting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "on" ]; then
|
2022-01-02 23:39:35 +00:00
|
|
|
if grep "#MODULES=()" /etc/mkinitcpio.conf > /dev/null; then
|
2021-12-28 17:03:43 +00:00
|
|
|
echo "VFIO is already enabled. Quitting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Enabling VFIO..."
|
|
|
|
sed -i 's/MODULES=()/#MODULES=()/g' /etc/mkinitcpio.conf
|
|
|
|
sed -i 's/#MODULES=(vfio/MODULES=(vfio/g' /etc/mkinitcpio.conf
|
|
|
|
elif [ "$1" = "off" ]; then
|
2022-01-02 23:39:35 +00:00
|
|
|
if grep "#MODULES=(vfio" /etc/mkinitcpio.conf > /dev/null; then
|
2021-12-28 17:03:43 +00:00
|
|
|
echo "VFIO is already disabled. Quitting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Disabling VFIO..."
|
|
|
|
sed -i 's/#MODULES=()/MODULES=()/g' /etc/mkinitcpio.conf
|
|
|
|
sed -i 's/MODULES=(vfio/#MODULES=(vfio/g' /etc/mkinitcpio.conf
|
|
|
|
else
|
|
|
|
echo "Please run with either 'on' or 'off' as command line argument. Quitting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 0.5
|
|
|
|
|
2022-01-02 23:39:35 +00:00
|
|
|
echo "Regenerating initramfs..."
|
2021-12-28 17:03:43 +00:00
|
|
|
mkinitcpio -P
|
|
|
|
|
|
|
|
echo "Done!"
|