#!/usr/bin/env python3 """Unseal file-backed OpenBao with operator-held local recovery shares.""" import json from pathlib import Path from bootstrap import BAO, bao_request operator=json.loads((BAO/'operator.json').read_text()) keys=operator.get('keys') or operator.get('keys_base64') or [] if len(keys)<2: raise SystemExit('OpenBao operator recovery material is incomplete') _,health=bao_request('sys/health') if not health.get('sealed',True): print('OpenBao is already unsealed.') raise SystemExit(0) for key in keys[:2]: _,health=bao_request('sys/unseal','POST',{'key':key}) if health.get('sealed',True): raise SystemExit('OpenBao remains sealed; inspect operator recovery shares locally.') print('OpenBao unsealed; operator shares were not printed.')