выполненная лаб2

This commit is contained in:
2026-10-22 17:11:47 +03:00
parent 65003b6119
commit 508340638d
39 changed files with 3547 additions and 33 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/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.')