#!/bin/sh # dev bootstrap: # - create accounts (alice, bob, charlie, david) # - write verified committer email fixtures for Deliberi # - write OWNER_DID to /shared/owner-did (for knot/spindle) # - create system label definitions under SYSTEM_DID set -eu . /scripts/lib.sh USERS="alice bob charlie david" OWNER_USER="${OWNER_USER:-alice}" SYSTEM_USER="${SYSTEM_USER:-alice}" SHARED_DIR="${SHARED_DIR:-/shared}" VERIFIED_EMAILS_FILE="${SHARED_DIR}/verified-emails.jsonl" VERIFIED_EMAILS_TMP="${VERIFIED_EMAILS_FILE}.tmp" mkdir -p "$SHARED_DIR" : > "$VERIFIED_EMAILS_TMP" ACCOUNTS_FILE="${SHARED_DIR}/accounts.tsv" sh /scripts/add-accounts.sh $USERS > "$ACCOUNTS_FILE" cat "$ACCOUNTS_FILE" >&2 OWNER_DID="" SYSTEM_DID="" while IFS="$(printf '\t')" read -r u did; do [ -n "$u" ] || continue jq -cn \ --arg did "$did" \ --arg email "${u}@${PDS_HOSTNAME}" \ '{did: $did, email: $email}' >> "$VERIFIED_EMAILS_TMP" if [ "$u" = "$OWNER_USER" ]; then OWNER_DID="$did" fi if [ "$u" = "$SYSTEM_USER" ]; then SYSTEM_DID="$did" fi done < "$ACCOUNTS_FILE" [ -n "$OWNER_DID" ] || { printf 'OWNER_USER %s not in USERS list\n' "$OWNER_USER" >&2; exit 1; } [ -n "$SYSTEM_DID" ] || { printf 'SYSTEM_USER %s not in USERS list\n' "$SYSTEM_USER" >&2; exit 1; } mv "$VERIFIED_EMAILS_TMP" "$VERIFIED_EMAILS_FILE" printf '[emails] wrote verified committer fixtures for %s\n' "$USERS" >&2 printf '%s' "$OWNER_DID" > "${SHARED_DIR}/owner-did" printf '[owner] %s → %s/owner-did\n' "$OWNER_USER" "$SHARED_DIR" >&2 printf '%s' "$SYSTEM_DID" > "${SHARED_DIR}/system-did" printf '[system] %s → %s/system-did\n' "$SYSTEM_USER" "$SHARED_DIR" >&2