chore(scripts): add safe stop script for osvauco-dev-vm and docs note (#10)

This commit is contained in:
chrischristiansen-glitch 2026-06-01 04:27:50 +02:00 committed by GitHub
parent 2b69a18c53
commit 58b12280dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 0 deletions

View File

@ -112,6 +112,7 @@ Endringer krever eksplisitt godkjenning fra Chris (`RULEBOOK APPROVED`).
3. **OQ-18 (nattlig VM teardown) betyr STOP, ikke DELETE.** 3. **OQ-18 (nattlig VM teardown) betyr STOP, ikke DELETE.**
- Korrekt kommando: `gcloud compute instances stop osvauco-dev-vm --zone=us-central1-b --project=propane-will-491900-m5` - Korrekt kommando: `gcloud compute instances stop osvauco-dev-vm --zone=us-central1-b --project=propane-will-491900-m5`
- Bruk helst `bash scripts/stop-osvauco-dev-vm.sh` for sikker stopp.
- Kjøres KUN når ingen aktiv SSH-sesjon er på VM-en. - Kjøres KUN når ingen aktiv SSH-sesjon er på VM-en.
4. **`03-teardown.sh` gjelder Cloud Run og Artifact Registry — ikke VM.** 4. **`03-teardown.sh` gjelder Cloud Run og Artifact Registry — ikke VM.**

51
scripts/stop-osvauco-dev-vm.sh Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# scripts/stop-osvauco-dev-vm.sh — Safely stop the OSVauco development VM
# Use this instead of manual delete commands.
set -euo pipefail
PROJECT_ID=${PROJECT_ID:-propane-will-491900-m5}
ZONE=${ZONE:-us-central1-b}
VM_NAME=${VM_NAME:-osvauco-dev-vm}
usage() {
cat <<EOF
Usage: $0 [--project <project>] [--zone <zone>] [--vm-name <vm-name>]
Stops the specified Compute Engine VM safely using gcloud.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--project)
PROJECT_ID="$2"
shift 2
;;
--zone)
ZONE="$2"
shift 2
;;
--vm-name)
VM_NAME="$2"
shift 2
;;
--help|-h)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done
echo "Stopping VM ${VM_NAME} in project ${PROJECT_ID}, zone ${ZONE}..."
gcloud compute instances stop "${VM_NAME}" \
--project="${PROJECT_ID}" \
--zone="${ZONE}" \
--quiet
echo "✓ VM stopped: ${VM_NAME}"