13 lines
637 B
Python
13 lines
637 B
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
import secrets
|
|
p=Path('secrets'); p.mkdir(mode=0o700,exist_ok=True)
|
|
password=p/'db_password'
|
|
if not password.exists(): password.write_text(secrets.token_hex(24))
|
|
for name,value in {'database_url':'postgresql://messenger:'+password.read_text().strip()+'@postgres:5432/messenger','cache_url':'redis://redis:6379/0'}.items():
|
|
target=p/name
|
|
if not target.exists(): target.write_text(value)
|
|
for target in p.iterdir(): target.chmod(0o600)
|
|
if not Path('.env').exists(): Path('.env').write_text('SESSION_TTL_SECONDS=3600\n')
|
|
print('Local configuration created; secrets were not printed.')
|