carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

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