Created
November 5, 2024 14:33
-
-
Save eznix86/e473ee00d6169102adf04bde680dfbdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export VITO_VERSION="1.x" | |
export DEBIAN_FRONTEND=noninteractive | |
export V_PHP_VERSION="8.2" | |
# Check if running as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
if [[ -z "${V_USERNAME}" ]]; then | |
export V_USERNAME=vito | |
fi | |
echo "Starting complete Vito uninstallation..." | |
# Stop all related services first | |
echo "Stopping services..." | |
supervisorctl stop worker:* | |
service supervisor stop | |
service nginx stop | |
service php${V_PHP_VERSION}-fpm stop | |
# Remove cron jobs | |
echo "Removing cron jobs..." | |
crontab -r -u ${V_USERNAME} | |
# Remove supervisor configurations and logs | |
echo "Removing supervisor configurations..." | |
rm -f /etc/supervisor/conf.d/worker.conf | |
rm -rf /home/${V_USERNAME}/.logs | |
# Remove nginx configurations | |
echo "Removing nginx configurations..." | |
rm -f /etc/nginx/sites-enabled/vito | |
rm -f /etc/nginx/sites-available/vito | |
rm -f /etc/nginx/sites-available/default | |
rm -f /etc/nginx/sites-enabled/default | |
# Remove application files | |
echo "Removing application files..." | |
rm -rf /home/${V_USERNAME}/ | |
# Remove user from sudoers | |
echo "Removing user from sudoers..." | |
sed -i "/${V_USERNAME} ALL=(ALL) NOPASSWD:ALL/d" /etc/sudoers | |
# Remove composer | |
echo "Removing Composer..." | |
rm -f /usr/local/bin/composer | |
rm -f composer-setup.php | |
# Remove PHP and related packages | |
echo "Removing PHP packages..." | |
apt remove --purge -y php${V_PHP_VERSION} php${V_PHP_VERSION}-fpm php${V_PHP_VERSION}-mbstring \ | |
php${V_PHP_VERSION}-mcrypt php${V_PHP_VERSION}-gd php${V_PHP_VERSION}-xml \ | |
php${V_PHP_VERSION}-curl php${V_PHP_VERSION}-gettext php${V_PHP_VERSION}-zip \ | |
php${V_PHP_VERSION}-bcmath php${V_PHP_VERSION}-soap php${V_PHP_VERSION}-redis \ | |
php${V_PHP_VERSION}-sqlite3 php${V_PHP_VERSION}-ssh2 | |
# Remove Ondrej PHP repository | |
echo "Removing PHP repository..." | |
add-apt-repository --remove ppa:ondrej/php -y | |
# Remove packages installed during setup | |
echo "Removing installed packages..." | |
apt remove --purge -y \ | |
needrestart \ | |
software-properties-common \ | |
curl \ | |
zip \ | |
unzip \ | |
git \ | |
gcc \ | |
nginx \ | |
supervisor \ | |
certbot \ | |
python3-certbot-nginx | |
# Remove user account and home directory | |
echo "Removing user account..." | |
pkill -u ${V_USERNAME} # Kill all processes owned by user | |
deluser --remove-home ${V_USERNAME} | |
# Clean up package system | |
echo "Cleaning up..." | |
apt autoremove -y | |
apt clean | |
echo "✅ Vito has been completely uninstalled along with all its dependencies." | |
echo "⚠️ Note: The following items were removed:" | |
echo " - Vito application and all its files" | |
echo " - User ${V_USERNAME} and their home directory" | |
echo " - Nginx and its configurations" | |
echo " - PHP ${V_PHP_VERSION} and all extensions" | |
echo " - Supervisor and worker configurations" | |
echo " - Composer" | |
echo " - All packages installed by the script including:" | |
echo " * needrestart" | |
echo " * software-properties-common" | |
echo " * development tools (git, gcc)" | |
echo " * utilities (curl, zip, unzip)" | |
echo " * web servers and related tools" | |
echo "" | |
echo "⚠️ If any of these packages are needed by other applications, please reinstall them." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment