🛠️ build(map): add array to package removal process

This commit is contained in:
Eshan Roy
2024-08-01 04:21:21 +05:30
parent 59ddebc57b
commit 876db49f10

View File

@@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
# set -e
# Author : Eshan Roy <eshan@snigdhaos.or> # Author : Eshan Roy <eshan@snigdhaos.or>
# Author URL : https://eshanized.github.io/ # Author URL : https://eshanized.github.io/
@@ -8,148 +7,45 @@ echo
echo "--->> Start snigdhaos-virtual-machine-check <<---" echo "--->> Start snigdhaos-virtual-machine-check <<---"
echo echo
# Detect virtualization platform
result=$(systemd-detect-virt) result=$(systemd-detect-virt)
# First remove the db.lck # Remove db.lck if it exists
while [ -e "/var/lib/pacman/db.lck" ]; do
while [ -e "/var/lib/pacman/db.lck" ];
do
echo 'Pacman is not ready yet. Trying in 10 Seconds.' echo 'Pacman is not ready yet. Trying in 10 Seconds.'
# shellcheck disable=SC2004
seconds=$(($seconds + 5))
sleep 5 sleep 5
if [[ "$seconds" == "30" ]]; then if [ -e "/var/lib/pacman/db.lck" ]; then
echo "Snigdha OS Removing Pacman db.lck!" echo "Snigdha OS Removing Pacman db.lck!"
rm /var/lib/pacman/db.lck rm /var/lib/pacman/db.lck
fi fi
done done
echo echo
# shellcheck disable=SC2086 echo "You Are On : $result"
echo "You Are On : "$result
echo echo
if [[ $result == "oracle" ]]; then # Define packages to remove for each virtualization platform
# removing pre-installed vmware declare -A packages_to_remove
packages_to_remove[oracle]="open-vm-tools xf86-video-vmware qemu-guest-agent"
packages_to_remove[kvm]="open-vm-tools xf86-video-vmware virtualbox-guest-utils virtualbox-guest-utils-nox"
packages_to_remove[vmware]="virtualbox-guest-utils virtualbox-guest-utils-nox qemu-guest-agent"
packages_to_remove[none]="virtualbox-guest-utils virtualbox-guest-utils-nox qemu-guest-agent open-vm-tools xf86-video-vmware"
# Remove packages and disable services
for package in ${packages_to_remove[$result]}; do
if pacman -Qi $package &> /dev/null; then
systemctl disable $package.service
pacman -Rns $package --noconfirm
echo "[REMOVED] $package"
fi
done
# Remove additional files
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" echo "[REMOVED] vmware-user.desktop"
fi fi
if pacman -Qi open-vm-tools &> /dev/null; then
systemctl disable vmware-vmblock-fuse.service
systemctl disable vmtoolsd.service
echo "[DISABLE] vmtoolsd.service"
pacman -Rns open-vm-tools --noconfirm
echo "[REMOVED] open-vm-tools"
fi
if pacman -Qi xf86-video-vmware &> /dev/null; then
pacman -Rns xf86-video-vmware --noconfirm
echo "[REMOVED] xf86-video-vmware"
fi
if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then
rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service
echo "[REMOVED] vmtoolsd.service"
fi
if pacman -Qi qemu-guest-agent &> /dev/null; then
systemctl disable qemu-guest-agent.service
pacman -Rns qemu-guest-agent --noconfirm
echo "[REMOVED] qemu-guest-agent"
fi
fi
if [ $result == "kvm" ]; then
if [ -f /etc/xdg/autostart/vmware-user.desktop ]; then
rm /etc/xdg/autostart/vmware-user.desktop
echo "[REMOVED] vmware-user.desktop"
fi
if pacman -Qi open-vm-tools &> /dev/null; then
systemctl disable vmware-vmblock-fuse.service
systemctl disable vmtoolsd.service
echo "[DISABLE] vmtoolsd.service"
pacman -Rns open-vm-tools --noconfirm
echo "[REMOVED] open-vm-tools"
fi
if pacman -Qi xf86-video-vmware &> /dev/null; then
pacman -Rns xf86-video-vmware --noconfirm
echo "[REMOVED] xf86-video-vmware"
fi
if pacman -Qi virtualbox-guest-utils &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils --noconfirm
echo "[REMOVED] virtualbox-guest-utils"
fi
if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils-nox --noconfirm
echo "[REMOVED] virtualbox-guest-utils-nox"
fi
fi
if [ $result == "vmware" ]; then
if pacman -Qi virtualbox-guest-utils &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils --noconfirm
echo "[REMOVED] virtualbox-guest-utils"
fi
if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils-nox --noconfirm
echo "[REMOVED] virtualbox-guest-utils-nox"
fi
if pacman -Qi qemu-guest-agent &> /dev/null; then
systemctl disable qemu-guest-agent.service
pacman -Rns qemu-guest-agent --noconfirm
echo "[REMOVED] qemu-guest-agent"
fi
fi
if [ $result == "none" ]; then
if pacman -Qi virtualbox-guest-utils &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils --noconfirm
echo "[REMOVED] virtualbox-guest-utils"
fi
if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then
systemctl disable vboxservice.service
pacman -Rns virtualbox-guest-utils-nox --noconfirm
echo "[REMOVED] virtualbox-guest-utils-nox"
fi
if pacman -Qi qemu-guest-agent &> /dev/null; then
systemctl disable qemu-guest-agent.service
pacman -Rns qemu-guest-agent --noconfirm
echo "[REMOVED] qemu-guest-agent"
fi
if [ -f /etc/xdg/autostart/vmware-user.desktop ]; then
rm /etc/xdg/autostart/vmware-user.desktop
echo "[REMOVED] vmware-user.desktop"
fi
if pacman -Qi open-vm-tools &> /dev/null; then
systemctl disable vmware-vmblock-fuse.service
systemctl disable vmtoolsd.service
echo "[DISABLE] vmtoolsd.service"
pacman -Rns open-vm-tools --noconfirm
echo "[REMOVED] open-vm-tools"
fi
if pacman -Qi xf86-video-vmware &> /dev/null; then
pacman -Rns xf86-video-vmware --noconfirm
echo "[REMOVED] xf86-video-vmware"
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" echo "[REMOVED] vmtoolsd.service"
@@ -164,7 +60,7 @@ if [ $result == "none" ]; then
rm /etc/systemd/system/multi-user.target.wants/virtual-machine-check.service rm /etc/systemd/system/multi-user.target.wants/virtual-machine-check.service
echo "[REMOVED] AVM-Check Script" echo "[REMOVED] AVM-Check Script"
fi fi
fi
echo echo
echo "--->> End snigdhaos-virtual-machine-check <<---" echo "--->> End snigdhaos-virtual-machine-check <<---"
echo echo