Добавить панель системы и временный внешний доступ

This commit is contained in:
Никита
2026-11-10 11:25:50 +03:00
parent 0e0efe5614
commit a81c0bad34
19 changed files with 383 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
"""Grant the local operations UI to an existing messenger account."""
import re,subprocess,sys
from pathlib import Path
root=Path(__file__).resolve().parents[1]
if len(sys.argv)!=2 or not re.fullmatch('[a-z0-9_]{3,32}',sys.argv[1]):raise SystemExit('Укажите логин: make operator USERNAME=n1k0der')
result=subprocess.check_output([str(root/'scripts/compose.sh'),'exec','-T','postgres','psql','-U','messenger','-d','messenger','-At','-c',"SELECT id FROM users WHERE username='"+sys.argv[1]+"'"],cwd=root,text=True).strip()
if not result:raise SystemExit('Сначала зарегистрируйте этот аккаунт в мессенджере')
p=root/'.env';lines=p.read_text().splitlines() if p.exists() else []
lines=[line for line in lines if not line.startswith('OPS_USER_ID=')];lines.append('OPS_USER_ID='+result);p.write_text('\n'.join(lines)+'\n');p.chmod(0o600)
subprocess.run([str(root/'scripts/compose.sh'),'up','-d','--no-deps','--wait','api'],cwd=root,check=True)
print('Панель доступна аккаунту '+sys.argv[1]+'. Перезайдите в мессенджер.')