diff --git a/surge-teardown-all.sh b/surge-teardown-all.sh new file mode 100755 index 0000000..9a80f9e --- /dev/null +++ b/surge-teardown-all.sh @@ -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 "所有部署已撤销。"