Files
gemini-cli/scripts/teardown-forever-agent.sh
T
Adam Weidman 444e42f6bf feat: one-command deployment script and parameterized startup
- deploy-forever-agent.sh: creates Pub/Sub, static IP, IAM, VM in one command
- teardown-forever-agent.sh: cleans up all resources
- gce-startup.sh: reads config from instance metadata instead of hardcoding
2026-03-04 09:36:14 -05:00

51 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# teardown-forever-agent.sh — Remove all Forever Agent GCE resources.
#
# Usage: ./scripts/teardown-forever-agent.sh
#
# Optional env vars (defaults shown):
# PROJECT - GCP project ID (defaults to gcloud config)
# REGION - GCP region (default: us-central1)
# ZONE - GCP zone (default: us-central1-a)
# VM_NAME - VM name (default: forever-agent)
# PUBSUB_TOPIC - Pub/Sub topic name (default: forever-agent-chat)
# PUBSUB_SUB - Pub/Sub subscription name (default: forever-agent-chat-sub)
set -euo pipefail
PROJECT="${PROJECT:-$(gcloud config get-value project 2>/dev/null)}"
REGION="${REGION:-us-central1}"
ZONE="${ZONE:-us-central1-a}"
VM_NAME="${VM_NAME:-forever-agent}"
PUBSUB_TOPIC="${PUBSUB_TOPIC:-forever-agent-chat}"
PUBSUB_SUB="${PUBSUB_SUB:-forever-agent-chat-sub}"
IP_NAME="${VM_NAME}-ip"
echo "=== Tearing down Forever Agent ==="
echo " Project: $PROJECT"
echo " VM: $VM_NAME ($ZONE)"
echo ""
read -p "Are you sure? This will delete the VM, static IP, and Pub/Sub resources. [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
echo "--- Deleting VM..."
gcloud compute instances delete "$VM_NAME" --zone="$ZONE" --project="$PROJECT" --quiet 2>/dev/null || echo " VM not found"
echo "--- Releasing static IP..."
gcloud compute addresses delete "$IP_NAME" --region="$REGION" --project="$PROJECT" --quiet 2>/dev/null || echo " Static IP not found"
echo "--- Deleting Pub/Sub subscription..."
gcloud pubsub subscriptions delete "$PUBSUB_SUB" --project="$PROJECT" --quiet 2>/dev/null || echo " Subscription not found"
echo "--- Deleting Pub/Sub topic..."
gcloud pubsub topics delete "$PUBSUB_TOPIC" --project="$PROJECT" --quiet 2>/dev/null || echo " Topic not found"
echo ""
echo "=== Teardown complete ==="
echo "Note: The Google Chat app configuration must be removed manually from the GCP console."