From f477ea7d6b2d874c4d41379fc703c5f8b0ea214b Mon Sep 17 00:00:00 2001 From: finn Date: Tue, 22 Sep 2026 19:28:20 -0700 Subject: [PATCH] guardrail to prevent conflicting linodes --- create-linode.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/create-linode.sh b/create-linode.sh index ec9b9e8..9dafcbd 100755 --- a/create-linode.sh +++ b/create-linode.sh @@ -66,6 +66,18 @@ fi # Linode API and be generally buggy and annoying in all further operations. if [[ "$SCRIPT_ACTION" == "c" && -n "$LINODE_LABEL" ]]; then + # Safety guard: this script administers a single Linode. Creating another + # while one already exists would leave two servers competing for the same + # volume, so refuse instead. The instances list reports the total number of + # Linodes in "results", which is 0 when nothing is running. + EXISTING_COUNT=$(curl -s -H "Authorization: Bearer $LINODE_API_KEY" \ + https://api.linode.com/v4/linode/instances | jq -r '.results // 0') + if [[ "$EXISTING_COUNT" != "0" ]]; then + echo "ERROR: $EXISTING_COUNT Linode(s) already exist; this script manages a single instance." >&2 + echo " Destroy the existing one first: create-linode.sh d