dotfiles/scripts/.local/bin/vfio.sh
the_4n0nym0u53 b9bc23d46e
Shell scripts:
- Improve install script with for loop
- Change hash bangs to /bin/sh because I've symlinked /bin/sh to dash, they should work with bash as well due to POSIX compliance
2022-01-08 16:24:17 +01:00

37 lines
946 B
Bash
Executable file

#!/bin/sh
if [ $(id -u) -ne 0 ]; then
echo "This script must be run as root. Quitting..."
exit 1
fi
if [ "$1" = "on" ]; then
if grep "#MODULES=()" /etc/mkinitcpio.conf > /dev/null; then
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
if grep "#MODULES=(vfio" /etc/mkinitcpio.conf > /dev/null; then
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
echo "Regenerating initramfs..."
mkinitcpio -P
echo "Done!"