#!/bin/bash # ================================================================= # 🗑️ VPS WireGuard 纯净卸载脚本 # ================================================================= RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${YELLOW}>>> [1/3] 正在停止 WireGuard 服务并清理防火墙规则...${NC}" # 停止服务会自动触发 PostDown,从而干干净净地撤销 iptables 规则 sudo systemctl stop wg-quick@wg0 > /dev/null 2>&1 sudo systemctl disable wg-quick@wg0 > /dev/null 2>&1 sudo wg-quick down wg0 > /dev/null 2>&1 echo -e "${GREEN}✅ 服务已停止,网络规则已还原。${NC}" echo -e "${YELLOW}>>> [2/3] 正在删除配置目录与密钥...${NC}" sudo rm -rf /etc/wireguard echo -e "${GREEN}✅ /etc/wireguard 已彻底抹除。${NC}" echo -e "${YELLOW}>>> [3/3] 正在卸载 WireGuard 主程序...${NC}" sudo apt-get purge wireguard wireguard-tools -y > /dev/null 2>&1 sudo apt-get autoremove -y > /dev/null 2>&1 sudo rm -f /etc/sysctl.d/99-wireguard.conf sudo sysctl -p > /dev/null 2>&1 echo -e "${GREEN}✅ 程序清理完毕。${NC}" echo "" echo -e "${GREEN}🎉 卸载完成!你的 VPS 已经恢复到没有安装过 WireGuard 的纯净状态。${NC}"