53 lines
1.6 KiB
Bash
53 lines
1.6 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# =============================================================
|
|
# PasteVault - remove-app.sh
|
|
# Stops all containers and deletes ALL Azure resources.
|
|
#
|
|
# WARNING: This permanently deletes the database and all data.
|
|
# Take a backup first with: bash scripts/backup.sh
|
|
#
|
|
# Usage:
|
|
# cd sk1/
|
|
# bash scripts/remove-app.sh
|
|
# =============================================================
|
|
|
|
RG="pastevault-rg"
|
|
VM_NAME="pastevault-vm"
|
|
VM_USER="azureuser"
|
|
SSH_KEY="$HOME/.ssh/id_rsa"
|
|
|
|
echo "⚠️ WARNING: This will permanently delete all PasteVault"
|
|
echo " resources including the database and all paste data."
|
|
echo ""
|
|
read -p " Type 'yes' to confirm: " CONFIRM
|
|
|
|
if [ "$CONFIRM" != "yes" ]; then
|
|
echo "Aborted. Nothing was deleted."
|
|
exit 0
|
|
fi
|
|
|
|
# Stop containers on VM first (clean shutdown)
|
|
echo ""
|
|
echo "🛑 Stopping containers on VM..."
|
|
VM_IP=$(az vm show -d -g $RG -n $VM_NAME --query publicIps -o tsv 2>/dev/null || echo "")
|
|
if [ -n "$VM_IP" ]; then
|
|
ssh -i $SSH_KEY -o StrictHostKeyChecking=no -o ConnectTimeout=10 $VM_USER@$VM_IP \
|
|
"cd ~/pastevault && sudo docker compose down -v --remove-orphans" 2>/dev/null || true
|
|
echo " ✅ Containers stopped"
|
|
else
|
|
echo " ⚠️ VM not reachable, skipping container shutdown"
|
|
fi
|
|
|
|
# Delete entire resource group — removes VM, DB, storage, IPs, everything
|
|
echo ""
|
|
echo "🗑️ Deleting Azure resource group '$RG'..."
|
|
echo " (This takes 2-3 minutes, running in background)"
|
|
az group delete --name $RG --yes --no-wait
|
|
|
|
echo ""
|
|
echo "✅ Teardown initiated."
|
|
echo " All Azure resources are being deleted."
|
|
echo " Verify with: az group list -o table"
|