#!/usr/bin/env bash # Seed the Pi demo fleet on the dev platform: N resident + M parked demo # instances, all fleet-placed at create (-place fleet/pi). The fleet's boxes # are the only activators on its bucket, so placement IS residency, per-fleet. # # The console API's app-create limiter is 10/address/day, so run this in # daily batches: seed-pi-demo.sh . State is the dev # platform itself — re-running an already-claimed index is SAFE (it will # not double-create), but it is NOT free: the limiter counts attempts, not # successes, and is checked before the claim (internal/console/authcli.go), # so every `exists:` line still spends one of the day's 10. Only re-run a # batch that actually failed — don't re-run a batch that already succeeded # just to double-check it. `carlos apps create` refuses a taken name with # "that name is taken" (HTTP 409), and this script treats that refusal as # success rather than a fresh error. # # Requires a carlos CLI build carrying PR #52's `apps create` verb with # `-place` flag (API mode ONLY — sign in first with `carlos auth login -console `; # direct bucket mode has no claims table to write to and this verb refuses it). # PR #52 is unmerged as of this writing (branch worktree-cli-app-create) — # seeding cannot run until it lands. Note also: neither main nor PR #52 # has an `apps list`/`ls` verb over the console API, so idempotence here is # done by interpreting create's own "taken" refusal, not by listing first. set -euo pipefail START=${1:?usage: seed-pi-demo.sh } COUNT=${2:?usage: seed-pi-demo.sh } if (( COUNT > 10 )); then echo "warning: console API limits app creation to 10/address/day — run this in batches of <=10" >&2 fi for i in $(seq "$START" $((START + COUNT - 1))); do app=$(printf 'pi-demo-%03d' "$i") if out=$(carlos apps create -app "$app" -place fleet/pi 2>&1); then echo "created: $app" elif [[ "$out" == *"that name is taken"* ]]; then echo "exists: $app" else echo "$out" >&2 echo "failed: $app" >&2 exit 1 fi done echo echo "Apps are fleet-placed at create. Records provision on the fleet's boxes" echo "automatically once the Pi is joined (runbook: platform-infrastructure repo)." echo echo "Placement does not yet mint a platform-edge route: on the dev edge box," echo "for each app above, run 'carlos add ' (NO -tunnel flag" echo "— placement already supplies the channel once the route row exists and" echo "this script's -place stamped Region) until fleet-route materialization" echo "lands (runbook: platform-infrastructure repo)."