completed lab4

This commit is contained in:
2026-11-06 17:03:03 +03:00
parent ec540a1a72
commit 6b42473aec
30 changed files with 1184 additions and 39 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Create local-only secret files once; do not print their values."""
from pathlib import Path
import secrets
root=Path(__file__).resolve().parents[1]
d=root/'secrets'; d.mkdir(mode=0o700,exist_ok=True); d.chmod(0o700)
def ensure(name,value):
p=d/name
if not p.exists(): p.write_text(value)
p.chmod(0o600)
ensure('db_password',secrets.token_urlsafe(32))
ensure('rustfs_root_user','RUSTFSROOT')
ensure('rustfs_root_password',secrets.token_urlsafe(32))
ensure('s3_access_key_id','messengerapi')
ensure('s3_secret_access_key',secrets.token_urlsafe(40))
p=d/'database_url'; ensure('database_url','postgresql://messenger:'+ (d/'db_password').read_text().strip()+'@postgres:5432/messenger')
ensure('cache_url','redis://redis:6379/0')
env=root/'.env'
if not env.exists(): env.write_text('API_REPLICAS=2\nSESSION_TTL_SECONDS=3600\n')
env.chmod(0o600)
print('Local secrets created or preserved; values hidden.')