fix: scripts properly set ENABLED flags and all env vars for providers
Some checks failed
Deploy to Homelab / Deploy Wordly to 192.168.1.151 (push) Has been cancelled
Deploy to Homelab / Deploy Monitoring (if configured) (push) Has been cancelled

setup-env.sh:
- Each provider choice now sets its *_ENABLEED=true flag explicitly
- All provider fields written to .env (model, base_url, api_key, enabled)
- Shows active provider status in summary

manage-keys.sh:
- Each provider menu sets *_ENABLEED=true when key is added
- Sets *_ENABLEED=false when key is removed
- Writes all required env vars (model, base_url) not just API key
- Shows provider status with enabled/disabled state
- Better organized menu

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 12:52:06 +02:00
parent 034d6bfce8
commit 7e97bbd07b
2 changed files with 324 additions and 277 deletions

View File

@@ -8,7 +8,6 @@
ENV_FILE=".env"
# Couleurs
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
@@ -17,19 +16,16 @@ BOLD='\033[1m'
NC='\033[0m'
if [ ! -f "$ENV_FILE" ]; then
echo -e "${RED}Fichier .env non trouve. Lance d'abord: bash scripts/setup-env.sh${NC}"
echo -e "${RED}.env non trouve. Lance d'abord: bash scripts/setup-env.sh${NC}"
exit 1
fi
# Fonction pour lire une valeur dans .env
get_env() {
grep "^${1}=" "$ENV_FILE" 2>/dev/null | cut -d'=' -f2- || echo ""
}
# Fonction pour ecrire une valeur dans .env
set_env() {
local key="$1"
local value="$2"
local key="$1" value="$2"
if grep -q "^${key}=" "$ENV_FILE"; then
sed -i "s|^${key}=.*|${key}=${value}|" "$ENV_FILE"
else
@@ -37,29 +33,33 @@ set_env() {
fi
}
# Fonction pour effacer une valeur dans .env
clear_env() {
local key="$1"
sed -i "s|^${key}=.*|${key}=|" "$ENV_FILE"
}
# Fonction pour afficher le statut d'une cle
show_key_status() {
local name="$1"
local key="$2"
show_status() {
local name="$1" key="$2"
local value=$(get_env "$key")
if [ -n "$value" ] && [ "$value" != "" ]; then
local enabled_key="${3:-}"
local enabled=""
if [ -n "$enabled_key" ]; then
enabled=$(get_env "$enabled_key")
fi
if [ -z "$value" ]; then
echo -e " ${RED}--${NC} ${name}: ${YELLOW}non configure${NC}"
elif [ -n "$enabled_key" ] && [ "$enabled" != "true" ]; then
local masked="${value:0:8}...${value: -4}"
echo -e " ${YELLOW}!!${NC} ${name}: ${masked} ${YELLOW}(desactive)${NC}"
else
local masked="${value:0:8}...${value: -4}"
echo -e " ${GREEN}OK${NC} ${name}: ${masked}"
else
echo -e " ${RED}--${NC} ${name}: ${YELLOW}non configure${NC}"
fi
}
# Fonction pour demander une cle
ask_key() {
local name="$1"
local key="$2"
local name="$1" key="$2"
local current=$(get_env "$key")
echo ""
@@ -67,7 +67,7 @@ ask_key() {
local masked="${current:0:8}...${current: -4}"
echo -e " Actuel: ${masked}"
fi
echo -ne " ${YELLOW}Nouvelle cle (Enter pour garder, 'x' pour effacer):${NC} "
echo -ne " ${YELLOW}Nouvelle valeur (Enter = garder, 'x' = effacer):${NC} "
stty -echo 2>/dev/null || true
read -r value
stty echo 2>/dev/null || true
@@ -75,94 +75,172 @@ ask_key() {
if [ "$value" = "x" ]; then
clear_env "$key"
echo -e " ${RED}Cle supprimee${NC}"
echo -e " ${RED}Supprime${NC}"
elif [ -n "$value" ]; then
set_env "$key" "$value"
echo -e " ${GREEN}Cle mise a jour${NC}"
echo -e " ${GREEN}Mis a jour${NC}"
else
echo -e " ${CYAN}Inchange${NC}"
fi
}
ask_value() {
local name="$1" key="$2" default="$3"
local current=$(get_env "$key")
echo -ne " ${YELLOW}${name}${NC} [${current:-$default}]: "
read -r value
if [ -n "$value" ]; then
set_env "$key" "$value"
elif [ -z "$current" ] && [ -n "$default" ]; then
set_env "$key" "$default"
fi
}
restart_hint() {
echo ""
echo -e " ${YELLOW}Redemarre pour appliquer: docker compose restart backend${NC}"
}
# ===========================================
# Menu principal
# Menu
# ===========================================
while true; do
echo ""
echo -e "${CYAN}${BOLD}=========================================${NC}"
echo -e "${CYAN}${BOLD} Wordly.art - Gestion des cles API${NC}"
echo -e "${CYAN}${BOLD} Wordly - Gestion des cles API${NC}"
echo -e "${CYAN}${BOLD}=========================================${NC}"
echo ""
echo -e "${BOLD}Statut actuel :${NC}"
echo -e " Service actif: ${BOLD}$(get_env TRANSLATION_SERVICE)${NC}"
echo ""
# Traduction
echo -e " ${BOLD}Traduction :${NC}"
show_key_status "OpenAI" "OPENAI_API_KEY"
show_key_status "DeepL" "DEEPL_API_KEY"
show_key_status "OpenRouter" "OPENROUTER_API_KEY"
show_key_status "DeepSeek" "DEEPSEEK_API_KEY"
show_key_status "Minimax" "MINIMAX_API_KEY"
show_key_status "Google" "GOOGLE_API_KEY"
echo -e " ${BOLD}Providers:${NC}"
show_status "Google " "GOOGLE_TRANSLATE_ENABLED"
show_status "Ollama " "OLLAMA_BASE_URL" "OLLAMA_ENABLED"
show_status "DeepSeek " "DEEPSEEK_API_KEY" "DEEPSEEK_ENABLED"
show_status "Minimax " "MINIMAX_API_KEY" "MINIMAX_ENABLED"
show_status "DeepL " "DEEPL_API_KEY" "DEEPL_ENABLED"
show_status "OpenAI " "OPENAI_API_KEY" "OPENAI_ENABLED"
show_status "OpenRouter " "OPENROUTER_API_KEY" "OPENROUTER_ENABLED"
echo ""
# Paiement
echo -e " ${BOLD}Paiement :${NC}"
show_key_status "Stripe Secret" "STRIPE_SECRET_KEY"
show_key_status "Stripe Webhook" "STRIPE_WEBHOOK_SECRET"
show_key_status "Stripe Price Starter" "STRIPE_STARTER_PRICE_ID"
show_key_status "Stripe Price Pro" "STRIPE_PRO_PRICE_ID"
show_key_status "Stripe Price Business" "STRIPE_BUSINESS_PRICE_ID"
echo -e " ${BOLD}Stripe:${NC}"
show_status "Secret Key " "STRIPE_SECRET_KEY"
show_status "Webhook " "STRIPE_WEBHOOK_SECRET"
show_status "Starter " "STRIPE_STARTER_PRICE_ID"
show_status "Pro " "STRIPE_PRO_PRICE_ID"
show_status "Business " "STRIPE_BUSINESS_PRICE_ID"
echo ""
# Menu
echo -e "${BOLD}Actions :${NC}"
echo " 1) Configurer OpenAI"
echo " 2) Configurer DeepL"
echo " 3) Configurer OpenRouter"
echo " 4) Configurer Stripe (toutes les cles)"
echo " 5) Changer le mot de passe admin"
echo " 6) Changer le service de traduction"
echo " 7) Configurer DeepSeek"
echo " 8) Configurer Minimax (m2.7)"
echo " 9) Tout afficher (attention: secrets visibles)"
echo " 0) Quitter"
echo -e "${BOLD}Actions:${NC}"
echo " 1) DeepSeek 4) OpenAI 7) Stripe"
echo " 2) Minimax 5) DeepL 8) Mot de passe admin"
echo " 3) OpenRouter 6) Ollama 9) Changer provider par defaut"
echo ""
echo " 0) Quitter v) Voir tout (.env brut)"
echo ""
echo -ne "${YELLOW}Choix:${NC} "
read -r choice
case "$choice" in
1)
echo -e "\n${BOLD}--- OpenAI ---${NC}"
echo " Ou: https://platform.openai.com/api-keys"
ask_key "OpenAI" "OPENAI_API_KEY"
echo -e "\n${BOLD}--- DeepSeek ---${NC}"
echo " https://platform.deepseek.com/api_keys"
ask_key "API Key" "DEEPSEEK_API_KEY"
ask_value "Modele" "DEEPSEEK_MODEL" "deepseek-chat"
ask_value "Base URL" "DEEPSEEK_BASE_URL" "https://api.deepseek.com/v1"
if [ -n "$(get_env DEEPSEEK_API_KEY)" ]; then
set_env "DEEPSEEK_ENABLED" "true"
echo -e " ${GREEN}Provider DeepSeek ACTIVE${NC}"
else
set_env "DEEPSEEK_ENABLED" "false"
echo -e " ${RED}Provider DeepSeek DESACTIVE (pas de cle)${NC}"
fi
restart_hint
;;
2)
echo -e "\n${BOLD}--- DeepL ---${NC}"
echo " Ou: https://www.deepl.com/pro-api (gratuit 500k caracteres/mois)"
ask_key "DeepL" "DEEPL_API_KEY"
echo -e "\n${BOLD}--- Minimax (m2.7 / MiniMax-M1) ---${NC}"
echo " https://platform.minimaxi.com/"
ask_key "API Key" "MINIMAX_API_KEY"
ask_value "Modele" "MINIMAX_MODEL" "MiniMax-M1"
ask_value "Base URL" "MINIMAX_BASE_URL" "https://api.minimax.chat/v1"
ask_value "Group ID (optionnel)" "MINIMAX_GROUP_ID" ""
if [ -n "$(get_env MINIMAX_API_KEY)" ]; then
set_env "MINIMAX_ENABLED" "true"
echo -e " ${GREEN}Provider Minimax ACTIVE${NC}"
else
set_env "MINIMAX_ENABLED" "false"
echo -e " ${RED}Provider Minimax DESACTIVE (pas de cle)${NC}"
fi
restart_hint
;;
3)
echo -e "\n${BOLD}--- OpenRouter ---${NC}"
echo " Ou: https://openrouter.ai/keys"
ask_key "OpenRouter" "OPENROUTER_API_KEY"
echo " https://openrouter.ai/keys"
ask_key "API Key" "OPENROUTER_API_KEY"
ask_value "Modele" "OPENROUTER_MODEL" "deepseek/deepseek-chat"
if [ -n "$(get_env OPENROUTER_API_KEY)" ]; then
set_env "OPENROUTER_ENABLED" "true"
echo -e " ${GREEN}Provider OpenRouter ACTIVE${NC}"
else
set_env "OPENROUTER_ENABLED" "false"
echo -e " ${RED}Provider OpenRouter DESACTIVE${NC}"
fi
restart_hint
;;
4)
echo -e "\n${BOLD}--- Stripe ---${NC}"
echo " Ou: https://dashboard.stripe.com/apikeys"
echo " Webhooks: https://dashboard.stripe.com/webhooks"
echo " Prices: https://dashboard.stripe.com/products"
ask_key "Stripe Secret Key" "STRIPE_SECRET_KEY"
ask_key "Stripe Webhook Secret" "STRIPE_WEBHOOK_SECRET"
ask_key "Price ID Starter" "STRIPE_STARTER_PRICE_ID"
ask_key "Price ID Pro" "STRIPE_PRO_PRICE_ID"
ask_key "Price ID Business" "STRIPE_BUSINESS_PRICE_ID"
echo ""
echo -e "${GREEN}Cles Stripe configurees.${NC}"
echo -e "${YELLOW}Pense a redemarrer: docker compose restart backend${NC}"
echo -e "\n${BOLD}--- OpenAI ---${NC}"
echo " https://platform.openai.com/api-keys"
ask_key "API Key" "OPENAI_API_KEY"
ask_value "Modele" "OPENAI_MODEL" "gpt-4o-mini"
ask_value "Base URL" "OPENAI_BASE_URL" "https://api.openai.com/v1"
if [ -n "$(get_env OPENAI_API_KEY)" ]; then
set_env "OPENAI_ENABLED" "true"
echo -e " ${GREEN}Provider OpenAI ACTIVE${NC}"
else
set_env "OPENAI_ENABLED" "false"
echo -e " ${RED}Provider OpenAI DESACTIVE${NC}"
fi
restart_hint
;;
5)
echo -e "\n${BOLD}--- Changer le mot de passe admin ---${NC}"
echo -e "\n${BOLD}--- DeepL ---${NC}"
echo " https://www.deepl.com/pro-api"
ask_key "API Key" "DEEPL_API_KEY"
if [ -n "$(get_env DEEPL_API_KEY)" ]; then
set_env "DEEPL_ENABLED" "true"
echo -e " ${GREEN}Provider DeepL ACTIVE${NC}"
else
set_env "DEEPL_ENABLED" "false"
echo -e " ${RED}Provider DeepL DESACTIVE${NC}"
fi
restart_hint
;;
6)
echo -e "\n${BOLD}--- Ollama (local) ---${NC}"
ask_value "URL" "OLLAMA_BASE_URL" "http://ollama:11434"
ask_value "Modele" "OLLAMA_MODEL" "llama3"
set_env "OLLAMA_ENABLED" "true"
echo -e " ${GREEN}Provider Ollama ACTIVE${NC}"
restart_hint
;;
7)
echo -e "\n${BOLD}--- Stripe ---${NC}"
echo " Dashboard: https://dashboard.stripe.com"
echo " API Keys: https://dashboard.stripe.com/apikeys"
echo " Webhooks: https://dashboard.stripe.com/webhooks"
echo " Products: https://dashboard.stripe.com/products"
echo ""
echo -e " ${CYAN}Mode test: utilise sk_test_... pour tester${NC}"
echo -e " ${CYAN}Carte test: 4242 4242 4242 4242${NC}"
echo ""
ask_key "Secret Key (sk_...)" "STRIPE_SECRET_KEY"
ask_key "Webhook Secret (whsec_...)" "STRIPE_WEBHOOK_SECRET"
ask_key "Price ID Starter (price_...)" "STRIPE_STARTER_PRICE_ID"
ask_key "Price ID Pro (price_...)" "STRIPE_PRO_PRICE_ID"
ask_key "Price ID Business (price_...)" "STRIPE_BUSINESS_PRICE_ID"
echo ""
echo -e " ${GREEN}Stripe configure${NC}"
restart_hint
;;
8)
echo -e "\n${BOLD}--- Mot de passe admin ---${NC}"
echo -ne " Nouveau mot de passe: "
stty -echo 2>/dev/null || true
read -r new_pass
@@ -175,11 +253,11 @@ while true; do
echo ""
if [ "$new_pass" != "$new_pass2" ]; then
echo -e " ${RED}Les mots de passe ne correspondent pas${NC}"
echo -e " ${RED}Ne correspondent pas${NC}"
elif [ -z "$new_pass" ]; then
echo -e " ${RED}Mot de passe vide${NC}"
echo -e " ${RED}Vide${NC}"
else
echo -e " ${CYAN}Generation du hash...${NC}"
echo -e " ${CYAN}Generation bcrypt...${NC}"
NEW_HASH=$(docker run --rm python:3.12-slim bash -c \
"pip install 'passlib[bcrypt]' bcrypt > /dev/null 2>&1 && \
python3 -c \"from passlib.context import CryptContext; \
@@ -187,69 +265,48 @@ while true; do
if [ -n "$NEW_HASH" ]; then
set_env "ADMIN_PASSWORD_HASH" "$NEW_HASH"
echo -e " ${GREEN}Mot de passe mis a jour${NC}"
echo -e " ${YELLOW}Redemarre le backend: docker compose restart backend${NC}"
restart_hint
else
echo -e " ${RED}Erreur lors de la generation du hash${NC}"
echo -e " ${RED}Erreur generation hash${NC}"
fi
fi
;;
6)
echo -e "\n${BOLD}--- Service de traduction ---${NC}"
9)
echo -e "\n${BOLD}--- Provider par defaut ---${NC}"
echo " Actuel: $(get_env TRANSLATION_SERVICE)"
echo " 1) ollama (local, gratuit)"
echo " 2) deepl (haute qualite)"
echo " 3) openai (GPT)"
echo " 4) openrouter (multi-modeles)"
echo " 5) deepseek (bon rapport qualite/prix)"
echo " 6) minimax (MiniMax-M1 / m2.7)"
echo ""
echo " 1) google 5) deepseek"
echo " 2) ollama 6) minimax"
echo " 3) deepl 7) openrouter"
echo " 4) openai"
echo ""
echo -ne " Choix: "
read -r svc
case "$svc" in
1) set_env "TRANSLATION_SERVICE" "ollama" ;;
2) set_env "TRANSLATION_SERVICE" "deepl" ;;
3) set_env "TRANSLATION_SERVICE" "openai" ;;
4) set_env "TRANSLATION_SERVICE" "openrouter" ;;
1) set_env "TRANSLATION_SERVICE" "google" ;;
2) set_env "TRANSLATION_SERVICE" "ollama" ;;
3) set_env "TRANSLATION_SERVICE" "deepl" ;;
4) set_env "TRANSLATION_SERVICE" "openai" ;;
5) set_env "TRANSLATION_SERVICE" "deepseek" ;;
6) set_env "TRANSLATION_SERVICE" "minimax" ;;
*) echo -e " ${RED}Choix invalide${NC}" ;;
7) set_env "TRANSLATION_SERVICE" "openrouter" ;;
*) echo -e " ${RED}Invalide${NC}" ;;
esac
echo -e " ${GREEN}Service mis a jour${NC}"
echo -e " ${YELLOW}Redemarre: docker compose restart backend${NC}"
echo -e " ${GREEN}Provider par defaut: $(get_env TRANSLATION_SERVICE)${NC}"
restart_hint
;;
7)
echo -e "\n${BOLD}--- DeepSeek ---${NC}"
echo " Ou: https://platform.deepseek.com/api_keys"
echo " Modele par defaut: deepseek-chat"
ask_key "DeepSeek" "DEEPSEEK_API_KEY"
if [ -n "$(get_env DEEPSEEK_API_KEY)" ]; then
set_env "DEEPSEEK_ENABLED" "true"
echo -e " ${GREEN}Provider DeepSeek active${NC}"
fi
;;
8)
echo -e "\n${BOLD}--- Minimax (m2.7 / MiniMax-M1) ---${NC}"
echo " Ou: https://platform.minimaxi.com/"
echo " Modele par defaut: MiniMax-M1"
ask_key "Minimax" "MINIMAX_API_KEY"
if [ -n "$(get_env MINIMAX_API_KEY)" ]; then
set_env "MINIMAX_ENABLED" "true"
echo -e " ${GREEN}Provider Minimax active${NC}"
fi
;;
9)
v)
echo ""
echo -e "${RED}${BOLD}ATTENTION: Secrets visibles!${NC}"
echo -ne "${YELLOW}Taper 'oui' pour continuer:${NC} "
echo -ne "${YELLOW}Taper 'oui':${NC} "
read -r confirm
if [ "$confirm" = "oui" ]; then
echo ""
cat "$ENV_FILE" | grep -v "^#" | grep -v "^$"
grep -v "^#" "$ENV_FILE" | grep -v "^$"
fi
;;
0)
echo ""
echo -e "${GREEN}Au revoir!${NC}"
echo -e "\n${GREEN}Au revoir!${NC}"
exit 0
;;
*)

View File

@@ -2,13 +2,11 @@
# ============================================
# Wordly.art - Configuration Wizard
# ============================================
# Script interactif pour configurer le .env
# Lancer sur le serveur: bash scripts/setup-env.sh
# Usage: bash scripts/setup-env.sh
# ============================================
set -e
# Couleurs
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
@@ -24,43 +22,30 @@ echo -e "${CYAN}${BOLD} Wordly.art - Configuration Wizard${NC}"
echo -e "${CYAN}${BOLD}=========================================${NC}"
echo ""
# Verifier qu'on est dans le bon dossier
if [ ! -f "docker-compose.yml" ]; then
echo -e "${RED}Erreur: lance ce script depuis la racine du projet (cd /opt/wordly)${NC}"
echo "Usage: bash scripts/setup-env.sh"
exit 1
fi
# Fonction pour demander une valeur avec defaut
ask() {
local prompt="$1"
local default="$2"
local varname="$3"
local required="$4"
local prompt="$1" default="$2" varname="$3" required="$4"
if [ -n "$default" ]; then
echo -ne "${YELLOW}${prompt}${NC} [${default}]: "
else
echo -ne "${YELLOW}${prompt}${NC}: "
fi
read -r answer
answer="${answer:-$default}"
if [ "$required" = "true" ] && [ -z "$answer" ]; then
echo -e "${RED}Cette valeur est obligatoire!${NC}"
ask "$prompt" "$default" "$varname" "$required"
return
fi
eval "$varname=\"\$answer\""
}
# Fonction pour demander un mot de passe cache
ask_password() {
local prompt="$1"
local varname="$2"
local prompt="$1" varname="$2"
echo -ne "${YELLOW}${prompt}${NC}: "
stty -echo 2>/dev/null || true
read -r answer
@@ -69,26 +54,20 @@ ask_password() {
eval "$varname=\"\$answer\""
}
# Fonction pour generer un secret
generate_secret() {
python3 -c "import secrets; print(secrets.token_urlsafe(64))" 2>/dev/null || \
openssl rand -base64 48 | tr -d '\n'
python3 -c "import secrets; print(secrets.token_urlsafe(64))" 2>/dev/null || openssl rand -base64 48 | tr -d '\n'
}
generate_hex() {
python3 -c "import secrets; print(secrets.token_hex(32))" 2>/dev/null || \
openssl rand -hex 32
python3 -c "import secrets; print(secrets.token_hex(32))" 2>/dev/null || openssl rand -hex 32
}
generate_password() {
python3 -c "import secrets; print(secrets.token_urlsafe(32))" 2>/dev/null || \
openssl rand -base64 24 | tr -d '\n'
python3 -c "import secrets; print(secrets.token_urlsafe(32))" 2>/dev/null || openssl rand -base64 24 | tr -d '\n'
}
# ===========================================
# ETAPE 1 : Domaine
# ===========================================
echo -e "${BOLD}--- Domaine & DNS ---${NC}"
echo -e "${BOLD}--- Domaine ---${NC}"
echo ""
ask "Nom de domaine" "wordly.art" DOMAIN true
@@ -96,11 +75,11 @@ ask "Nom de domaine" "wordly.art" DOMAIN true
# ETAPE 2 : Base de donnees
# ===========================================
echo ""
echo -e "${BOLD}--- Base de donnees PostgreSQL ---${NC}"
echo -e "${BOLD}--- Base de donnees ---${NC}"
echo ""
ask "Utilisateur PostgreSQL" "translate" POSTGRES_USER true
POSTGRES_PASSWORD=$(generate_password)
echo -e " ${GREEN}Mot de passe genere automatiquement${NC}"
echo -e " ${GREEN}Mot de passe DB genere${NC}"
# ===========================================
# ETAPE 3 : Admin
@@ -109,10 +88,10 @@ echo ""
echo -e "${BOLD}--- Compte Administrateur ---${NC}"
echo ""
ask "Nom d'utilisateur admin" "admin" ADMIN_USERNAME true
ask_password "Mot de passe admin (cache)" ADMIN_PASSWORD
ask_password "Mot de passe admin" ADMIN_PASSWORD
if [ -z "$ADMIN_PASSWORD" ]; then
echo -e "${RED}Le mot de passe admin est obligatoire!${NC}"
ask_password "Mot de passe admin (cache)" ADMIN_PASSWORD
ask_password "Mot de passe admin" ADMIN_PASSWORD
fi
echo ""
ask_password "Confirmer le mot de passe" ADMIN_PASSWORD_CONFIRM
@@ -122,29 +101,26 @@ if [ "$ADMIN_PASSWORD" != "$ADMIN_PASSWORD_CONFIRM" ]; then
fi
echo -e " ${GREEN}Mot de passe confirme${NC}"
# Generer le hash bcrypt
echo -e " ${CYAN}Generation du hash bcrypt...${NC}"
ADMIN_PASSWORD_HASH=""
if command -v docker &> /dev/null; then
ADMIN_PASSWORD_HASH=$(docker run --rm python:3.12-slim bash -c \
"pip install 'passlib[bcrypt]' bcrypt > /dev/null 2>&1 && \
python3 -c \"from passlib.context import CryptContext; \
print(CryptContext(schemes=['bcrypt']).hash('${ADMIN_PASSWORD}'))\"" 2>/dev/null)
fi
if [ -z "$ADMIN_PASSWORD_HASH" ]; then
echo -e " ${YELLOW}Impossible de generer le hash bcrypt automatiquement.${NC}"
echo -e " ${YELLOW}Tu devras le generer manuellement plus tard.${NC}"
echo -e " ${YELLOW}Hash bcrypt non genere. Tu devras le faire manuellement.${NC}"
ADMIN_PASSWORD_HASH="CHANGE_WITH_BCRYPT_HASH"
else
echo -e " ${GREEN}Hash bcrypt genere${NC}"
fi
# ===========================================
# ETAPE 4 : Secrets
# ETAPE 4 : Secrets auto
# ===========================================
echo ""
echo -e "${BOLD}--- Secrets de securite ---${NC}"
echo -e " ${CYAN}Generation automatique des secrets...${NC}"
echo -e "${BOLD}--- Secrets de securite (auto) ---${NC}"
JWT_SECRET_KEY=$(generate_secret)
ADMIN_TOKEN_SECRET=$(generate_hex)
echo -e " ${GREEN}JWT_SECRET_KEY genere${NC}"
@@ -154,59 +130,80 @@ echo -e " ${GREEN}ADMIN_TOKEN_SECRET genere${NC}"
# ETAPE 5 : Services de traduction
# ===========================================
echo ""
echo -e "${BOLD}--- Services de traduction ---${NC}"
echo -e "${BOLD}--- Service de traduction ---${NC}"
echo ""
echo "Quel service de traduction par defaut ?"
echo " 1) ollama (local, gratuit)"
echo " 2) google (API gratuite via deep_translator)"
echo " 3) deepl (haute qualite, 500k car/mois gratuit)"
echo " 4) openai (GPT, payant)"
echo " 5) openrouter (multi-modeles, payant)"
echo " 6) deepseek (tres bon rapport qualite/prix)"
echo " 7) minimax (MiniMax-M1 / m2.7, payant)"
echo "Quel service par defaut ?"
echo " 1) google (gratuit, aucune cle)"
echo " 2) ollama (local, gratuit,需要一个 GPU)"
echo " 3) deepseek (tres bon rapport Q/P, ~0.14$/M tokens)"
echo " 4) minimax (MiniMax-M1 / m2.7)"
echo " 5) deepl (haute qualite, 500k car/mois gratuit)"
echo " 6) openai (GPT, payant)"
echo " 7) openrouter (multi-modeles)"
ask "Choix (1-7)" "1" TRANSLATION_CHOICE
case "$TRANSLATION_CHOICE" in
1) TRANSLATION_SERVICE="ollama" ;;
2) TRANSLATION_SERVICE="google" ;;
3) TRANSLATION_SERVICE="deepl" ;;
4) TRANSLATION_SERVICE="openai" ;;
5) TRANSLATION_SERVICE="openrouter" ;;
6) TRANSLATION_SERVICE="deepseek" ;;
7) TRANSLATION_SERVICE="minimax" ;;
*) TRANSLATION_SERVICE="ollama" ;;
esac
# Initialiser tous les flags a false
GOOGLE_ENABLED="true"
OLLAMA_ENABLED="false"
OLLAMA_BASE_URL="http://ollama:11434"
OLLAMA_MODEL="llama3"
DEEPL_ENABLED="false"
DEEPL_API_KEY=""
OPENAI_ENABLED="false"
OPENAI_API_KEY=""
OPENAI_MODEL="gpt-4o-mini"
OPENAI_BASE_URL="https://api.openai.com/v1"
OPENROUTER_ENABLED="false"
OPENROUTER_API_KEY=""
OPENROUTER_MODEL="deepseek/deepseek-chat"
DEEPSEEK_ENABLED="false"
DEEPSEEK_API_KEY=""
DEEPSEEK_MODEL="deepseek-chat"
DEEPSEEK_BASE_URL="https://api.deepseek.com/v1"
MINIMAX_ENABLED="false"
MINIMAX_API_KEY=""
MINIMAX_MODEL="MiniMax-M1"
MINIMAX_BASE_URL="https://api.minimax.chat/v1"
if [ "$TRANSLATION_SERVICE" = "ollama" ]; then
case "$TRANSLATION_CHOICE" in
1) TRANSLATION_SERVICE="google" ;;
2)
TRANSLATION_SERVICE="ollama"
OLLAMA_ENABLED="true"
ask "URL Ollama" "http://ollama:11434" OLLAMA_BASE_URL
ask "Modele Ollama" "llama3" OLLAMA_MODEL
fi
if [ "$TRANSLATION_SERVICE" = "deepl" ] || [ "$TRANSLATION_SERVICE" = "all" ]; then
ask "Cle API DeepL (laisser vide si pas maintenant)" "" DEEPL_API_KEY
fi
if [ "$TRANSLATION_SERVICE" = "openai" ] || [ "$TRANSLATION_SERVICE" = "all" ]; then
ask "Cle API OpenAI (laisser vide si pas maintenant)" "" OPENAI_API_KEY
fi
if [ "$TRANSLATION_SERVICE" = "openrouter" ] || [ "$TRANSLATION_SERVICE" = "all" ]; then
ask "Cle API OpenRouter (laisser vide si pas maintenant)" "" OPENROUTER_API_KEY
fi
if [ "$TRANSLATION_SERVICE" = "deepseek" ] || [ "$TRANSLATION_SERVICE" = "all" ]; then
ask "Cle API DeepSeek (laisser vide si pas maintenant)" "" DEEPSEEK_API_KEY
fi
if [ "$TRANSLATION_SERVICE" = "minimax" ] || [ "$TRANSLATION_SERVICE" = "all" ]; then
ask "Cle API Minimax (laisser vide si pas maintenant)" "" MINIMAX_API_KEY
fi
;;
3)
TRANSLATION_SERVICE="deepseek"
DEEPSEEK_ENABLED="true"
ask "Cle API DeepSeek" "" DEEPSEEK_API_KEY true
ask "Modele DeepSeek" "deepseek-chat" DEEPSEEK_MODEL
;;
4)
TRANSLATION_SERVICE="minimax"
MINIMAX_ENABLED="true"
ask "Cle API Minimax" "" MINIMAX_API_KEY true
ask "Modele Minimax" "MiniMax-M1" MINIMAX_MODEL
;;
5)
TRANSLATION_SERVICE="deepl"
DEEPL_ENABLED="true"
ask "Cle API DeepL" "" DEEPL_API_KEY true
;;
6)
TRANSLATION_SERVICE="openai"
OPENAI_ENABLED="true"
ask "Cle API OpenAI" "" OPENAI_API_KEY true
ask "Modele OpenAI" "gpt-4o-mini" OPENAI_MODEL
;;
7)
TRANSLATION_SERVICE="openrouter"
OPENROUTER_ENABLED="true"
ask "Cle API OpenRouter" "" OPENROUTER_API_KEY true
ask "Modele OpenRouter" "deepseek/deepseek-chat" OPENROUTER_MODEL
;;
*) TRANSLATION_SERVICE="google" ;;
esac
# ===========================================
# ETAPE 6 : Monitoring
@@ -219,11 +216,12 @@ GRAFANA_PASSWORD=$(generate_password)
echo -e " ${GREEN}Mot de passe Grafana genere: ${GRAFANA_PASSWORD}${NC}"
# ===========================================
# ETAPE 7 : Stripe (optionnel)
# ETAPE 7 : Stripe
# ===========================================
echo ""
echo -e "${BOLD}--- Paiements Stripe (optionnel) ---${NC}"
echo ""
echo " Tu peux configurer Stripe plus tard avec: bash scripts/manage-keys.sh"
ask "Configurer Stripe maintenant ? (oui/non)" "non" SETUP_STRIPE
STRIPE_SECRET_KEY=""
STRIPE_WEBHOOK_SECRET=""
@@ -232,11 +230,11 @@ STRIPE_PRO_PRICE_ID=""
STRIPE_BUSINESS_PRICE_ID=""
if [ "$SETUP_STRIPE" = "oui" ]; then
ask "Cle secrete Stripe (sk_live_...)" "" STRIPE_SECRET_KEY
ask "Cle secrete Stripe (sk_live_... ou sk_test_...)" "" STRIPE_SECRET_KEY
ask "Webhook secret (whsec_...)" "" STRIPE_WEBHOOK_SECRET
ask "Price ID Starter" "" STRIPE_STARTER_PRICE_ID
ask "Price ID Pro" "" STRIPE_PRO_PRICE_ID
ask "Price ID Business" "" STRIPE_BUSINESS_PRICE_ID
ask "Price ID Starter (price_...)" "" STRIPE_STARTER_PRICE_ID
ask "Price ID Pro (price_...)" "" STRIPE_PRO_PRICE_ID
ask "Price ID Business (price_...)" "" STRIPE_BUSINESS_PRICE_ID
fi
# ===========================================
@@ -251,35 +249,42 @@ echo -e " Domaine: ${BOLD}${DOMAIN}${NC}"
echo -e " Traduction: ${BOLD}${TRANSLATION_SERVICE}${NC}"
echo -e " DB User: ${BOLD}${POSTGRES_USER}${NC}"
echo -e " Admin: ${BOLD}${ADMIN_USERNAME}${NC}"
echo -e " Admin hash: ${BOLD}${ADMIN_PASSWORD_HASH:0:20}...${NC}"
echo -e " JWT Secret: ${BOLD}${JWT_SECRET_KEY:0:20}...${NC}"
echo -e " Admin Token: ${BOLD}${ADMIN_TOKEN_SECRET:0:20}...${NC}"
echo -e " Grafana: ${BOLD}${GRAFANA_USER} / ${GRAFANA_PASSWORD}${NC}"
echo ""
echo -e " Providers actifs:"
echo -e " Google: ${GREEN}toujours actif${NC}"
echo -e " Ollama: $([ "$OLLAMA_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo -e " DeepSeek: $([ "$DEEPSEEK_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo -e " Minimax: $([ "$MINIMAX_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo -e " DeepL: $([ "$DEEPL_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo -e " OpenAI: $([ "$OPENAI_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo -e " OpenRouter: $([ "$OPENROUTER_ENABLED" = "true" ] && echo "${GREEN}ON${NC}" || echo "${RED}OFF${NC}")"
echo ""
if [ -n "$STRIPE_SECRET_KEY" ]; then
echo -e " Stripe: ${GREEN}Configure${NC}"
else
echo -e " Stripe: ${YELLOW}Non configure${NC}"
echo -e " Stripe: ${YELLOW}Non configure (gerer plus tard)${NC}"
fi
echo ""
# Confirmation
ask "Cette configuration est correcte ? (oui/non)" "oui" CONFIRM
ask "Valider cette configuration ? (oui/non)" "oui" CONFIRM
if [ "$CONFIRM" != "oui" ]; then
echo "Annule. Relance le script pour recommencer."
echo "Annule."
exit 0
fi
# ===========================================
# GENERATION DU FICHIER .env
# ECRITURE DU .env
# ===========================================
echo ""
echo -e "${CYAN}Generation du fichier .env...${NC}"
echo -e "${CYAN}Ecriture du fichier .env...${NC}"
cat > "$ENV_FILE" <<ENVEOF
cat > "$ENV_FILE" <<EOF
# ============================================
# Wordly.art - Environnement de production
# Genere automatiquement le $(date +"%Y-%m-%d a %H:%M")
# Genere le $(date +"%Y-%m-%d a %H:%M")
# ============================================
# Application
@@ -296,24 +301,43 @@ NEXT_PUBLIC_API_URL=https://${DOMAIN}
BACKEND_PORT=8000
FRONTEND_PORT=3000
# Traduction
# ===== TRADUCTION =====
TRANSLATION_SERVICE=${TRANSLATION_SERVICE}
OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://ollama:11434}
OLLAMA_MODEL=${OLLAMA_MODEL:-llama3}
DEEPL_API_KEY=${DEEPL_API_KEY}
OPENAI_API_KEY=${OPENAI_API_KEY}
OPENAI_MODEL=gpt-4o-mini
OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
# Google (toujours actif, gratuit)
GOOGLE_TRANSLATE_ENABLED=true
# Ollama (local LLM)
OLLAMA_ENABLED=${OLLAMA_ENABLED}
OLLAMA_BASE_URL=${OLLAMA_BASE_URL}
OLLAMA_MODEL=${OLLAMA_MODEL}
# DeepSeek
DEEPSEEK_ENABLED=${DEEPSEEK_ENABLED:-false}
DEEPSEEK_ENABLED=${DEEPSEEK_ENABLED}
DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
DEEPSEEK_MODEL=deepseek-chat
DEEPSEEK_MODEL=${DEEPSEEK_MODEL}
DEEPSEEK_BASE_URL=${DEEPSEEK_BASE_URL}
# Minimax (m2.7 / MiniMax-M1)
MINIMAX_ENABLED=${MINIMAX_ENABLED:-false}
MINIMAX_ENABLED=${MINIMAX_ENABLED}
MINIMAX_API_KEY=${MINIMAX_API_KEY}
MINIMAX_MODEL=MiniMax-M1
MINIMAX_MODEL=${MINIMAX_MODEL}
MINIMAX_BASE_URL=${MINIMAX_BASE_URL}
# DeepL
DEEPL_ENABLED=${DEEPL_ENABLED}
DEEPL_API_KEY=${DEEPL_API_KEY}
# OpenAI
OPENAI_ENABLED=${OPENAI_ENABLED}
OPENAI_API_KEY=${OPENAI_API_KEY}
OPENAI_MODEL=${OPENAI_MODEL}
OPENAI_BASE_URL=${OPENAI_BASE_URL}
# OpenRouter
OPENROUTER_ENABLED=${OPENROUTER_ENABLED}
OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
OPENROUTER_MODEL=${OPENROUTER_MODEL}
# Upload
MAX_FILE_SIZE_MB=50
@@ -348,53 +372,19 @@ STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
STRIPE_STARTER_PRICE_ID=${STRIPE_STARTER_PRICE_ID}
STRIPE_PRO_PRICE_ID=${STRIPE_PRO_PRICE_ID}
STRIPE_BUSINESS_PRICE_ID=${STRIPE_BUSINESS_PRICE_ID}
ENVEOF
EOF
# Securiser le fichier
chmod 600 "$ENV_FILE"
echo -e "${GREEN}Fichier .env cree avec succes!${NC}"
echo -e "${GREEN}.env ecrit avec succes!${NC}"
echo ""
# ===========================================
# PROPOSITIONS FINALES
# ===========================================
echo -e "${BOLD}Prochaines etapes :${NC}"
echo " 1. Verifier: ${CYAN}cat .env${NC}"
echo " 2. Lancer: ${CYAN}docker compose up -d --build${NC}"
echo " 3. Tester: ${CYAN}curl http://localhost:8000/health${NC}"
echo " 4. Monitorer: ${CYAN}docker compose ps${NC}"
echo ""
echo -e " 1. Verifier le fichier:"
echo -e " ${CYAN}cat .env${NC}"
echo ""
echo -e " 2. Lancer l'application:"
echo -e " ${CYAN}docker compose up -d --build${NC}"
echo ""
echo -e " 3. Verifier que tout tourne:"
echo -e " ${CYAN}docker compose ps${NC}"
echo -e " ${CYAN}curl http://localhost:8000/health${NC}"
echo ""
echo -e " 4. Lancer le monitoring:"
echo -e " ${CYAN}docker compose -f docker-compose.yml -f docker-compose.monitoring.yml up -d${NC}"
echo ""
# Sauvegarder les infos importantes dans un fichier temp
INFO_FILE="/tmp/wordly-setup-info.txt"
cat > "$INFO_FILE" <<INFOEOF
========================================
Wordly.art - Infos de configuration
Genere le $(date)
========================================
Domaine: ${DOMAIN}
Admin: ${ADMIN_USERNAME}
Grafana: ${GRAFANA_USER} / ${GRAFANA_PASSWORD}
DB Password: ${POSTGRES_PASSWORD}
ATTENTION: Ce fichier contient des secrets!
Supprime-le apres avoir note les infos: rm ${INFO_FILE}
========================================
INFOEOF
chmod 600 "$INFO_FILE"
echo -e "${YELLOW}Infos sensibles sauvegardees dans ${INFO_FILE}${NC}"
echo -e "${YELLOW}Supprime ce fichier apres note: rm ${INFO_FILE}${NC}"
echo -e "${YELLOW}Pour ajouter/modifier des cles API plus tard:${NC}"
echo " ${CYAN}bash scripts/manage-keys.sh${NC}"
echo ""
echo -e "${GREEN}${BOLD}Configuration terminee!${NC}"