From 70e1bebf0d562d2c76a252404b4117bed188a1ed Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 30 May 2025 15:53:03 +0200 Subject: [PATCH] vf --- localai-p2p-worker/config.yaml | 2 +- localai-p2p-worker/run.sh | 36 +++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/localai-p2p-worker/config.yaml b/localai-p2p-worker/config.yaml index d2322cc..c783fec 100644 --- a/localai-p2p-worker/config.yaml +++ b/localai-p2p-worker/config.yaml @@ -1,5 +1,5 @@ name: "LocalAI P2P Worker" -version: "1.0.4.5" +version: "1.0.4.6" slug: "localai-p2p-worker" description: "LocalAI P2P federation worker node" arch: diff --git a/localai-p2p-worker/run.sh b/localai-p2p-worker/run.sh index b043e38..265acf5 100644 --- a/localai-p2p-worker/run.sh +++ b/localai-p2p-worker/run.sh @@ -1,17 +1,39 @@ #!/bin/bash -# Sourcer bashio pour utiliser les fonctions de configuration Home Assistant -source /usr/lib/bashio/bashio +# Initialiser bashio pour utiliser les fonctions de configuration Home Assistant +# shellcheck disable=SC1091 +source /usr/lib/bashio/bashio || { + echo "Bashio not available, using direct JSON parsing" + BASHIO_AVAILABLE=false +} echo "Starting LocalAI P2P Worker" +# Fonction pour lire la configuration avec fallback +get_config() { + local key="$1" + local default="$2" + + if [ -f /data/options.json ]; then + if command -v bashio::config >/dev/null 2>&1; then + bashio::config "$key" 2>/dev/null || echo "$default" + else + # Fallback: utiliser jq pour lire directement le JSON + jq -r ".$key // \"$default\"" /data/options.json 2>/dev/null || echo "$default" + fi + else + echo "$default" + fi +} + # Lire la configuration Home Assistant if [ -f /data/options.json ]; then - TOKEN="$(bashio::config 'master_token' 2>/dev/null || echo '')" - GPU_LAYERS="$(bashio::config 'gpu_layers' 2>/dev/null || echo '0')" - DEBUG="$(bashio::config 'debug' 2>/dev/null || echo 'false')" - MODELS_PATH="$(bashio::config 'models_path' 2>/dev/null || echo '/share/localai/models')" - THREADS="$(bashio::config 'threads' 2>/dev/null || echo '8')" + echo "Reading Home Assistant configuration..." + TOKEN="$(get_config 'master_token' '')" + GPU_LAYERS="$(get_config 'gpu_layers' '0')" + DEBUG="$(get_config 'debug' 'false')" + MODELS_PATH="$(get_config 'models_path' '/share/localai/models')" + THREADS="$(get_config 'threads' '8')" echo "Master Token: $TOKEN" echo "GPU Layers: $GPU_LAYERS"