metis-desk/scripts/prepare-local-env.py

19 lines
634 B
Python
Raw Permalink Normal View History

from pathlib import Path
import secrets
root = Path(__file__).resolve().parent.parent
target = root / ".env"
if target.exists():
print("La configuración local ya existe; no se modifica.")
else:
template = (root / ".env.example").read_text()
for placeholder in [
"replace-with-a-random-value",
"replace-with-another-random-value",
"replace-with-at-least-32-random-characters",
]:
template = template.replace(placeholder, secrets.token_urlsafe(48))
target.write_text(template)
target.chmod(0o600)
print("Configuración local creada. No se han generado cuentas de usuario.")