#!/bin/sh set -eu cd "$(dirname "$0")/.." python3 - <<'PY' from pathlib import Path import secrets import json p = Path('.env') if not p.exists(): p.write_text('\n'.join(k+'='+secrets.token_hex(20) for k in ( 'POSTGRES_PASSWORD','BROKER_PASSWORD','S3_ACCESS_KEY_ID','S3_SECRET_ACCESS_KEY','GRAFANA_PASSWORD'))+'\n') p.chmod(0o600) print('Created local .env') else: print('Keeping existing .env') values = dict(line.split('=', 1) for line in p.read_text().splitlines() if line.strip() and not line.lstrip().startswith('#') and '=' in line) folder = Path('secrets') folder.mkdir(exist_ok=True, mode=0o700) config = folder / 'seaweed-s3.json' config.write_text(json.dumps({'identities': [{'name': 'messenger', 'credentials': [{'accessKey': values['S3_ACCESS_KEY_ID'].strip(), 'secretKey': values['S3_SECRET_ACCESS_KEY'].strip()}], 'actions': ['Admin', 'Read', 'Write', 'List', 'Tagging']}]})) config.chmod(0o600) print('Configured authenticated SeaweedFS storage') PY