#!/bin/sh # Shared helpers for operator scripts. The root token lives only in ./secrets/operator (0600, outside Git, outside any image/volume). S="${SECRETS_DIR:-secrets}"; OPD="$S/operator" # baoc : run the bao CLI. BAO_LOCAL=1 uses a host binary; default is `docker compose exec` into the openbao container. baoc() { if [ -n "${BAO_LOCAL:-}" ]; then BAO_ADDR="${BAO_LOCAL_ADDR:-https://localhost:8200}" BAO_CACERT="$S/pki/ca/ca.crt" BAO_TOKEN="${BAO_TOKEN_VALUE:-}" "${BAO_BIN:-bao}" "$@" else docker compose exec -T -e BAO_ADDR=https://openbao:8200 -e BAO_CACERT=/run/pki/ca.crt -e BAO_TOKEN="${BAO_TOKEN_VALUE:-}" openbao bao "$@" fi } load_root() { [ -f "$OPD/root_token" ] || { echo "no operator root token: run scripts/bao_init.sh" >&2; exit 1; }; BAO_TOKEN_VALUE="$(cat "$OPD/root_token")"; }