I make a Proper hestia Uninstall script, and it works.
uninstall.sh
Create uninstall script manually
cat > /tmp/uninstall.sh << ‘EOF’
#!/bin/bash
Hestia Control Panel uninstall script
For full documentation, please visit: https://docs.hestiacp.com/
Check root permissions
if [ “$EUID” -ne 0 ]; then
echo “Please run as root”
exit 1
fi
Source hestia.conf if exists
if [ -f /usr/local/hestia/conf/hestia.conf ]; then
source /usr/local/hestia/conf/hestia.conf
fi
Set default values
VERSION=“1.8.5”
HESTIA=“/usr/local/hestia”
HESTIA_DATA_DIR=“/usr/local/hestia/data”
Colors
RED=‘\033[0;31m’
GREEN=‘\033[0;32m’
YELLOW=‘\033[0;33m’
NC=‘\033[0m’ # No Color
Functions
log() {
echo -e “${GREEN}[*]${NC} $1”
}
error() {
echo -e “${RED}[!]${NC} $1”
}
warning() {
echo -e “${YELLOW}[!]${NC} $1”
}
ask() {
echo -n -e "${YELLOW}[?]${NC} $1 [y/N]: "
read -r response
case “$response” in
[yY][eE][sS]|[yY])
return 0
;;
*)
return 1
;;
esac
}
Check if Hestia is installed
if [ ! -d “$HESTIA” ]; then
error “Hestia Control Panel is not installed!”
exit 1
fi
Welcome message
echo “=========================================”
echo " Hestia Control Panel Uninstaller"
echo “=========================================”
echo
warning “WARNING: This will remove Hestia Control Panel and all associated data!”
echo “This includes:”
echo " - All user accounts and data"
echo " - Websites and databases"
echo " - Email accounts"
echo " - DNS records"
echo " - All configuration files"
echo
if ! ask “Are you sure you want to continue?”; then
echo “Uninstallation cancelled.”
exit 0
fi
echo
log “Starting uninstallation process…”
Stop Hestia and related services
log “Stopping services…”
systemctl stop hestia 2>/dev/null
systemctl disable hestia 2>/dev/null
Stop web services based on configuration
if [ -f “$HESTIA/conf/hestia.conf” ]; then
source $HESTIA/conf/hestia.conf
if [ “$WEB_SYSTEM” = “nginx” ]; then
systemctl stop nginx 2>/dev/null
elif [ “$WEB_SYSTEM” = “apache2” ]; then
systemctl stop apache2 2>/dev/null
fi
if [ "$PROXY_SYSTEM" = "nginx" ]; then
systemctl stop nginx 2>/dev/null
fi
fi
Stop other services
systemctl stop mysql 2>/dev/null || systemctl stop mariadb 2>/dev/null
systemctl stop postfix 2>/dev/null || systemctl stop exim4 2>/dev/null
systemctl stop dovecot 2>/dev/null
systemctl stop vsftpd 2>/dev/null || systemctl stop proftpd 2>/dev/null
systemctl stop named 2>/dev/null || systemctl stop bind9 2>/dev/null
systemctl stop spamassassin 2>/dev/null
systemctl stop clamav-daemon 2>/dev/null
systemctl stop fail2ban 2>/dev/null
Remove users and their data
log “Removing user data…”
if [ -f “$HESTIA/data/users.conf” ]; then
users=$(grep ‘USER=’ $HESTIA/data/users.conf | cut -f2 -d’ | tr ‘\n’ ’ ')
for user in $users; do
log “Removing user: $user”
Remove user directory
if [ -d “/home/$user” ]; then
rm -rf “/home/$user”
fi
Remove FTP user
if id “$user” &>/dev/null; then
userdel -r “$user” 2>/dev/null
fi
done
fi
Remove admin user
if id “admin” &>/dev/null; then
userdel -r admin 2>/dev/null
fi
Remove hestia system user
if id “hestia” &>/dev/null; then
userdel -r hestia 2>/dev/null
fi
Remove Hestia directory
log “Removing Hestia files…”
rm -rf $HESTIA
Remove configuration directories
rm -rf /etc/hestia 2>/dev/null
Remove log directories
rm -rf /var/log/hestia 2>/dev/null
Remove cron jobs
log “Removing cron jobs…”
crontab -u root -l | grep -v hestia | crontab -u root - 2>/dev/null
rm -f /etc/cron.d/hestia 2>/dev/null
rm -f /etc/cron.daily/hestia 2>/dev/null
rm -f /etc/cron.hourly/hestia 2>/dev/null
Remove systemd service
log “Removing systemd service…”
rm -f /etc/systemd/system/hestia.service 2>/dev/null
rm -f /lib/systemd/system/hestia.service 2>/dev/null
systemctl daemon-reload 2>/dev/null
Remove databases
log “Removing databases…”
if command -v mysql &>/dev/null; then
mysql -e “DROP DATABASE IF EXISTS hestia;” 2>/dev/null
mysql -e “DROP DATABASE IF EXISTS roundcube;” 2>/dev/null
mysql -e “DROP USER IF EXISTS ‘hestia’@‘localhost’;” 2>/dev/null
fi
Remove packages (optional)
if ask “Remove Hestia and related packages?”; then
log “Removing packages…”
apt-get remove --purge -y
hestia*
hestia-nginx
hestia-php
hestia-mariadb
roundcube*
2>/dev/null
apt-get autoremove -y 2>/dev/null
apt-get autoclean -y 2>/dev/null
fi
Remove apt repository
rm -f /etc/apt/sources.list.d/hestia.list 2>/dev/null
rm -f /etc/apt/sources.list.d/hestia-src.list 2>/dev/null
Final cleanup
log “Cleaning up temporary files…”
rm -rf /tmp/hestia* 2>/dev/null
rm -rf /tmp/hst-* 2>/dev/null
rm -f /root/hestia* 2>/dev/null
rm -f /root/.hestia* 2>/dev/null
echo
log “=========================================”
log " Uninstallation complete!"
log “=========================================”
echo
log “The following items were removed:”
log " - Hestia Control Panel files"
log " - User accounts and data"
log " - Configuration files"
log " - System services"
echo
warning “Note: Some system packages (nginx, mysql, etc.) may still be installed.”
warning “If you want to remove them, run: apt-get remove --purge nginx mysql-* php-*”
echo
log “You may need to reboot your system for all changes to take effect.”
EOF
Make it executable and run
chmod +x /tmp/uninstall.sh
bash /tmp/uninstall.sh