You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
802 B
32 lines
802 B
#!/usr/bin/env python3 |
|
"""Initialisation du frontend pySonnerie. |
|
|
|
Cree frontend/data/conf.json avec une secret_key aleatoire si le fichier |
|
n'existe pas encore. |
|
""" |
|
from __future__ import annotations |
|
|
|
import json |
|
import secrets |
|
import sys |
|
from pathlib import Path |
|
|
|
CONF_PATH = Path(__file__).resolve().parent / "data" / "conf.json" |
|
|
|
|
|
def main() -> None: |
|
if CONF_PATH.exists(): |
|
print(f"[info] {CONF_PATH} existe deja, aucune modification.") |
|
sys.exit(0) |
|
|
|
CONF_PATH.parent.mkdir(parents=True, exist_ok=True) |
|
|
|
conf = {"secret_key": secrets.token_hex(32)} |
|
CONF_PATH.write_text(json.dumps(conf, indent=2) + "\n", encoding="utf-8") |
|
CONF_PATH.chmod(0o600) |
|
|
|
print(f"[ok] {CONF_PATH} cree avec une cle aleatoire (permissions 600).") |
|
|
|
|
|
if __name__ == "__main__": |
|
main()
|
|
|