#!/bin/bash # 删除指定部署 # 用法: bash delete.sh CONFIG_FILE="$HOME/.openclaw/cloud-deploy.json" DEPLOY_ID="$1" if [ -z "$DEPLOY_ID" ]; then echo "用法: bash delete.sh " exit 1 fi TOKEN=$(python3 -c "import json; t=json.load(open('$CONFIG_FILE')).get('token'); print(t if t else '')" 2>/dev/null) API_URL=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE'))['apiUrl'])") if [ -z "$TOKEN" ]; then echo "错误:未注册,请先执行 register.sh" exit 1 fi RESPONSE=$(curl -s --max-time 10 \ -X DELETE \ -H "Authorization: Bearer $TOKEN" \ "$API_URL/deploy/$DEPLOY_ID" 2>/dev/null) SUCCESS=$(echo "$RESPONSE" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('success', False))" 2>/dev/null) if [ "$SUCCESS" = "True" ]; then DELETED=$(echo "$RESPONSE" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('deleted',''))" 2>/dev/null) echo "✅ 已删除: $DELETED" else echo "❌ 删除失败" echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE" fi