feat(surge): 添加 surge-teardown-all.sh 脚本以撤销所有部署

This commit is contained in:
严浩
2025-12-19 23:31:50 +08:00
parent 2663eb3cdf
commit 00ad43f721

35
surge-teardown-all.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
#-------------------------------------------------------------------------------------------------------------
# 使用方法:
# export SURGE_TOKEN="你的 Surge Token"
# URL="https://git.1-h.cc/Scripts/Linux/raw/branch/2026/surge-teardown-all.sh"; curl -fsSL "$URL" | bash
# URL="https://git.1-h.cc/Scripts/Linux/raw/branch/2026/surge-teardown-all.sh"; wget -q -O - "$URL" | bash
#-------------------------------------------------------------------------------------------------------------
echo "正在获取 Surge 部署列表..."
domains=$(bunx surge list | sed 's/\x1b\[[0-9;]*m//g' | grep -E '\.surge\.sh' | awk '{print $1}')
if [ -z "$domains" ]; then
echo "未找到 Surge 部署。"
exit 0
fi
echo "发现以下需要撤销的部署:"
echo "$domains"
echo ""
read -p "确定要撤销所有部署吗?(y/N): " confirm
if [[ $confirm != [yY] && $confirm != [yY][eE][sS] ]]; then
echo "操作已取消。"
exit 0
fi
echo "正在撤销所有部署..."
echo "$domains" | while read -r domain; do
if [ -n "$domain" ]; then
echo "正在撤销: $domain"
bunx surge teardown "$domain"
fi
done
echo "所有部署已撤销。"