41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
trap 'exit 130' INT
|
|
|
|
# Confirmation prompt
|
|
while true; do
|
|
read -r -p "Would you like to uninstall phpMyAdmin? [Y/n] " input
|
|
|
|
case $input in
|
|
[yY][eE][sS]|[yY])
|
|
break
|
|
;;
|
|
[nN][oO]|[nN])
|
|
echo "phpMyAdmin uninstallation aborted."
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "That wasn't an option..."
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Uninstallation
|
|
if [ -n "$(dpkg --get-selections | grep apache)" ]; then
|
|
sudo apt remove phpmyadmin -y
|
|
sudo apt-get autoremove -y
|
|
sudo rm -rf /usr/share/phpmyadmin/
|
|
sudo rm -rf /etc/apache2/sites-enabled/phpmyadmin.conf
|
|
sudo systemctl restart apache2
|
|
elif [ -n "$(dpkg --get-selections | grep nginx)" ]; then
|
|
sudo apt remove phpmyadmin -y
|
|
sudo apt-get autoremove -y
|
|
sudo rm -rf /usr/share/phpmyadmin/
|
|
sudo rm -rf /etc/nginx/conf.d/phpmyadmin.conf
|
|
sudo systemctl restart nginx
|
|
else
|
|
echo "Neither Apache nor Nginx is installed. Cannot uninstall phpMyAdmin."
|
|
exit 1
|
|
fi
|
|
|
|
echo "phpMyAdmin has been successfully uninstalled."
|