Record railiance01 clone tree, host_paths registration, and tooling for bulk clone and path registration. Update T05 workplan with Phase 4 completion.
49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Register railiance01 host_paths for all State Hub repos.
|
|
# Usage: railiance01-register-host-paths.sh [--dry-run]
|
|
set -euo pipefail
|
|
|
|
API_BASE="${API_BASE:-http://127.0.0.1:8000}"
|
|
HOST="${RAILIANCE_HOST:-239.62.205.92.host.secureserver.net}"
|
|
CLONE_ROOT="${CLONE_ROOT:-/home/tegwick}"
|
|
DRY_RUN=0
|
|
|
|
if [[ "${1:-}" == "--dry-run" ]]; then
|
|
DRY_RUN=1
|
|
fi
|
|
|
|
repos=$(curl -fsS "${API_BASE}/repos/")
|
|
registered=0
|
|
skipped=0
|
|
|
|
while IFS= read -r slug; do
|
|
path="${CLONE_ROOT}/${slug}"
|
|
current=$(python3 -c "
|
|
import json, sys
|
|
repos = json.load(sys.stdin)
|
|
for r in repos:
|
|
if r['slug'] == sys.argv[1]:
|
|
print((r.get('host_paths') or {}).get(sys.argv[2], ''))
|
|
break
|
|
" <<<"${repos}" "${slug}" "${HOST}")
|
|
if [[ "${current}" == "${path}" ]]; then
|
|
echo "OK ${slug}"
|
|
skipped=$((skipped + 1))
|
|
continue
|
|
fi
|
|
if [[ "${DRY_RUN}" -eq 1 ]]; then
|
|
echo "DRY ${slug} host_paths[${HOST}]=${path} (was: ${current:-<empty>})"
|
|
continue
|
|
fi
|
|
curl -fsS -X POST "${API_BASE}/repos/${slug}/paths" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"host\": \"${HOST}\", \"path\": \"${path}\"}" >/dev/null
|
|
echo "POST ${slug} -> ${path}"
|
|
registered=$((registered + 1))
|
|
done < <(python3 -c "
|
|
import json, sys
|
|
for r in sorted(json.load(sys.stdin), key=lambda x: x['slug']):
|
|
print(r['slug'])
|
|
" <<<"${repos}")
|
|
|
|
echo "done: registered=${registered} unchanged=${skipped}" |