Fix: Improve Hysteria2 uninstallation script for complete removal
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
source /etc/hysteria/core/scripts/path.sh
|
||||
source /etc/hysteria/core/scripts/path.sh || true
|
||||
|
||||
echo "Uninstalling Hysteria2..."
|
||||
|
||||
@ -6,39 +6,45 @@ echo "Running uninstallation script..."
|
||||
bash <(curl -fsSL https://get.hy2.sh/) --remove >/dev/null 2>&1
|
||||
|
||||
echo "Removing WARP"
|
||||
python3 $CLI_PATH uninstall-warp
|
||||
if command -v python3 &> /dev/null && [ -f "$CLI_PATH" ]; then
|
||||
python3 "$CLI_PATH" uninstall-warp || true
|
||||
else
|
||||
echo "Skipping WARP removal (python3 or CLI_PATH not found)"
|
||||
fi
|
||||
|
||||
|
||||
echo "Removing Hysteria folder..."
|
||||
rm -rf /etc/hysteria >/dev/null 2>&1
|
||||
|
||||
echo "Deleting hysteria user..."
|
||||
userdel -r hysteria >/dev/null 2>&1
|
||||
userdel -r hysteria >/dev/null 2>&1 || true
|
||||
|
||||
echo "Removing systemd service files..."
|
||||
rm -f /etc/systemd/system/multi-user.target.wants/hysteria-server.service >/dev/null 2>&1
|
||||
rm -f /etc/systemd/system/multi-user.target.wants/hysteria-server@*.service >/dev/null 2>&1
|
||||
|
||||
for service in hysteria-server.service hysteria-webpanel.service hysteria-caddy.service \
|
||||
hysteria-telegram-bot.service hysteria-normal-sub.service hysteria-singbox.service \
|
||||
hysteria-server@*.service; do
|
||||
rm -f "/etc/systemd/system/$service" "/etc/systemd/system/multi-user.target.wants/$service" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
systemctl daemon-reload >/dev/null 2>&1
|
||||
|
||||
echo "Removing cron jobs..."
|
||||
(crontab -l | grep -v "python3 /etc/hysteria/core/cli.py traffic-status" | crontab -) >/dev/null 2>&1
|
||||
(crontab -l | grep -v "/etc/hysteria/core/scripts/hysteria2/kick.sh" | crontab -) >/dev/null 2>&1
|
||||
(crontab -l | grep -v "python3 /etc/hysteria/core/cli.py restart-hysteria2" | crontab -) >/dev/null 2>&1
|
||||
(crontab -l | grep -v "python3 /etc/hysteria/core/cli.py backup-hysteria" | crontab -) >/dev/null 2>&1
|
||||
if crontab -l 2>/dev/null | grep -q "hysteria"; then
|
||||
(crontab -l | grep -v "hysteria" | crontab -) >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "Removing alias 'hys2' from .bashrc..."
|
||||
sed -i '/alias hys2=.*\/etc\/hysteria\/menu.sh/d' ~/.bashrc
|
||||
|
||||
echo "Stop/Disabling Hysteria TelegramBOT Service..."
|
||||
systemctl stop hysteria-telegram-bot.service > /dev/null 2>&1
|
||||
systemctl disable hysteria-telegram-bot.service > /dev/null 2>&1
|
||||
|
||||
echo "Stop/Disabling Singbox SubLink Service..."
|
||||
systemctl stop hysteria-singbox.service > /dev/null 2>&1
|
||||
systemctl disable hysteria-singbox.service > /dev/null 2>&1
|
||||
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 ""
|
||||
|
||||
Reference in New Issue
Block a user