From 2fac1cf8b835815d0fcc441cb7c74338b48bb94c Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 11:31:13 +0200 Subject: [PATCH 01/10] Add git reloading --- .../rootfs/etc/cont-init.d/99-nginx-config.sh | 6 ++ cookcli/rootfs/etc/services.d/git-sync/run | 74 ++----------------- .../rootfs/etc/services.d/reload-listener/run | 2 + cookcli/rootfs/usr/local/bin/git-sync-now.sh | 31 ++++++++ cookcli/rootfs/usr/local/bin/reload-http.sh | 11 +++ 5 files changed, 56 insertions(+), 68 deletions(-) create mode 100644 cookcli/rootfs/etc/services.d/reload-listener/run create mode 100644 cookcli/rootfs/usr/local/bin/git-sync-now.sh create mode 100644 cookcli/rootfs/usr/local/bin/reload-http.sh diff --git a/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh index baf940a..6bce255 100644 --- a/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh +++ b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh @@ -55,6 +55,12 @@ http { proxy_redirect http://127.0.0.1:9081/ \$scheme://\$host${INGRESS_PATH}/; proxy_redirect http://127.0.0.1:9081 \$scheme://\$host${INGRESS_PATH}; } + + location = /api/reload { + limit_except POST { deny all; } + proxy_pass http://127.0.0.1:8098; + proxy_read_timeout 120s; + } } } diff --git a/cookcli/rootfs/etc/services.d/git-sync/run b/cookcli/rootfs/etc/services.d/git-sync/run index e6429c5..809bb08 100644 --- a/cookcli/rootfs/etc/services.d/git-sync/run +++ b/cookcli/rootfs/etc/services.d/git-sync/run @@ -1,70 +1,8 @@ #!/usr/bin/with-contenv bashio -set -e +INTERVAL=$(bashio::config 'git_sync_interval') +[ -z "$INTERVAL" ] || [ "$INTERVAL" -eq 0 ] && INTERVAL=3600 -# --- Fonction de synchronisation Git --- -sync_git() { - local REPO=$(bashio::config 'git_repository') - local BRANCH=$(bashio::config 'git_branch') - local USERNAME=$(bashio::config 'git_username') - local PASSWORD=$(bashio::config 'git_password') - local RECIPES_PATH=/config/recipes - - if [ -z "$REPO" ]; then - bashio::log.info "Aucun dépôt Git configuré. Attente..." - sleep infinity - return - fi - - bashio::log.info "Synchronisation avec ${REPO} (branche: ${BRANCH})" - - # Construction de l'URL avec authentification si nécessaire - local AUTH_URL="$REPO" - if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then - # Supposons que l'URL est de type https://github.com/user/repo.git - local PROTOCOL="https://" - local REPO_WITHOUT_PROTOCOL="${REPO#https://}" - REPO_WITHOUT_PROTOCOL="${REPO_WITHOUT_PROTOCOL#http://}" - AUTH_URL="${PROTOCOL}${USERNAME}:${PASSWORD}@${REPO_WITHOUT_PROTOCOL}" - bashio::log.info "Authentification configurée pour ${USERNAME}" - fi - - # Clone ou pull - if [ ! -d "$RECIPES_PATH/.git" ]; then - bashio::log.info "Premier clone du dépôt..." - git clone --branch "$BRANCH" "$AUTH_URL" "$RECIPES_PATH" 2>&1 | bashio::log.info - else - bashio::log.info "Mise à jour du dépôt existant..." - cd "$RECIPES_PATH" - # Réinitialisation pour éviter les conflits - git fetch origin "$BRANCH" 2>&1 | bashio::log.info - git reset --hard "origin/$BRANCH" 2>&1 | bashio::log.info - cd - > /dev/null - fi - - bashio::log.info "Synchronisation Git terminée." -} - -# --- Fonction de synchronisation périodique --- -periodic_sync() { - local INTERVAL=$(bashio::config 'git_sync_interval') - if [ -z "$INTERVAL" ] || [ "$INTERVAL" -eq 0 ]; then - INTERVAL=3600 - fi - - bashio::log.info "Synchronisation périodique configurée toutes les ${INTERVAL}s" - - while true; do - sleep "$INTERVAL" - bashio::log.info "=== Synchronisation Git périodique ===" - sync_git - done -} - -# --- Exécution --- -bashio::log.info "=== Service de synchronisation Git ===" - -# Premier sync au démarrage -sync_git - -# Lancement du sync périodique en arrière-plan -periodic_sync \ No newline at end of file +while true; do + /usr/local/bin/git-sync-now.sh || bashio::log.warning "Échec de la synchro Git" + sleep "$INTERVAL" +done \ No newline at end of file diff --git a/cookcli/rootfs/etc/services.d/reload-listener/run b/cookcli/rootfs/etc/services.d/reload-listener/run new file mode 100644 index 0000000..c3dfa39 --- /dev/null +++ b/cookcli/rootfs/etc/services.d/reload-listener/run @@ -0,0 +1,2 @@ +#!/usr/bin/with-contenv bashio +exec socat TCP-LISTEN:8098,bind=127.0.0.1,fork,reuseaddr EXEC:/usr/local/bin/reload-http.sh \ No newline at end of file diff --git a/cookcli/rootfs/usr/local/bin/git-sync-now.sh b/cookcli/rootfs/usr/local/bin/git-sync-now.sh new file mode 100644 index 0000000..0dc6654 --- /dev/null +++ b/cookcli/rootfs/usr/local/bin/git-sync-now.sh @@ -0,0 +1,31 @@ +#!/usr/bin/with-contenv bashio +RECIPES_PATH=/config/recipes + +exec 9>/tmp/git-sync.lock +flock -n 9 || { bashio::log.info "Synchro déjà en cours"; exit 0; } + +REPO=$(bashio::config 'git_repository') +BRANCH=$(bashio::config 'git_branch') +USERNAME=$(bashio::config 'git_username') +PASSWORD=$(bashio::config 'git_password') + +if [ -z "$REPO" ]; then + bashio::log.info "Aucun dépôt Git configuré." + exit 0 +fi + +AUTH_URL="$REPO" +if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then + STRIPPED="${REPO#https://}"; STRIPPED="${STRIPPED#http://}" + AUTH_URL="https://${USERNAME}:${PASSWORD}@${STRIPPED}" +fi + +if [ ! -d "$RECIPES_PATH/.git" ]; then + bashio::log.info "Premier clone du dépôt..." + git clone --branch "$BRANCH" "$AUTH_URL" "$RECIPES_PATH" +else + bashio::log.info "Mise à jour du dépôt existant..." + git -C "$RECIPES_PATH" fetch origin "$BRANCH" + git -C "$RECIPES_PATH" reset --hard "origin/$BRANCH" +fi +bashio::log.info "Synchronisation Git terminée." \ No newline at end of file diff --git a/cookcli/rootfs/usr/local/bin/reload-http.sh b/cookcli/rootfs/usr/local/bin/reload-http.sh new file mode 100644 index 0000000..9d6fe98 --- /dev/null +++ b/cookcli/rootfs/usr/local/bin/reload-http.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# Consomme la requête jusqu'à la ligne vide +while IFS= read -r line; do line="${line%$'\r'}"; [ -z "$line" ] && break; done + +if /usr/local/bin/git-sync-now.sh >/dev/null 2>&1; then + status="200 OK"; body='{"status":"ok"}' +else + status="500 Internal Server Error"; body='{"status":"error"}' +fi +printf 'HTTP/1.1 %s\r\nContent-Type: application/json\r\nContent-Length: %d\r\nConnection: close\r\n\r\n%s' \ + "$status" "${#body}" "$body" \ No newline at end of file -- 2.43.4 From 816c83bb7a4501e754d21d2716f0c37ec06aa881 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 11:58:44 +0200 Subject: [PATCH 02/10] Update repository.json --- repository.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository.json b/repository.json index e1367ac..c054fa0 100644 --- a/repository.json +++ b/repository.json @@ -1,5 +1,5 @@ { - "name": "TheThomaas' Home Assistant Apps", + "name": "TheThomaas' Home Assistant Apps DEV", "url": "https://git.thethomaas.net/TheThomaas/home-assistant-apps", "maintainer": "TheThomaas " } \ No newline at end of file -- 2.43.4 From 9efba0ae477b36ef0c4adf3dbca8b91d993b132b Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 11:58:47 +0200 Subject: [PATCH 03/10] Update config.yaml --- cookcli/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index e547659..a2c0816 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -1,7 +1,7 @@ --- name: CookCLI Server slug: cookcli -version: 0.11.4 +version: 0.11.5 description: "Serveur CookCLI avec synchronisation Git" url: "https://git.thethomaas.net/TheThomaas/home-assistant-apps/src/branch/main/cookcli" arch: -- 2.43.4 From 4f4143232ab967eafdc04afaf4a253312ed462ba Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 12:02:27 +0200 Subject: [PATCH 04/10] Update Dockerfile --- cookcli/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/cookcli/Dockerfile b/cookcli/Dockerfile index bd7f4c2..edaad3e 100644 --- a/cookcli/Dockerfile +++ b/cookcli/Dockerfile @@ -18,6 +18,7 @@ RUN apk add --no-cache \ openssh-client \ nginx \ nginx-mod-stream \ + socat \ file # Détection de l'architecture et téléchargement de la bonne version -- 2.43.4 From 11c4ac0b8b583fc7248d88bf70632888a3d98be5 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 12:02:29 +0200 Subject: [PATCH 05/10] Update config.yaml --- cookcli/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index a2c0816..6a9c10b 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -1,7 +1,7 @@ --- -name: CookCLI Server +name: CookCLI Server DEV slug: cookcli -version: 0.11.5 +version: 0.11.6 description: "Serveur CookCLI avec synchronisation Git" url: "https://git.thethomaas.net/TheThomaas/home-assistant-apps/src/branch/main/cookcli" arch: -- 2.43.4 From 82907c6fcf81285be2dfe7591c96e7950c322a1d Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 12:17:17 +0200 Subject: [PATCH 06/10] Update service --- cookcli/config.yaml | 2 +- cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh | 6 ------ cookcli/rootfs/etc/services.d/reload-listener/run | 2 +- cookcli/rootfs/usr/local/bin/reload-http.sh | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index 6a9c10b..a067391 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -1,7 +1,7 @@ --- name: CookCLI Server DEV slug: cookcli -version: 0.11.6 +version: 0.11.7 description: "Serveur CookCLI avec synchronisation Git" url: "https://git.thethomaas.net/TheThomaas/home-assistant-apps/src/branch/main/cookcli" arch: diff --git a/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh index 6bce255..baf940a 100644 --- a/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh +++ b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh @@ -55,12 +55,6 @@ http { proxy_redirect http://127.0.0.1:9081/ \$scheme://\$host${INGRESS_PATH}/; proxy_redirect http://127.0.0.1:9081 \$scheme://\$host${INGRESS_PATH}; } - - location = /api/reload { - limit_except POST { deny all; } - proxy_pass http://127.0.0.1:8098; - proxy_read_timeout 120s; - } } } diff --git a/cookcli/rootfs/etc/services.d/reload-listener/run b/cookcli/rootfs/etc/services.d/reload-listener/run index c3dfa39..1f6454c 100644 --- a/cookcli/rootfs/etc/services.d/reload-listener/run +++ b/cookcli/rootfs/etc/services.d/reload-listener/run @@ -1,2 +1,2 @@ #!/usr/bin/with-contenv bashio -exec socat TCP-LISTEN:8098,bind=127.0.0.1,fork,reuseaddr EXEC:/usr/local/bin/reload-http.sh \ No newline at end of file +exec socat TCP-LISTEN:8098,fork,reuseaddr EXEC:/usr/local/bin/reload-http.sh \ No newline at end of file diff --git a/cookcli/rootfs/usr/local/bin/reload-http.sh b/cookcli/rootfs/usr/local/bin/reload-http.sh index 9d6fe98..06f2b5c 100644 --- a/cookcli/rootfs/usr/local/bin/reload-http.sh +++ b/cookcli/rootfs/usr/local/bin/reload-http.sh @@ -2,7 +2,7 @@ # Consomme la requête jusqu'à la ligne vide while IFS= read -r line; do line="${line%$'\r'}"; [ -z "$line" ] && break; done -if /usr/local/bin/git-sync-now.sh >/dev/null 2>&1; then +if /usr/local/bin/git-sync-now.sh >> /proc/1/fd/1 2>&1; then status="200 OK"; body='{"status":"ok"}' else status="500 Internal Server Error"; body='{"status":"error"}' -- 2.43.4 From f81952a94abb883ac1e48c206bc552df757f5725 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 12:29:05 +0200 Subject: [PATCH 07/10] Update config.yaml --- cookcli/config.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index a067391..36819f1 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -39,9 +39,3 @@ schema: git_sync_interval: int(60,86400)? git_username: str? git_password: password? - -#--- Permissions Ingress --- -ingress: - - port: 9080 - protocol: http - path: / \ No newline at end of file -- 2.43.4 From 18e2e7faede3a2dd5408fa9b97600db098f9de71 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 14:55:40 +0200 Subject: [PATCH 08/10] Update run --- cookcli/rootfs/etc/services.d/reload-listener/run | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cookcli/rootfs/etc/services.d/reload-listener/run b/cookcli/rootfs/etc/services.d/reload-listener/run index 1f6454c..c548dfc 100644 --- a/cookcli/rootfs/etc/services.d/reload-listener/run +++ b/cookcli/rootfs/etc/services.d/reload-listener/run @@ -1,2 +1,4 @@ #!/usr/bin/with-contenv bashio + +bashio::log.info "Démarrage du listener de reload sur le port 8098" exec socat TCP-LISTEN:8098,fork,reuseaddr EXEC:/usr/local/bin/reload-http.sh \ No newline at end of file -- 2.43.4 From c00b342066d04dd4da5cb471f4cfdabc6c7f049c Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 14:58:33 +0200 Subject: [PATCH 09/10] Update config.yaml --- cookcli/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index 36819f1..bd549f8 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -1,7 +1,7 @@ --- name: CookCLI Server DEV slug: cookcli -version: 0.11.7 +version: 0.11.8 description: "Serveur CookCLI avec synchronisation Git" url: "https://git.thethomaas.net/TheThomaas/home-assistant-apps/src/branch/main/cookcli" arch: -- 2.43.4 From 812747bfaa4f07b988e3e5a261b39befb021547e Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 20 Sep 2026 18:52:27 +0200 Subject: [PATCH 10/10] Remove DEV mentions --- cookcli/config.yaml | 6 +++--- repository.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookcli/config.yaml b/cookcli/config.yaml index bd549f8..cb03671 100644 --- a/cookcli/config.yaml +++ b/cookcli/config.yaml @@ -1,7 +1,7 @@ --- -name: CookCLI Server DEV +name: CookCLI Server slug: cookcli -version: 0.11.8 +version: 0.11.5 description: "Serveur CookCLI avec synchronisation Git" url: "https://git.thethomaas.net/TheThomaas/home-assistant-apps/src/branch/main/cookcli" arch: @@ -15,10 +15,10 @@ host_network: false discovery: - cookcli -#--- Configuration Ingress --- ingress: true ingress_port: 9080 ingress_entry: / + panel_icon: mdi:chef-hat panel_title: "CookCLI" diff --git a/repository.json b/repository.json index c054fa0..e1367ac 100644 --- a/repository.json +++ b/repository.json @@ -1,5 +1,5 @@ { - "name": "TheThomaas' Home Assistant Apps DEV", + "name": "TheThomaas' Home Assistant Apps", "url": "https://git.thethomaas.net/TheThomaas/home-assistant-apps", "maintainer": "TheThomaas " } \ No newline at end of file -- 2.43.4