Improve uninstallation process

This commit is contained in:
Whispering Wind
2025-03-24 20:23:15 +03:30
committed by GitHub
parent 1b840007de
commit efb2d22672

View File

@ -2,6 +2,16 @@ source /etc/hysteria/core/scripts/path.sh || true
echo "Uninstalling Hysteria2..." echo "Uninstalling Hysteria2..."
SERVICES=(
"hysteria-server.service"
"hysteria-webpanel.service"
"hysteria-caddy.service"
"hysteria-telegram-bot.service"
"hysteria-normal-sub.service"
"hysteria-singbox.service"
"hysteria-ip-limit.service"
)
echo "Running uninstallation script..." echo "Running uninstallation script..."
bash <(curl -fsSL https://get.hy2.sh/) --remove >/dev/null 2>&1 bash <(curl -fsSL https://get.hy2.sh/) --remove >/dev/null 2>&1
@ -12,18 +22,22 @@ else
echo "Skipping WARP removal (python3 or CLI_PATH not found)" echo "Skipping WARP removal (python3 or CLI_PATH not found)"
fi fi
echo "Removing Hysteria folder..." echo "Removing Hysteria folder..."
rm -rf /etc/hysteria >/dev/null 2>&1 rm -rf /etc/hysteria >/dev/null 2>&1
echo "Deleting hysteria user..." echo "Deleting hysteria user..."
userdel -r hysteria >/dev/null 2>&1 || true userdel -r hysteria >/dev/null 2>&1 || true
echo "Removing systemd service files..." echo "Stop/Disabling Hysteria Services..."
for service in "${SERVICES[@]}" "hysteria-server@*.service"; do
echo "Stopping and disabling $service..."
systemctl stop "$service" > /dev/null 2>&1 || true
systemctl disable "$service" > /dev/null 2>&1 || true
done
for service in hysteria-server.service hysteria-webpanel.service hysteria-caddy.service \ echo "Removing systemd service files..."
hysteria-telegram-bot.service hysteria-normal-sub.service hysteria-singbox.service \ for service in "${SERVICES[@]}" "hysteria-server@*.service"; do
hysteria-server@*.service; do echo "Removing service file: $service"
rm -f "/etc/systemd/system/$service" "/etc/systemd/system/multi-user.target.wants/$service" >/dev/null 2>&1 rm -f "/etc/systemd/system/$service" "/etc/systemd/system/multi-user.target.wants/$service" >/dev/null 2>&1
done done
@ -35,16 +49,8 @@ if crontab -l 2>/dev/null | grep -q "hysteria"; then
(crontab -l | grep -v "hysteria" | crontab -) >/dev/null 2>&1 (crontab -l | grep -v "hysteria" | crontab -) >/dev/null 2>&1
fi fi
echo "Removing alias 'hys2' from .bashrc..." echo "Removing alias 'hys2' from .bashrc..."
sed -i '/alias hys2=.*\/etc\/hysteria\/menu.sh/d' ~/.bashrc 2>/dev/null || true sed -i '/alias hys2=.*\/etc\/hysteria\/menu.sh/d' ~/.bashrc 2>/dev/null || true
echo "Stop/Disabling Hysteria Services..."
for service in hysteria-telegram-bot.service hysteria-singbox.service hysteria-webpanel.service hysteria-caddy.service hysteria-normal-sub.service; do
systemctl stop "$service" > /dev/null 2>&1 || true
systemctl disable "$service" > /dev/null 2>&1 || true
done
echo "Hysteria2 uninstalled!" echo "Hysteria2 uninstalled!"
echo "" echo ""