Files
mtusi2026lab7/scripts/rotate-service-secret.sh
2026-11-26 23:34:55 +03:00

16 lines
544 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
role="${1:?Usage: rotate-service-secret.sh api|worker}"
[[ "$role" == api || "$role" == worker ]] || exit 2
python3 - "$role" <<'PY'
import secrets,sys
from pathlib import Path
for name in ['redis-'+sys.argv[1],'s3-'+sys.argv[1]]:
p=Path('secrets/operator')/name
p.write_text(secrets.token_hex(24));p.chmod(0o600)
PY
scripts/bootstrap-openbao.sh
scripts/dc.sh restart cache
if [[ "$role" == api ]]; then scripts/dc.sh restart api api2; else scripts/dc.sh restart worker; fi