Clona il repository, crea l'ambiente, chiede le credenziali (password senza eco, mai nella cronologia), verifica di riuscire a leggere l'impianto, installa e avvia il servizio, e stampa indirizzo e token da mettere nell'app. Non serve root e non tocca niente fuori dalla home. I percorsi sono variabili (AIRA_INSTALL_DIR, AIRA_CONFIG_DIR, AIRA_PORT) con valori predefiniti sensati, cosi' lo script funziona per chiunque: i valori predefiniti dei programmi esistenti non sono stati cambiati, per non toccare installazioni in corso. Provato per davvero: clonazione, ambiente Python con pyairahome/grpc/cryptography, lettura del token, e il file del servizio passato a systemd-analyze verify. Il ramo che usa systemctl --user non e' verificabile da qui (nessun bus utente): da provare su una macchina con sessione systemd. README: installazione in un comando, con la procedura manuale come ripiego. setup_creds.py: messaggi in inglese, per il pubblico del forum.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Save the Aira credentials in $AIRA_CONFIG_DIR/aira.json (permissions 600).
|
|
|
|
Run it yourself, in your own terminal: the password is typed without echo and
|
|
never appears in the logs or in the shell history.
|
|
|
|
Usage:
|
|
cd bridge
|
|
.venv/bin/python setup_creds.py
|
|
"""
|
|
import getpass
|
|
import json
|
|
import os
|
|
import stat
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
BASE = Path(os.environ.get("AIRA_CONFIG_DIR") or (Path.home() / ".hermes" / "profiles" / "carlo"))
|
|
TARGET = BASE / "aira.json"
|
|
|
|
|
|
def main() -> int:
|
|
email = input("Aira account email: ").strip()
|
|
if not email:
|
|
print("empty email, aborting", file=sys.stderr)
|
|
return 1
|
|
|
|
password = getpass.getpass("Password (will not be shown): ")
|
|
if not password:
|
|
print("empty password, aborting", file=sys.stderr)
|
|
return 1
|
|
|
|
TARGET.parent.mkdir(parents=True, exist_ok=True)
|
|
tmp = TARGET.with_suffix(".tmp")
|
|
tmp.write_text(json.dumps({"email": email, "password": password}, indent=2))
|
|
os.chmod(tmp, stat.S_IRUSR | stat.S_IWUSR)
|
|
tmp.replace(TARGET)
|
|
|
|
print(f"\nOK: credentials saved in {TARGET} (permissions 600)")
|
|
print("Next: .venv/bin/python aira_probe.py")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|