mirror of
https://github.com/theupriser/steamify-cachyos-live-iso.git
synced 2026-10-02 15:10:26 +02:00
🧹 cleanup VM stuff
This commit is contained in:
1 file changed
+15
-90
@@ -1,123 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# grabed from https://github.com/xerolinux/xerolinux_iso
|
|
||||||
#
|
_remove_pacman_package() {
|
||||||
# driver=free or driver=nonfree - grub and efi
|
local _pkgname="$1"
|
||||||
echo "Start cachyos-remove-nvidia"
|
pacman -Rsnc "$_pkgname" --noconfirm || true
|
||||||
kernel_cmdline(){
|
|
||||||
for param in $(cat /proc/cmdline); do
|
|
||||||
case "${param}" in
|
|
||||||
$1=*) echo "${param##*=}"; return 0 ;;
|
|
||||||
"$1") return 0 ;;
|
|
||||||
*) continue ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
[ -n "${2}" ] && echo "${2}"
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_driver(){
|
# remove pkgs installed for VMs
|
||||||
kernel_cmdline driver
|
_clean_vm_packages() {
|
||||||
}
|
|
||||||
|
|
||||||
get_virtmach(){
|
|
||||||
kernel_cmdline virtmach
|
|
||||||
}
|
|
||||||
|
|
||||||
while [ -e "/var/lib/pacman/db.lck" ];
|
|
||||||
do
|
|
||||||
echo 'Pacman is not ready yet. Will try again in 10 seconds.'
|
|
||||||
seconds=$((seconds + 10))
|
|
||||||
sleep 10
|
|
||||||
if [[ "$seconds" == "30" ]]; then
|
|
||||||
echo 'Warning: removing pacman db.lck!'
|
|
||||||
rm /var/lib/pacman/db.lck
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# free = remove nvidia keep nouveau
|
|
||||||
selection=$(get_driver)
|
|
||||||
echo "#################################"
|
|
||||||
echo "Selection was ""$selection"
|
|
||||||
echo "#################################"
|
|
||||||
if [[ $selection == "free" ]]; then
|
|
||||||
pacman -R --noconfirm nvidia-dkms nvidia-utils
|
|
||||||
fi
|
|
||||||
|
|
||||||
#freenonouveau = remove nvidia and nouveau
|
|
||||||
selection=$(get_driver)
|
|
||||||
echo "#################################"
|
|
||||||
echo "Selection was ""$selection"
|
|
||||||
echo "#################################"
|
|
||||||
if [[ $selection == "freenonouveau" ]]; then
|
|
||||||
pacman -R --noconfirm nvidia-dkms nvidia-utils
|
|
||||||
pacman -R --noconfirm xf86-video-nouveau
|
|
||||||
fi
|
|
||||||
|
|
||||||
#nonfree = keepin nvidia and nouveau
|
|
||||||
selection=$(get_driver)
|
|
||||||
echo "Selection was ""$selection"
|
|
||||||
if [[ $selection == "nonfree" ]]; then
|
|
||||||
echo "#################################"
|
|
||||||
echo "We keep nvidia and nouveau onboard"
|
|
||||||
echo "#################################"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# nonfreenonouveau : keep nvidia and remove nouveau
|
|
||||||
selection=$(get_driver)
|
|
||||||
echo "#################################"
|
|
||||||
echo "Selection was ""$selection"
|
|
||||||
echo "#################################"
|
|
||||||
if [[ $selection == "nonfreenonouveau" ]]; then
|
|
||||||
pacman -R --noconfirm xf86-video-nouveau
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove virtual machines
|
|
||||||
selection=$(get_virtmach)
|
|
||||||
echo "#################################"
|
|
||||||
echo "Selection was ""$selection"
|
|
||||||
echo "#################################"
|
|
||||||
if [[ $selection == "none" ]]; then
|
|
||||||
|
|
||||||
#remove virtualbox
|
#remove virtualbox
|
||||||
if pacman -Qi virtualbox-guest-utils &> /dev/null; then
|
if pacman -Qi virtualbox-guest-utils &> /dev/null; then
|
||||||
systemctl disable vboxservice.service
|
systemctl disable vboxservice.service
|
||||||
pacman -Rns virtualbox-guest-utils --noconfirm
|
_remove_pacman_package virtualbox-guest-utils
|
||||||
echo "Removed virtualbox-guest-utils"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then
|
if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then
|
||||||
systemctl disable vboxservice.service
|
systemctl disable vboxservice.service
|
||||||
pacman -Rns virtualbox-guest-utils-nox --noconfirm
|
_remove_pacman_package virtualbox-guest-utils-nox
|
||||||
echo "Removed virtualbox-guest-utils-nox"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#remove vmware
|
#remove vmware
|
||||||
if [ -f /etc/xdg/autostart/vmware-user.desktop ]; then
|
if [ -f /etc/xdg/autostart/vmware-user.desktop ]; then
|
||||||
rm /etc/xdg/autostart/vmware-user.desktop
|
rm /etc/xdg/autostart/vmware-user.desktop
|
||||||
echo "Removed vmware-user.desktop"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if pacman -Qi open-vm-tools &> /dev/null; then
|
if pacman -Qi open-vm-tools &> /dev/null; then
|
||||||
systemctl disable vmtoolsd.service
|
systemctl disable vmtoolsd.service
|
||||||
echo "Disabled vmtoolsd.service"
|
_remove_pacman_package open-vm-tools
|
||||||
pacman -Rns open-vm-tools --noconfirm
|
|
||||||
echo "Removed open-vm-tools"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then
|
if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then
|
||||||
rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service
|
rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service
|
||||||
echo "Removed vmtoolsd.service if still exists"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#remove qemu
|
#remove qemu
|
||||||
if pacman -Qi qemu-guest-agent &> /dev/null; then
|
if pacman -Qi qemu-guest-agent &> /dev/null; then
|
||||||
systemctl disable qemu-guest-agent.service
|
systemctl disable qemu-guest-agent.service
|
||||||
pacman -Rns qemu-guest-agent --noconfirm
|
_remove_pacman_package qemu-guest-agent
|
||||||
echo "Removed qemu-guest-agent"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_check_not_running_vm="$(systemd-detect-virt | grep -q 'none'; echo $?)"
|
||||||
|
if [[ "${_check_not_running_vm}" -eq 0 ]]; then
|
||||||
|
_clean_vm_packages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "#################################"
|
# vim:set ft=bash sw=2 sts=2 et:
|
||||||
echo "End cachyos-remove-nvidia"
|
|
||||||
echo "#################################"
|
|
||||||
Reference in new issue
Block a user