36 lines
1.2 KiB
Bash
Executable File
36 lines
1.2 KiB
Bash
Executable File
#!/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 "所有部署已撤销。"
|