-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiqrypt_start.py
More file actions
699 lines (596 loc) · 26.9 KB
/
piqrypt_start.py
File metadata and controls
699 lines (596 loc) · 26.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 PiQrypt Inc.
# e-Soleau: DSO2026006483 (19/02/2026) -- DSO2026009143 (12/03/2026)
#!/usr/bin/env python3
"""
piqrypt_start.py — Launcher unique PiQrypt
==========================================
Démarre le stack PiQrypt selon le tier de licence actuel.
Usage :
python piqrypt_start.py # stack complet selon tier
python piqrypt_start.py --vigil # Vigil uniquement
python piqrypt_start.py --trustgate # TrustGate uniquement (Pro+ requis)
python piqrypt_start.py --all # force tout (si droits suffisants)
python piqrypt_start.py --check # vérifie la config sans démarrer
python piqrypt_start.py --gen-tokens # génère des tokens sécurisés
Variables d'environnement :
VIGIL_TOKEN Token Bearer pour Vigil (obligatoire)
TRUSTGATE_TOKEN Token Bearer pour TrustGate (obligatoire si Pro+)
PIQRYPT_HOME Répertoire de données (défaut: ~/.piqrypt)
VIGIL_PORT Port Vigil (défaut: 8421)
TRUSTGATE_PORT Port TrustGate (défaut: 8422)
VIGIL_HOST Host Vigil (défaut: 127.0.0.1)
TRUSTGATE_HOST Host TrustGate (défaut: 127.0.0.1)
Tier → services disponibles :
Free → Vigil (lecture seule), TrustGate absent
Pro / Team → Vigil (complet), TrustGate (manuel)
Business+ → Vigil (complet), TrustGate (complet)
Enterprise → Tout, illimité
IP : e-Soleau DSO2026006483 (INPI France — 19/02/2026)
"""
from __future__ import annotations
import argparse
import logging
import os
import secrets
import signal
import subprocess
import sys
import threading
import time
from pathlib import Path
from typing import List, Optional
# ── Windows UTF-8 fix ─────────────────────────────────────────────────────────
# PowerShell / cmd.exe utilisent cp1252 par défaut — force UTF-8 sur stdout/stderr
# pour éviter UnicodeEncodeError sur les caractères ─ ✅ ❌ ⚠ etc.
if sys.platform == "win32":
import io
try:
sys.stdout = io.TextIOWrapper(
sys.stdout.buffer, encoding="utf-8", errors="replace", line_buffering=True
)
sys.stderr = io.TextIOWrapper(
sys.stderr.buffer, encoding="utf-8", errors="replace", line_buffering=True
)
except AttributeError:
pass # déjà reconfigured ou pas de buffer (pytest, etc.)
# Activer aussi le mode UTF-8 pour les sous-processus
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
# Activer le mode virtuel ANSI pour PowerShell (couleurs)
try:
import ctypes
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleOutputCP(65001) # UTF-8 code page
kernel32.SetConsoleMode(
kernel32.GetStdHandle(-11), # STDOUT
kernel32.GetConsoleMode(kernel32.GetStdHandle(-11), ctypes.byref(ctypes.c_ulong())) or 7
)
except Exception:
pass
# ── Résolution des chemins ────────────────────────────────────────────────────
_LAUNCHER_DIR = Path(__file__).resolve().parent
for _p in [str(_LAUNCHER_DIR), str(_LAUNCHER_DIR / "aiss")]:
if _p not in sys.path:
sys.path.insert(0, _p)
# ── Logging ───────────────────────────────────────────────────────────────────
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [PIQRYPT] %(levelname)s %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
)
log = logging.getLogger("piqrypt.start")
# ── Ports par défaut ──────────────────────────────────────────────────────────
DEFAULT_VIGIL_PORT = int(os.getenv("VIGIL_PORT", "8421"))
DEFAULT_TRUSTGATE_PORT = int(os.getenv("TRUSTGATE_PORT", "8422"))
DEFAULT_HOST = os.getenv("VIGIL_HOST", "127.0.0.1")
DEFAULT_TRUSTGATE_HOST = os.getenv("TRUSTGATE_HOST", "127.0.0.1")
# ── Couleurs terminal ─────────────────────────────────────────────────────────
_USE_COLOR = sys.stdout.isatty()
def _c(text: str, code: str) -> str:
return f"\033[{code}m{text}\033[0m" if _USE_COLOR else text
def green(t): return _c(t, "32")
def yellow(t): return _c(t, "33")
def red(t): return _c(t, "31")
def bold(t): return _c(t, "1")
def cyan(t): return _c(t, "36")
def dim(t): return _c(t, "2")
# ── Symboles unicode avec fallback ASCII ──────────────────────────────────────
# Certains terminaux Windows (cp1252) ne supportent pas les caractères > U+00FF.
# On détecte la capacité du codec et on replie sur ASCII si nécessaire.
def _can_encode(s: str) -> bool:
try:
s.encode(sys.stdout.encoding or "ascii")
return True
except (UnicodeEncodeError, LookupError):
return False
_OK = "OK" if not _can_encode("✅") else "✅"
_ERR = "ERR" if not _can_encode("❌") else "❌"
_WARN = "(!)" if not _can_encode("⚠️") else "⚠️"
_BOOK = "[r]" if not _can_encode("📖") else "📖"
_BULL = "*" if not _can_encode("●") else "●"
_SEP = "-" if not _can_encode("─") else "─"
_INF = "inf" if not _can_encode("∞") else "∞"
_ARR = "->" if not _can_encode("→") else "→"
# ══════════════════════════════════════════════════════════════════════════════
# TIER & LICENCE
# ══════════════════════════════════════════════════════════════════════════════
def get_current_tier() -> str:
"""Récupère le tier depuis aiss/license.py."""
try:
from aiss.license import get_tier
return get_tier()
except ImportError:
try:
from license import get_tier
return get_tier()
except ImportError:
return "free"
def tier_allows_trustgate(tier: str) -> bool:
"""True si le tier permet TrustGate (Pro ou supérieur)."""
return tier in ("pro", "team", "business", "enterprise")
def tier_allows_vigil_full(tier: str) -> bool:
"""True si le tier permet Vigil en mode complet."""
return tier != "free"
# ══════════════════════════════════════════════════════════════════════════════
# CONFIGURATION CHECK
# ══════════════════════════════════════════════════════════════════════════════
class StartupCheck:
"""Vérifie la configuration avant démarrage."""
def __init__(self, tier: str, want_vigil: bool = True, want_trustgate: bool = False):
self.tier = tier
self.want_vigil = want_vigil
self.want_trustgate = want_trustgate
self.errors: List[str] = []
self.warnings: List[str] = []
def run(self) -> bool:
"""Lance tous les checks. Retourne True si OK pour démarrer."""
self._check_python_version()
self._check_auth_middleware()
self._check_aiss_importable()
self._check_tokens()
self._check_ports()
self._check_vigil_files()
if self.want_trustgate:
self._check_trustgate_available()
self._check_trustgate_files()
return len(self.errors) == 0
def _check_python_version(self):
if sys.version_info < (3, 9):
self.errors.append(
f"Python 3.9+ requis — version actuelle : {sys.version.split()[0]}"
)
def _check_auth_middleware(self):
auth_path = _LAUNCHER_DIR / "auth_middleware.py"
if not auth_path.exists():
self.errors.append(
f"auth_middleware.py introuvable dans {_LAUNCHER_DIR}. "
"Placez auth_middleware.py à la racine du repo piqrypt/."
)
def _check_aiss_importable(self):
try:
import aiss # noqa: F401
except ImportError:
self.errors.append(
"Package 'aiss' non importable. "
"Lancez depuis la racine du repo ou installez : pip install piqrypt"
)
def _check_tokens(self):
if self.want_vigil:
vigil_token = os.getenv("VIGIL_TOKEN", "").strip()
if not vigil_token:
self.errors.append(
"VIGIL_TOKEN non défini.\n"
" Générez un token : python piqrypt_start.py --gen-tokens\n"
" Puis : export VIGIL_TOKEN=<token>"
)
if self.want_trustgate and tier_allows_trustgate(self.tier):
tg_token = os.getenv("TRUSTGATE_TOKEN", "").strip()
if not tg_token:
self.errors.append(
"TRUSTGATE_TOKEN non défini.\n"
" export TRUSTGATE_TOKEN=<token>"
)
def _check_ports(self):
import socket
for port, name in [
(DEFAULT_VIGIL_PORT if self.want_vigil else None, "Vigil"),
(DEFAULT_TRUSTGATE_PORT if self.want_trustgate else None, "TrustGate"),
]:
if port is None:
continue
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
s.bind(("127.0.0.1", port))
except OSError:
self.warnings.append(
f"Port {port} ({name}) déjà utilisé. "
f"Définissez {name.upper()}_PORT pour changer."
)
def _check_vigil_files(self):
vigil_server = _LAUNCHER_DIR / "vigil" / "vigil_server.py"
vigil_html = _LAUNCHER_DIR / "vigil" / "vigil_v4_final.html"
if not vigil_server.exists():
self.errors.append(f"vigil_server.py introuvable : {vigil_server}")
if not vigil_html.exists():
self.warnings.append(
f"vigil_v4_final.html introuvable — le dashboard affichera le fallback HTML. "
f"Attendu : {vigil_html}"
)
def _check_trustgate_available(self):
if not tier_allows_trustgate(self.tier):
self.errors.append(
f"TrustGate non disponible sur le tier '{self.tier}'.\n"
f" Disponible à partir du tier Pro. https://piqrypt.com/pricing"
)
def _check_trustgate_files(self):
candidates = [
_LAUNCHER_DIR / "trustgate" / "trustgate_server.py",
]
if not any(c.exists() for c in candidates):
self.errors.append(
"trustgate_server.py introuvable dans piqrypt/trustgate/. "
"Vérifiez votre structure de repo."
)
def print_report(self):
print()
print(bold("PiQrypt Stack Launcher v1.8.4"))
print(dim(_SEP * 50))
print(f" Tier : {bold(self.tier.upper())}")
_vigil_str = (
_OK + ' complet'
if tier_allows_vigil_full(self.tier)
else _BOOK + ' lecture seule (Free)'
)
_tg_str = (
(_OK + ' ' + ('complet' if self.tier in ('business', 'enterprise') else 'manuel'))
if tier_allows_trustgate(self.tier) else red('non disponible -- upgrade Pro')
)
print(f" Vigil : {_vigil_str}")
print(f" TrustGate : {_tg_str}")
print()
if self.warnings:
for w in self.warnings:
print(yellow(f" {_WARN} {w}"))
print()
if self.errors:
for e in self.errors:
print(red(f" {_ERR} {e}"))
print()
print(red(" Startup annule -- corrigez les erreurs ci-dessus."))
else:
print(green(f" {_OK} Configuration valide -- pret a demarrer."))
print()
# ══════════════════════════════════════════════════════════════════════════════
# PROCESS MANAGER
# ══════════════════════════════════════════════════════════════════════════════
class ServiceProcess:
"""Gère un processus serveur (Vigil ou TrustGate)."""
def __init__(self, name: str, script: Path, host: str, port: int,
extra_args: Optional[List[str]] = None):
self.name = name
self.script = script
self.host = host
self.port = port
self.extra_args = extra_args or []
self._process: Optional[subprocess.Popen] = None
def start(self) -> bool:
"""Démarre le processus. Retourne True si démarré."""
cmd = [
sys.executable, str(self.script),
"--host", self.host,
"--port", str(self.port),
] + self.extra_args
try:
env = {**os.environ, "PYTHONIOENCODING": "utf-8"}
self._process = subprocess.Popen(
cmd, env=env,
stdout=subprocess.PIPE, encoding="utf-8", errors="replace",
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
)
# Lire les premières lignes pour confirmer le démarrage
threading.Thread(
target=self._log_output,
daemon=True,
name=f"{self.name}-logger"
).start()
# Attendre max 3s pour confirmer que le process ne crashe pas immédiatement
time.sleep(0.5)
if self._process.poll() is not None:
log.error("[%s] Processus terminé prématurément (code %d)",
self.name, self._process.returncode)
return False
log.info("[%s] %s Demarre -- http://%s:%d", self.name, _OK, self.host, self.port)
return True
except Exception as e:
log.error("[%s] %s Echec demarrage : %s", self.name, _ERR, e)
return False
def _log_output(self):
if self._process and self._process.stdout:
for line in self._process.stdout:
line = line.rstrip()
if line:
log.info("[%s] %s", self.name, line)
def stop(self):
if self._process and self._process.poll() is None:
log.info("[%s] Arret en cours...", self.name)
self._process.terminate()
try:
self._process.wait(timeout=5)
except subprocess.TimeoutExpired:
self._process.kill()
log.info("[%s] %s Arrete.", self.name, _OK)
def is_running(self) -> bool:
return self._process is not None and self._process.poll() is None
@property
def url(self) -> str:
display_host = "localhost" if self.host in ("127.0.0.1", "0.0.0.0") else self.host
return f"http://{display_host}:{self.port}"
# ══════════════════════════════════════════════════════════════════════════════
# LAUNCHER PRINCIPAL
# ══════════════════════════════════════════════════════════════════════════════
class PiQryptLauncher:
"""Orchestre le démarrage et l'arrêt du stack complet."""
def __init__(self, args: argparse.Namespace):
self.args = args
self.tier = get_current_tier()
self.services: List[ServiceProcess] = []
self._stopped = False
def _resolve_script(self, *candidates: Path) -> Optional[Path]:
for c in candidates:
if c.exists():
return c
return None
def _build_services(self) -> List[ServiceProcess]:
services = []
# ── Vigil ──
if not self.args.trustgate_only:
vigil_script = self._resolve_script(
_LAUNCHER_DIR / "vigil" / "vigil_server.py",
)
if vigil_script:
services.append(ServiceProcess(
name="Vigil",
script=vigil_script,
host=DEFAULT_HOST,
port=DEFAULT_VIGIL_PORT,
))
else:
log.error("vigil_server.py introuvable -- Vigil non demarre")
# ── TrustGate ──
# --trustgate ou --all → lancer TrustGate si le tier le permet
# Note: --vigil (vigil_only) ne bloque plus --trustgate explicite
launch_tg = (
(self.args.trustgate or self.args.all)
and tier_allows_trustgate(self.tier)
)
if launch_tg:
tg_script = self._resolve_script(
_LAUNCHER_DIR / "trustgate" / "trustgate_server.py",
)
if tg_script:
tg_extra = []
# --manual ou TRUSTGATE_MODE=manual → --demo active le principal admin
_tg_mode = os.getenv("TRUSTGATE_MODE", "").lower()
if getattr(self.args, "manual", False) or _tg_mode == "manual":
tg_extra.append("--demo")
log.info("TrustGate : mode MANUEL — principal admin créé automatiquement")
services.append(ServiceProcess(
name="TrustGate",
script=tg_script,
host=DEFAULT_TRUSTGATE_HOST,
port=DEFAULT_TRUSTGATE_PORT,
extra_args=tg_extra,
))
else:
log.warning("trustgate_server.py introuvable -- TrustGate non demarre")
elif not tier_allows_trustgate(self.tier) and not self.args.vigil_only:
log.info(
"TrustGate non disponible sur le tier '%s'. "
"Disponible a partir du tier Pro -- https://piqrypt.com/pricing",
self.tier
)
return services
def run(self) -> int:
"""Lance le stack. Retourne le code de sortie."""
# ── Check config ──
want_tg = tier_allows_trustgate(self.tier) and not self.args.vigil_only
check = StartupCheck(
tier=self.tier,
want_vigil=not self.args.trustgate_only,
want_trustgate=want_tg,
)
check.print_report()
if not check.run():
return 1
if self.args.check:
return 0
# ── Démarrer les services ──
self.services = self._build_services()
if not self.services:
log.error("Aucun service a demarrer.")
return 1
print(bold("\n Demarrage du stack PiQrypt..."))
print()
started = []
for svc in self.services:
if svc.start():
started.append(svc)
else:
log.error("Echec demarrage %s -- arret.", svc.name)
self._shutdown_all()
return 1
# ── Résumé ──
print()
print(bold(" Stack PiQrypt operationnel"))
print(dim(" " + _SEP * 46))
for svc in started:
_token = (
os.getenv("VIGIL_TOKEN", "") if svc.name == "Vigil"
else os.getenv("TRUSTGATE_TOKEN", "")
)
_tg_path = "/console" if svc.name == "TrustGate" else ""
_display_url = f"{svc.url}{_tg_path}?token={_token}" if _token else svc.url
print(f" {green(_BULL)} {svc.name:<12} {cyan(_display_url)}")
tier_label = self.tier.upper()
print(f" {'Tier':<12} {bold(tier_label)}")
_auth_str = (
_OK + ' Bearer token' if os.getenv('VIGIL_TOKEN') else red(_WARN + ' non configure')
)
print(f" {'Auth':<12} {_auth_str}")
print()
print(dim(" Ctrl+C pour arreter."))
print()
# ── Graceful shutdown ──
def _shutdown(sig, frame):
if not self._stopped:
self._stopped = True
print()
log.info("Signal %d recu -- arret en cours...", sig)
self._shutdown_all()
sys.exit(0)
signal.signal(signal.SIGTERM, _shutdown)
signal.signal(signal.SIGINT, _shutdown)
# ── Boucle principale — surveiller les processus ──
try:
while True:
time.sleep(5)
for svc in started:
if not svc.is_running():
log.error(
"%s s'est arrêté de façon inattendue. "
"Relancez piqrypt_start.py.", svc.name
)
self._shutdown_all()
return 1
except KeyboardInterrupt:
pass
finally:
self._shutdown_all()
return 0
def _shutdown_all(self):
for svc in self.services:
try:
svc.stop()
except Exception as e:
log.warning("Erreur arrêt %s : %s", svc.name, e)
log.info("Stack PiQrypt arrêté.")
# ══════════════════════════════════════════════════════════════════════════════
# COMMANDES UTILITAIRES
# ══════════════════════════════════════════════════════════════════════════════
def cmd_gen_tokens():
"""Génère des tokens sécurisés pour VIGIL_TOKEN et TRUSTGATE_TOKEN."""
vigil_token = secrets.token_urlsafe(32)
trustgate_token = secrets.token_urlsafe(32)
print()
print(bold(" Tokens PiQrypt generes"))
print(dim(" " + _SEP * 50))
print()
print(" Copiez ces lignes dans votre .env ou votre shell :\n")
print(f" export VIGIL_TOKEN={vigil_token}")
print(f" export TRUSTGATE_TOKEN={trustgate_token}")
print()
print(dim(" Ces tokens ne sont pas sauvegardes -- notez-les maintenant."))
print()
# Proposer de créer un fichier .env
env_file = _LAUNCHER_DIR / ".env.piqrypt"
try:
if not env_file.exists():
env_file.write_text(
f"# PiQrypt tokens — ne jamais committer ce fichier\n"
f"VIGIL_TOKEN={vigil_token}\n"
f"TRUSTGATE_TOKEN={trustgate_token}\n"
)
print(green(f" {_OK} Fichier cree : {env_file}"))
print(dim(" Source : source .env.piqrypt (bash/zsh)"))
print()
except OSError:
pass
def cmd_status():
"""Affiche l'état de la configuration sans démarrer."""
tier = get_current_tier()
vigil_token = os.getenv("VIGIL_TOKEN", "")
tg_token = os.getenv("TRUSTGATE_TOKEN", "")
print()
print(bold(" PiQrypt Stack -- Etat de la configuration"))
print(dim(" " + _SEP * 50))
print(f" Tier : {bold(tier.upper())}")
print(f" VIGIL_TOKEN : {_OK + ' defini' if vigil_token else red(_ERR + ' absent')}")
_tg_tok_str = (
_OK + ' defini' if tg_token
else (yellow(_WARN + ' absent') if tier_allows_trustgate(tier) else dim('non requis (Free)')) # noqa: E501
)
print(f" TRUSTGATE_TOKEN: {_tg_tok_str}")
print()
try:
from aiss.license import get_license_info
info = get_license_info()
print(f" Agents max : {info.get('agents_max') or _INF}")
print(f" Events/mois : {info.get('events_month') or _INF}")
print(f" TrustGate : {info['features'].get('trustgate') or red('non disponible')}")
print(f" Quantum : {_OK if info['features'].get('quantum') else '--'}")
except Exception:
pass
print()
# ══════════════════════════════════════════════════════════════════════════════
# CLI
# ══════════════════════════════════════════════════════════════════════════════
def main():
parser = argparse.ArgumentParser(
description="PiQrypt Stack Launcher — démarre Vigil et TrustGate selon le tier",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__,
)
parser.add_argument(
"--vigil", dest="vigil_only", action="store_true",
help="Démarrer Vigil uniquement"
)
parser.add_argument(
"--trustgate", dest="trustgate", action="store_true",
help="Inclure TrustGate (Pro+ requis)"
)
parser.add_argument(
"--trustgate-only", dest="trustgate_only", action="store_true",
help="TrustGate uniquement (Pro+ requis)"
)
parser.add_argument(
"--all", action="store_true",
help="Démarrer tous les services disponibles selon le tier"
)
parser.add_argument(
"--check", action="store_true",
help="Vérifier la configuration sans démarrer"
)
parser.add_argument(
"--gen-tokens", action="store_true",
help="Générer des tokens d'authentification sécurisés"
)
parser.add_argument(
"--status", action="store_true",
help="Afficher l'état de la configuration"
)
parser.add_argument(
"--debug", action="store_true",
help="Logging verbose"
)
parser.add_argument(
"--manual", action="store_true",
help="TrustGate en mode manuel — crée un principal admin pour la Decision Queue"
)
args = parser.parse_args()
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)
# Commandes utilitaires
if args.gen_tokens:
cmd_gen_tokens()
return 0
if args.status:
cmd_status()
return 0
# Lancer le stack
launcher = PiQryptLauncher(args)
return launcher.run()
if __name__ == "__main__":
sys.exit(main())