#!/usr/bin/env bash # Delete every VM of the devnet (nodes and builder), the firewall and the zone networks. The SSH key stays on the provider (free). # Run experiments/collect.sh first: the logs on the VMs go with them. . "$(dirname "$0")/lib/common.sh" if [ "$PROVIDER" = digitalocean ]; then need doctl "brew install doctl" ids=$(doctl compute droplet list --tag-name "$PREFIX-devnet" --format ID,Name --no-header) [ -n "$ids" ] || log "no droplets tagged $PREFIX-devnet" printf '%s\n' "$ids" confirm "delete these droplets and the firewall $PREFIX-devnet?" [ -n "$ids" ] && doctl compute droplet delete -f --tag-name "$PREFIX-devnet" doctl compute droplet delete -f "$PREFIX-builder" 2>/dev/null || true fw=$(doctl compute firewall list --format ID,Name --no-header | awk -v n="$PREFIX-devnet" '$2 == n { print $1 }') [ -n "$fw" ] && doctl compute firewall delete -f "$fw" else need hcloud "brew install hcloud" hcloud server list -l igneum=devnet confirm "delete every server labelled igneum=devnet and the firewall $PREFIX-devnet?" names=$(hcloud server list -l igneum=devnet -o columns=name -o noheader) for s in $names; do hcloud server delete "$s" >/dev/null && log "deleted $s"; done hcloud firewall delete "$PREFIX-devnet" >/dev/null 2>&1 && log "deleted firewall $PREFIX-devnet" || true for net in $(hcloud network list -l igneum=devnet -o columns=name -o noheader); do hcloud network delete "$net" >/dev/null && log "deleted network $net"; done fi if [ -f "$NODES_FILE" ]; then d=$(results_dir_for); cp "$NODES_FILE" "$d/nodes-destroyed-$(date -u +%H%M%S).tsv"; rm -f "$NODES_FILE" "$BUILD_DIR/builder.ip" fi printf '%s\tdestroy\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$(results_dir_for)/events.log" log "done. Check the provider console once: nothing labelled igneum should remain."