Files
rpa_vision_v3/server/bootstrap_local_env.sh
Dom a27b74cf22 v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40)
- Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard)
- Ollama GPU fonctionnel
- Self-healing interactif
- Dashboard confiance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:23:51 +01:00

58 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# server/bootstrap_local_env.sh
#
# Crée (si absent) et charge un fichier .env.local pour les lancements DEV.
# Objectif: éviter l'oubli des tokens (Fiche #23) + garder une expérience "plug&play".
#
# Usage:
# ./server/bootstrap_local_env.sh (depuis la racine projet)
set -euo pipefail
PROJECT_DIR="${PROJECT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
ENV_FILE="${ENV_FILE:-$PROJECT_DIR/.env.local}"
_has_cmd() { command -v "$1" >/dev/null 2>&1; }
_gen_hex_32() {
if _has_cmd openssl; then
openssl rand -hex 32
else
python3 - <<'PY'
import secrets
print(secrets.token_hex(32))
PY
fi
}
if [[ ! -f "$ENV_FILE" ]]; then
umask 077
cat >"$ENV_FILE" <<EOF
# .env.local (DEV) - généré automatiquement
ENVIRONMENT=development
# Secrets
ENCRYPTION_PASSWORD=$(_gen_hex_32)
SECRET_KEY=$(_gen_hex_32)
# Fiche #23 - tokens
RPA_TOKEN_ADMIN=$(_gen_hex_32)
RPA_TOKEN_READONLY=$(_gen_hex_32)
# Fiche #22 - admin autoheal
AUTOHEAL_ADMIN_TOKEN=$(_gen_hex_32)
# En dev on garde l'auth active pour éviter les surprises en prod
RPA_AUTH_REQUIRED=true
EOF
echo "✅ Créé: $ENV_FILE"
else
echo "✅ Env local présent: $ENV_FILE"
fi
# Charge l'env dans le process courant (si sourcé)
set -a
source "$ENV_FILE"
set +a
echo "🔑 Dashboard: http://localhost:${RPA_DASHBOARD_PORT:-5001}/?token=${RPA_TOKEN_READONLY}"
echo "🔐 API: utilisez le header Authorization: Bearer <token> (read-only ou admin)"