#!/bin/sh # ONE-TIME operator step: initialise OpenBao (3 key shares, threshold 2). Shares and root token go to ./secrets/operator # as separate 0600 files: the operator is expected to move shares to different custodians. Nothing is printed. set -eu cd "$(dirname "$0")/.."; . scripts/bao_lib.sh umask 077; mkdir -p "$OPD" if baoc status -format=json 2>/dev/null | grep -q "\"initialized\": true"; then echo "OpenBao already initialised"; exit 0; fi baoc operator init -key-shares=3 -key-threshold=2 -format=json > "$OPD/init.json" python3 - "$OPD" <<"PY" import json, os, sys d = sys.argv[1]; j = json.load(open(d + "/init.json")) for i, k in enumerate(j["unseal_keys_b64"], 1): open(f"{d}/unseal-{i}", "w").write(k) open(d + "/root_token", "w").write(j["root_token"]) os.remove(d + "/init.json") PY echo "initialised: unseal-1..3 and root_token written to $OPD (keep them OUT of Git and OUT of the stand)"