4
This commit is contained in:
@@ -1,51 +1,37 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
# Forcer l'utilisation de la configuration Home Assistant
|
||||
echo "Using Home Assistant configuration"
|
||||
# Les variables d'environnement sont automatiquement disponibles depuis les options
|
||||
echo "Starting LocalAI P2P Worker"
|
||||
echo "Master Token: $(bashio::config 'master_token')"
|
||||
echo "GPU Layers: $(bashio::config 'gpu_layers')"
|
||||
echo "Models Path: $(bashio::config 'models_path')"
|
||||
|
||||
# Vérifier que bashio est disponible
|
||||
if [ -f /usr/bin/bashio ]; then
|
||||
echo "DEBUG: bashio found, reading configuration"
|
||||
GPU_LAYERS="$(bashio config gpu_layers 2>/dev/null || echo '0')"
|
||||
TOKEN="$(bashio config master_token 2>/dev/null || echo '')"
|
||||
MODELS_PATH="$(bashio config models_path 2>/dev/null || echo '/share/localai/models')"
|
||||
else
|
||||
echo "DEBUG: bashio not found, using defaults"
|
||||
GPU_LAYERS="0"
|
||||
TOKEN=""
|
||||
MODELS_PATH="/share/localai/models"
|
||||
fi
|
||||
|
||||
echo "DEBUG: GPU_LAYERS=$GPU_LAYERS"
|
||||
echo "DEBUG: TOKEN from config: '$TOKEN'"
|
||||
echo "DEBUG: MODELS_PATH=$MODELS_PATH"
|
||||
|
||||
# Forcer l'utilisation du token si fourni
|
||||
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then
|
||||
echo "DEBUG: Setting LOCALAI_P2P_TOKEN to: $TOKEN"
|
||||
# Configurer le token P2P si fourni
|
||||
TOKEN="$(bashio::config 'master_token')"
|
||||
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ]; then
|
||||
export LOCALAI_P2P_TOKEN="$TOKEN"
|
||||
export P2P_TOKEN="$TOKEN"
|
||||
echo "P2P Token configured"
|
||||
else
|
||||
echo "DEBUG: No valid token provided in configuration"
|
||||
echo "No P2P token provided - will generate one"
|
||||
fi
|
||||
|
||||
echo "DEBUG: LOCALAI_P2P_TOKEN is set to: '$LOCALAI_P2P_TOKEN'"
|
||||
echo "DEBUG: P2P_TOKEN is set to: '$P2P_TOKEN'"
|
||||
|
||||
# Créer le répertoire des modèles s'il n'existe pas
|
||||
# Créer le répertoire des modèles
|
||||
MODELS_PATH="$(bashio::config 'models_path')"
|
||||
mkdir -p "$MODELS_PATH"
|
||||
|
||||
# Nettoyer les fichiers de configuration corrompus
|
||||
echo "DEBUG: Cleaning corrupted config files in $MODELS_PATH"
|
||||
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; | while read file; do
|
||||
echo "DEBUG: Removing corrupted file: $file"
|
||||
rm -f "$file"
|
||||
done 2>/dev/null || true
|
||||
# Nettoyer les fichiers corrompus
|
||||
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; 2>/dev/null | xargs rm -f 2>/dev/null || true
|
||||
|
||||
# Définir les variables d'environnement pour LocalAI
|
||||
export THREADS="${THREADS:-8}"
|
||||
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-8}"
|
||||
# Configurer les threads
|
||||
export THREADS="$(bashio::config 'threads' || echo '8')"
|
||||
export OMP_NUM_THREADS="$THREADS"
|
||||
|
||||
# Lancer LocalAI avec nos paramètres
|
||||
echo "DEBUG: Starting LocalAI with models-path=$MODELS_PATH, threads=$THREADS"
|
||||
exec /build/local-ai run --models-path="$MODELS_PATH" --threads="$THREADS" --address="0.0.0.0:8080" --cors --cors-allow-origins="*"
|
||||
# Lancer LocalAI
|
||||
echo "Starting LocalAI with models path: $MODELS_PATH"
|
||||
exec /usr/local/bin/local-ai run \
|
||||
--models-path="$MODELS_PATH" \
|
||||
--threads="$THREADS" \
|
||||
--address="0.0.0.0:8080" \
|
||||
--cors \
|
||||
--cors-allow-origins="*"
|
||||
|
||||
Reference in New Issue
Block a user