From 7789a9a57709cabef455513d1e34524dc75c51df Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:57:25 +0000 Subject: [PATCH 01/80] Github bot : issues linked to readme --- postgres/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/postgres/README.md b/postgres/README.md index b78da03eb..489d36db5 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -1,4 +1,3 @@ -## ⚠ Open Issue : [🐛 [PostgresSQL] does not get shutdown properly when stopping the addon (opened 2024-12-01)](https://github.com/alexbelgium/hassio-addons/issues/1652) by [@paviro](https://github.com/paviro) # Home assistant add-on: Postgres [![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) From ba77c0c9bd6b20a850f693aac181718d4144cc86 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:37:09 +0100 Subject: [PATCH 02/80] Update Dockerfile --- postgres/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 45f7030aa..5f5057cf7 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,10 +72,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - # Close gracefully - cat /etc/cont-init.d/99-run.sh >> /ha_entrypoint.sh && \ - rm /etc/cont-init.d/99-run.sh +RUN chmod 777 /docker-entrypoint-initdb.d/* WORKDIR /config ENTRYPOINT [ "/ha_entrypoint.sh" ] From 7c40a68acb9d0e67dcab010cc13305612c27eff0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:37:30 +0100 Subject: [PATCH 03/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 1cb04be6e..549c95536 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -37,5 +37,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3" + "version": "15.7-3_test" } From 5215b5ed8aff298d41e181f4b023f4200033e532 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:48:36 +0100 Subject: [PATCH 04/80] Update Dockerfile --- postgres/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 5f5057cf7..4c3e9ef2a 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -74,6 +74,8 @@ RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif. RUN chmod 777 /docker-entrypoint-initdb.d/* +RUN echo -e "\n# Simulate long-running process to allow signal handling\nwhile true; do\n sleep 1\ndone" >> /ha_entrypoint.sh + WORKDIR /config ENTRYPOINT [ "/ha_entrypoint.sh" ] From 6f29a049cc00fa43537d8b6c819a64154e2a10c3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:50:20 +0100 Subject: [PATCH 05/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 0e79069ba..853d7847e 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -56,4 +56,4 @@ else fi # Wait for processes to finish -wait "$VECTOR_PID" "$POSTGRES_PID" +# wait "$VECTOR_PID" "$POSTGRES_PID" From b4c78c518321c9da1786126c052e4cf340908aca Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:51:28 +0100 Subject: [PATCH 06/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 549c95536..6db85821c 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -37,5 +37,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test" + "version": "15.7-3_test2" } From 5e525d64ae2b794b98e1ddb494582e3586661f5b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:56:08 +0100 Subject: [PATCH 07/80] Update Dockerfile --- postgres/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 4c3e9ef2a..1801abbc8 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -74,7 +74,7 @@ RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif. RUN chmod 777 /docker-entrypoint-initdb.d/* -RUN echo -e "\n# Simulate long-running process to allow signal handling\nwhile true; do\n sleep 1\ndone" >> /ha_entrypoint.sh +RUN echo "\nsleep infinity" >> /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/ha_entrypoint.sh" ] From 0d90e92cbc7486b2ea81b0fc849e9ab6557cb86c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:56:28 +0100 Subject: [PATCH 08/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 6db85821c..260121b12 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -37,5 +37,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test2" + "version": "15.7-3_test3" } From 43b6dc0ba343e23ccee296f5f3802d3f53e28127 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:08:07 +0100 Subject: [PATCH 09/80] Update Dockerfile --- postgres/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 1801abbc8..1b071002c 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -74,10 +74,10 @@ RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif. RUN chmod 777 /docker-entrypoint-initdb.d/* -RUN echo "\nsleep infinity" >> /ha_entrypoint.sh - WORKDIR /config -ENTRYPOINT [ "/ha_entrypoint.sh" ] +ENTRYPOINT [ "/usr/bin/env" ] +CMD [ "/ha_entrypoint.sh" ] +SHELL ["/bin/bash", "-o", "pipefail", "-c"] ############ # 5 Labels # From 0593ae0dc74fe7b7dc72caa336aff9390ba9cf21 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:08:30 +0100 Subject: [PATCH 10/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 853d7847e..0e79069ba 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -56,4 +56,4 @@ else fi # Wait for processes to finish -# wait "$VECTOR_PID" "$POSTGRES_PID" +wait "$VECTOR_PID" "$POSTGRES_PID" From 7f2b02719a3b4c29928b4024f6e05fdd27424bdf Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:09:18 +0100 Subject: [PATCH 11/80] Update config.json --- postgres/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 260121b12..c8b8849cf 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -12,6 +12,7 @@ "PGDATA": "/config/database" }, "image": "ghcr.io/alexbelgium/postgres-{arch}", + "init": false, "map": [ "addon_config:rw", "homeassistant_config:rw", @@ -37,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test3" + "version": "15.7-3_test4" } From a9fa6ce6983314308bd8fe8abeb43ec684e52945 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:57:31 +0100 Subject: [PATCH 12/80] Update Dockerfile --- postgres/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 1b071002c..a0281bc61 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,7 +72,9 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* +RUN chmod 777 /docker-entrypoint-initdb.d/* && \ + # Close gracefully + sed -i "s|trap terminate|trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop; exit 0'|g" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From 5b556e17c0ea4827183c14714c575d4b1f827f52 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:57:57 +0100 Subject: [PATCH 13/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index c8b8849cf..e1943e946 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test4" + "version": "15.7-3_test5" } From 0d0168cdd0269e504ba88af591bee74fe85658df Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:18:33 +0100 Subject: [PATCH 14/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index c062fda6c..e7bea1235 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -74,9 +74,12 @@ done # Starting container # ###################### -echo " " -echo -e "\033[0;32mStarting the upstream container\033[0m" -echo " " - -# Launch lsio mods -if [ -f /docker-mods ]; then exec /docker-mods; fi +if [ "$$" -eq 1 ]; then + sleep infinity +else + echo " " + echo -e "\033[0;32mStarting the upstream container\033[0m" + echo " " + # Launch lsio mods + if [ -f /docker-mods ]; then exec /docker-mods; fi +fi From c18b0b350fff04f8dece192abd72daa2b9049c57 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:21:26 +0100 Subject: [PATCH 15/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 0e79069ba..853d7847e 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -56,4 +56,4 @@ else fi # Wait for processes to finish -wait "$VECTOR_PID" "$POSTGRES_PID" +# wait "$VECTOR_PID" "$POSTGRES_PID" From 500a70be73b7fd0634f9831ee7d32277638cc6f9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:22:20 +0100 Subject: [PATCH 16/80] Update Dockerfile --- postgres/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index a0281bc61..24ef7092c 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -74,7 +74,7 @@ RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif. RUN chmod 777 /docker-entrypoint-initdb.d/* && \ # Close gracefully - sed -i "s|trap terminate|trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop; exit 0'|g" /ha_entrypoint.sh + sed -i "s|trap terminate|trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop'|g" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From d80c9c7d8e6ea01321b14abb7184fbf5d538cccd Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:22:36 +0100 Subject: [PATCH 17/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index e1943e946..c7ab64931 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test5" + "version": "15.7-3_test6" } From 38feafc2db788e93d4c91bb08cb9437308bd5e33 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:29:36 +0100 Subject: [PATCH 18/80] Update Dockerfile --- postgres/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 24ef7092c..1b071002c 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,9 +72,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - # Close gracefully - sed -i "s|trap terminate|trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop'|g" /ha_entrypoint.sh +RUN chmod 777 /docker-entrypoint-initdb.d/* WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From e1d84b557c3a5f08222eabaf192019ea61baae41 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:31:12 +0100 Subject: [PATCH 19/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 853d7847e..e9a9267e6 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -40,7 +40,7 @@ function shutdown_postgres { exit 0 } -trap 'shutdown_postgres' SIGTERM SIGINT +#trap 'shutdown_postgres' SIGTERM SIGINT # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then @@ -55,5 +55,7 @@ else POSTGRES_PID=$! fi +bashio::log.info "Started!" + # Wait for processes to finish # wait "$VECTOR_PID" "$POSTGRES_PID" From 3f3770d35d0d6ad238fb294dffa2a64a60f46e21 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:31:29 +0100 Subject: [PATCH 20/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index c7ab64931..e1943e946 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test6" + "version": "15.7-3_test5" } From 555685e93195620ae04cacd83d41c5809710fd53 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:39:22 +0100 Subject: [PATCH 21/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index e9a9267e6..8a5f48920 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -44,15 +44,12 @@ function shutdown_postgres { # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then - /./docker-entrypoint-initdb.d/10-vector.sh & - VECTOR_PID=$! + /./docker-entrypoint-initdb.d/10-vector.sh & VECTOR_PID=$! - docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & - POSTGRES_PID=$! + docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & POSTGRES_PID=$! else bashio::log.warning "ARMv7 detected: Starting without vectors.so" - docker-entrypoint.sh postgres & - POSTGRES_PID=$! + docker-entrypoint.sh postgres & POSTGRES_PID=$! fi bashio::log.info "Started!" From c06ca33e23d52679a0d7c7f92dc0b65f3b89d5be Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:41:11 +0100 Subject: [PATCH 22/80] Update 10-vector.sh --- postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh index c97f4fe61..fe9fd1fa6 100755 --- a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh +++ b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh @@ -24,4 +24,4 @@ echo "DROP EXTENSION IF EXISTS vectors; \q"> setup_postgres.sql # Enable vectors -psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < setup_postgres.sql || true +psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < setup_postgres.sql & true From cb9628dd6731c5668493dc93cf5a4df1560be19e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:41:33 +0100 Subject: [PATCH 23/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index e1943e946..73535c9f8 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test5" + "version": "15.7-3_test7" } From e6abaafab7c06665d9ebd2df0ba0ce2b8ec5c3b0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:48:38 +0100 Subject: [PATCH 24/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 8a5f48920..c2d193f36 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -52,7 +52,5 @@ else docker-entrypoint.sh postgres & POSTGRES_PID=$! fi -bashio::log.info "Started!" - # Wait for processes to finish # wait "$VECTOR_PID" "$POSTGRES_PID" From dc69fa24eb55c243ce348fac35236c2b4a2d8866 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:51:56 +0100 Subject: [PATCH 25/80] Update Dockerfile --- postgres/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 1b071002c..31d4319f8 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,7 +72,8 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* +RUN chmod 777 /docker-entrypoint-initdb.d/* && \ + echo "bashio::log.info \"Postgres ready to connect\" && sleep infinity" >> /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From ff9cb8096f9a1058a9e01dd0399d9b00372cd358 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:52:15 +0100 Subject: [PATCH 26/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 73535c9f8..a4ac7923f 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test7" + "version": "15.7-3_test8" } From bc3f35f83240c472d0c493b15dbb6e8e3064c1e2 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:59:49 +0100 Subject: [PATCH 27/80] Update Dockerfile --- postgres/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 31d4319f8..612ef6294 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -73,7 +73,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - echo "bashio::log.info \"Postgres ready to connect\" && sleep infinity" >> /ha_entrypoint.sh + sed -i "s|sleep infinity|bashio::log.info \"Postgres ready to connect\" && sleep infinity|g" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From bc22a5c50525795f19d38d44a53c8921d2f178bf Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:00:09 +0100 Subject: [PATCH 28/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index a4ac7923f..73535c9f8 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test8" + "version": "15.7-3_test7" } From fe5e1427645857c5d41a253ee8922f075e85d9f7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:05:43 +0100 Subject: [PATCH 29/80] Update Dockerfile --- postgres/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 612ef6294..42f7fae87 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -73,7 +73,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - sed -i "s|sleep infinity|bashio::log.info \"Postgres ready to connect\" && sleep infinity|g" /ha_entrypoint.sh + sed -i "s|sleep infinity|bashio::log.info \"Postgres ready to connect\" \& sleep infinity|g" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From 7f08556748c552c1792b88d5708f292e83d0b01d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:07:51 +0100 Subject: [PATCH 30/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index e7bea1235..2c9644a5d 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -75,6 +75,8 @@ done ###################### if [ "$$" -eq 1 ]; then + echo " " + echo -e "\033[0;32mEverything started!\033[0m" sleep infinity else echo " " From aa643ae74e56405badf8f378ca9b69cca7d8a78a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:08:41 +0100 Subject: [PATCH 31/80] Update Dockerfile --- postgres/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 42f7fae87..1b071002c 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,8 +72,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - sed -i "s|sleep infinity|bashio::log.info \"Postgres ready to connect\" \& sleep infinity|g" /ha_entrypoint.sh +RUN chmod 777 /docker-entrypoint-initdb.d/* WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From c603c6c5a7ce49f04cea30a0ad09b9a7252136ec Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:09:00 +0100 Subject: [PATCH 32/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 73535c9f8..a4ac7923f 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test7" + "version": "15.7-3_test8" } From bb3d724ae7a2a9aa651eb35c76b379eaf5d5e4f7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:25:41 +0100 Subject: [PATCH 33/80] Change order of trap --- .templates/ha_entrypoint.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 2c9644a5d..54cf25115 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -3,12 +3,11 @@ # Only trap SIGTERM if the script's PID is 1 if [ "$$" -eq 1 ]; then - echo "PID is 1, trapping SIGTERM..." set -m terminate() { echo "Termination signal received, forwarding to subprocesses..." - # Check for available commands to terminate subprocesses + # Gracefully terminate subprocesses if command -v pkill &>/dev/null; then pkill -P $$ elif command -v kill &>/dev/null; then @@ -20,7 +19,6 @@ if [ "$$" -eq 1 ]; then echo "All subprocesses terminated. Exiting." exit 0 } - trap terminate SIGTERM SIGINT fi echo "Starting..." @@ -77,7 +75,8 @@ done if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" - sleep infinity + trap terminate SIGTERM SIGINT + exec sleep infinity else echo " " echo -e "\033[0;32mStarting the upstream container\033[0m" From bc4cdb9ec22997ab78e855f106c9dfb5491f446d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:26:13 +0100 Subject: [PATCH 34/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index a4ac7923f..7e1257f49 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test8" + "version": "15.7-3_test9" } From f9662240923853415db3ded50a74b582b6a0c5dd Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:33:56 +0100 Subject: [PATCH 35/80] Adapt trap --- .templates/ha_entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 54cf25115..0f9a1c5a2 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -76,7 +76,7 @@ if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" trap terminate SIGTERM SIGINT - exec sleep infinity + while true; do sleep 86400 & wait $!; done else echo " " echo -e "\033[0;32mStarting the upstream container\033[0m" From fc4b0b1b6c303596567ef89cac10b2566e0cb8cd Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:34:07 +0100 Subject: [PATCH 36/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 7e1257f49..1c2a18dde 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test9" + "version": "15.7-3_test10" } From 96ae16687ce562540237a7b9b374465799d64a70 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:36:20 +0100 Subject: [PATCH 37/80] Update config.json --- postgres/config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 1c2a18dde..d1cf0a8ca 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -12,7 +12,6 @@ "PGDATA": "/config/database" }, "image": "ghcr.io/alexbelgium/postgres-{arch}", - "init": false, "map": [ "addon_config:rw", "homeassistant_config:rw", From d239b008edec52795df20d9a0d424ef7436b7356 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:40:01 +0100 Subject: [PATCH 38/80] Update config.json --- postgres/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/postgres/config.json b/postgres/config.json index d1cf0a8ca..1c2a18dde 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -12,6 +12,7 @@ "PGDATA": "/config/database" }, "image": "ghcr.io/alexbelgium/postgres-{arch}", + "init": false, "map": [ "addon_config:rw", "homeassistant_config:rw", From 0086fed1584e68f8cf8537253a6c2a397abede21 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:42:23 +0100 Subject: [PATCH 39/80] Hide output --- postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh index fe9fd1fa6..d5d05dbe4 100755 --- a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh +++ b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh @@ -24,4 +24,4 @@ echo "DROP EXTENSION IF EXISTS vectors; \q"> setup_postgres.sql # Enable vectors -psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < setup_postgres.sql & true +psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < setup_postgres.sql >/dev/null || true From eecf773ceee123c30967057030466609c87647a2 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:42:56 +0100 Subject: [PATCH 40/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index c2d193f36..cc8d8b691 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -40,7 +40,7 @@ function shutdown_postgres { exit 0 } -#trap 'shutdown_postgres' SIGTERM SIGINT +trap 'shutdown_postgres' SIGTERM SIGINT # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then From a0c7bd046ec6026645d2a7d333fa089408dbab79 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:43:45 +0100 Subject: [PATCH 41/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 1c2a18dde..cba3e3236 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test10" + "version": "15.7-3_test11" } From c2c0ea93617a9ddcdd534c3c97aed3550a8b79f3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:34:10 +0100 Subject: [PATCH 42/80] Use subshells --- .templates/ha_entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 0f9a1c5a2..62c8def13 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -58,10 +58,10 @@ for SCRIPTS in /etc/cont-init.d/*; do sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" # shellcheck source=/dev/null - source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" + (source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? &) else # Support for posix only shell - "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" + ("$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? &) fi # Cleanup From 2150da479b233ccb1f9244313021888b008f14a1 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:34:28 +0100 Subject: [PATCH 43/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index cba3e3236..006562d36 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test11" + "version": "15.7-3_test12" } From c230d52bec12b74f559129963de40c33a527129d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:03:33 +0100 Subject: [PATCH 44/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 62c8def13..c7d0a84ef 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -8,11 +8,10 @@ if [ "$$" -eq 1 ]; then echo "Termination signal received, forwarding to subprocesses..." # Gracefully terminate subprocesses - if command -v pkill &>/dev/null; then - pkill -P $$ - elif command -v kill &>/dev/null; then - kill -TERM -- -$$ - fi + for pid in "${pids[@]}"; do + echo "Terminating PID $pid" + kill -TERM "$pid" 2>/dev/null + done # Wait for all child processes to terminate wait @@ -23,6 +22,9 @@ fi echo "Starting..." +# Array to hold the PIDs of the subprocesses +pids=() + #################### # Starting scripts # #################### @@ -58,12 +60,15 @@ for SCRIPTS in /etc/cont-init.d/*; do sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" # shellcheck source=/dev/null - (source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? &) + source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? & else # Support for posix only shell - ("$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? &) + "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? & fi + # Track the PID of the background process + pids+=($!) + # Cleanup rm "$SCRIPTS" done From c68d61e524facf31ea40cfe758ee912c288687bd Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:03:54 +0100 Subject: [PATCH 45/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 006562d36..f34d504bc 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test12" + "version": "15.7-3_test13" } From 5fb684f8f256a20a089cd027e422999dc5a6c68e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:18:25 +0100 Subject: [PATCH 46/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index c7d0a84ef..27d74254c 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -34,7 +34,7 @@ for SCRIPTS in /etc/cont-init.d/*; do echo "$SCRIPTS: executing" # Check if run as root - if test "$(id -u)" == 0 && test "$(id -u)" == 0; then + if [ "$(id -u)" == 0 ]; then chown "$(id -u)":"$(id -g)" "$SCRIPTS" chmod a+x "$SCRIPTS" else @@ -60,10 +60,10 @@ for SCRIPTS in /etc/cont-init.d/*; do sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" # shellcheck source=/dev/null - source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? & + source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" & else # Support for posix only shell - "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $? & + "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" & fi # Track the PID of the background process From c76aa57bd94a89203917e6689499c2182346143a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:18:49 +0100 Subject: [PATCH 47/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index f34d504bc..1e2d0a92a 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test13" + "version": "15.7-3_test14" } From 99adad577145497cf343b65647fe4f470d01ec0a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:34:40 +0100 Subject: [PATCH 48/80] Improve PID catching --- .templates/ha_entrypoint.sh | 47 +++++++++++++++---------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 27d74254c..e4195c1f2 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -1,40 +1,20 @@ #!/command/with-contenv bashio # shellcheck shell=bash -# Only trap SIGTERM if the script's PID is 1 -if [ "$$" -eq 1 ]; then - set -m - terminate() { - echo "Termination signal received, forwarding to subprocesses..." - - # Gracefully terminate subprocesses - for pid in "${pids[@]}"; do - echo "Terminating PID $pid" - kill -TERM "$pid" 2>/dev/null - done - - # Wait for all child processes to terminate - wait - echo "All subprocesses terminated. Exiting." - exit 0 - } -fi - echo "Starting..." -# Array to hold the PIDs of the subprocesses -pids=() - #################### # Starting scripts # #################### +pids=() +pids+=(1) for SCRIPTS in /etc/cont-init.d/*; do [ -e "$SCRIPTS" ] || continue echo "$SCRIPTS: executing" # Check if run as root - if [ "$(id -u)" == 0 ]; then + if test "$(id -u)" == 0 && test "$(id -u)" == 0; then chown "$(id -u)":"$(id -g)" "$SCRIPTS" chmod a+x "$SCRIPTS" else @@ -60,15 +40,12 @@ for SCRIPTS in /etc/cont-init.d/*; do sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" # shellcheck source=/dev/null - source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" & + source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" && pids+=($!) else # Support for posix only shell - "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" & + "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" && pids+=($!) fi - # Track the PID of the background process - pids+=($!) - # Cleanup rm "$SCRIPTS" done @@ -80,6 +57,20 @@ done if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" + terminate() { + echo "Termination signal received, forwarding to subprocesses..." + + # Gracefully terminate subprocesses + for pid in "${pids[@]}"; do + echo "Terminating PID $pid" + kill -TERM "$pid" 2>/dev/null + done + + # Wait for all child processes to terminate + wait + echo "All subprocesses terminated. Exiting." + exit 0 + } trap terminate SIGTERM SIGINT while true; do sleep 86400 & wait $!; done else From 0d0c2d604675fe7f8bfc41d34213ed14f48a517c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:34:59 +0100 Subject: [PATCH 49/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 1e2d0a92a..0b5b62e09 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test14" + "version": "15.7-3_test15" } From 51857521cac590795703bcefff1ec97e8657f345 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:44:41 +0100 Subject: [PATCH 50/80] Try another solution --- .templates/ha_entrypoint.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index e4195c1f2..9f91ea2a8 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -7,8 +7,6 @@ echo "Starting..." # Starting scripts # #################### -pids=() -pids+=(1) for SCRIPTS in /etc/cont-init.d/*; do [ -e "$SCRIPTS" ] || continue echo "$SCRIPTS: executing" @@ -40,10 +38,10 @@ for SCRIPTS in /etc/cont-init.d/*; do sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" # shellcheck source=/dev/null - source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" && pids+=($!) + source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" else # Support for posix only shell - "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" && pids+=($!) + "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" fi # Cleanup @@ -60,10 +58,10 @@ if [ "$$" -eq 1 ]; then terminate() { echo "Termination signal received, forwarding to subprocesses..." - # Gracefully terminate subprocesses - for pid in "${pids[@]}"; do + # Gracefully terminate open subprocesses + for pid in $(ls /proc/*/cmdline 2>/dev/null | grep -oP '/proc/\K[0-9]+'); do echo "Terminating PID $pid" - kill -TERM "$pid" 2>/dev/null + kill -TERM "$pid" 2>/dev/null || true done # Wait for all child processes to terminate From 563af10ae5ca88ffa3f6a41d1a8505e19197ac75 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:48:49 +0100 Subject: [PATCH 51/80] Improve PID --- .templates/ha_entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 9f91ea2a8..18f47c928 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -59,7 +59,7 @@ if [ "$$" -eq 1 ]; then echo "Termination signal received, forwarding to subprocesses..." # Gracefully terminate open subprocesses - for pid in $(ls /proc/*/cmdline 2>/dev/null | grep -oP '/proc/\K[0-9]+'); do + for pid in $(grep -l "/etc/cont-init.d" /proc/*/cmdline 2>/dev/null | grep -oP '/proc/\K[0-9]+'); do echo "Terminating PID $pid" kill -TERM "$pid" 2>/dev/null || true done From d06a9051c5e5747a153052ea9e09f282a4976b5c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:49:07 +0100 Subject: [PATCH 52/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 0b5b62e09..321f36b50 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test15" + "version": "15.7-3_test16" } From 3f893bace14c3a8426cd80e3a772e1a31979c7b1 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:00:15 +0100 Subject: [PATCH 53/80] Remove trap --- postgres/rootfs/etc/cont-init.d/99-run.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index cc8d8b691..80d923980 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -34,14 +34,6 @@ cd /config || true bashio::log.info "Starting the app" -function shutdown_postgres { - echo "Received SIGTERM/SIGINT, shutting down PostgreSQL..." - gosu postgres pg_ctl -D "$PGDATA" -m fast stop - exit 0 -} - -trap 'shutdown_postgres' SIGTERM SIGINT - # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then /./docker-entrypoint-initdb.d/10-vector.sh & VECTOR_PID=$! From 5d0dfad522a767a1e02cdde117c2301585b3093b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:01:48 +0100 Subject: [PATCH 54/80] Update Dockerfile --- postgres/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 1b071002c..053600694 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -72,7 +72,8 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -RUN chmod 777 /docker-entrypoint-initdb.d/* +RUN chmod 777 /docker-entrypoint-initdb.d/* && \ + sed -i "/Termination signal received/a trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop' SIGTERM SIGINT" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From 0a1c71e8fe8715f8634c187871092892820903ed Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:01:59 +0100 Subject: [PATCH 55/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 321f36b50..318c8e9e9 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test16" + "version": "15.7-3_test17" } From 083fa8e08d8fb8e44382204fe9126350081c4214 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:11:36 +0100 Subject: [PATCH 56/80] Improved pid detection --- .templates/ha_entrypoint.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 18f47c928..eb174549c 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -59,9 +59,13 @@ if [ "$$" -eq 1 ]; then echo "Termination signal received, forwarding to subprocesses..." # Gracefully terminate open subprocesses - for pid in $(grep -l "/etc/cont-init.d" /proc/*/cmdline 2>/dev/null | grep -oP '/proc/\K[0-9]+'); do - echo "Terminating PID $pid" - kill -TERM "$pid" 2>/dev/null || true + for pid in /proc/[0-9]*/; do + pid=${pid#/proc/} + pid=${pid%/} + if [[ "$pid" -ne 1 ]]; then + echo "Terminating PID $pid" + kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" + fi done # Wait for all child processes to terminate From 2159e34ebe1060431b8887349a1968883979c0a6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:24:26 +0100 Subject: [PATCH 57/80] Use pgrep if available --- .templates/ha_entrypoint.sh | 42 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index eb174549c..ae15d185e 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -12,7 +12,7 @@ for SCRIPTS in /etc/cont-init.d/*; do echo "$SCRIPTS: executing" # Check if run as root - if test "$(id -u)" == 0 && test "$(id -u)" == 0; then + if [ "$(id -u)" -eq 0 ]; then chown "$(id -u)":"$(id -g)" "$SCRIPTS" chmod a+x "$SCRIPTS" else @@ -27,20 +27,21 @@ for SCRIPTS in /etc/cont-init.d/*; do # Get current shebang, if not available use another currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")" if [ ! -f "${currentshebang%% *}" ]; then - for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done + for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do + if [ -f "${shebang%% *}" ]; then + break + fi + done sed -i "s|$currentshebang|$shebang|g" "$SCRIPTS" fi # Use source to share env variables when requested if [ "${ha_entry_source:-null}" = true ] && command -v "source" &>/dev/null; then - # Exit cannot be used with source sed -i "s/(.*\s|^)exit ([0-9]+)/\1 return \2 || exit \2/g" "$SCRIPTS" sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" - # shellcheck source=/dev/null source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" else - # Support for posix only shell "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?" fi @@ -57,24 +58,31 @@ if [ "$$" -eq 1 ]; then echo -e "\033[0;32mEverything started!\033[0m" terminate() { echo "Termination signal received, forwarding to subprocesses..." + + if command -v pgrep &>/dev/null; then + # Use pgrep if available to find child processes + for pid in $(pgrep -P $$); do + echo "Terminating child PID $pid" + kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" + done + else + # Fallback to iterating through /proc + for pid in /proc/[0-9]*/; do + pid=${pid#/proc/} + pid=${pid%/} + if [[ "$pid" -ne 1 ]] && grep -q "^PPid:\s*$$" "/proc/$pid/status" 2>/dev/null; then + echo "Terminating child PID $pid" + kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" + fi + done + fi - # Gracefully terminate open subprocesses - for pid in /proc/[0-9]*/; do - pid=${pid#/proc/} - pid=${pid%/} - if [[ "$pid" -ne 1 ]]; then - echo "Terminating PID $pid" - kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" - fi - done - - # Wait for all child processes to terminate wait echo "All subprocesses terminated. Exiting." exit 0 } trap terminate SIGTERM SIGINT - while true; do sleep 86400 & wait $!; done + while :; do sleep infinity & wait $!; done else echo " " echo -e "\033[0;32mStarting the upstream container\033[0m" From 911510d6a4035310e284c1faac9f7a0f01aa4038 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:25:28 +0100 Subject: [PATCH 58/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 318c8e9e9..e8c311a48 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test17" + "version": "15.7-3_test18" } From e5a4331233689a71384f1e9a09ae42007b9d8788 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:48:58 +0100 Subject: [PATCH 59/80] Re-add trap --- postgres/rootfs/etc/cont-init.d/99-run.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 80d923980..960eef070 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -34,6 +34,14 @@ cd /config || true bashio::log.info "Starting the app" +function shutdown_postgres { + echo "Received SIGTERM/SIGINT, shutting down PostgreSQL..." + gosu postgres pg_ctl -D "$PGDATA" -m fast stop + exit 0 +} + +trap 'shutdown_postgres' SIGTERM SIGINT + # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then /./docker-entrypoint-initdb.d/10-vector.sh & VECTOR_PID=$! @@ -43,6 +51,3 @@ else bashio::log.warning "ARMv7 detected: Starting without vectors.so" docker-entrypoint.sh postgres & POSTGRES_PID=$! fi - -# Wait for processes to finish -# wait "$VECTOR_PID" "$POSTGRES_PID" From ece12f4eff4b8e027abe17f16a4d6d7a12c5238e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:49:03 +0100 Subject: [PATCH 60/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index e8c311a48..fe0dc57fd 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test18" + "version": "15.7-3_test19" } From 994f49192389b1ad801568cc649e693b978afaa0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:16:56 +0100 Subject: [PATCH 61/80] Update 99-run.sh --- postgres/rootfs/etc/cont-init.d/99-run.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 960eef070..44ea2f150 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -44,10 +44,12 @@ trap 'shutdown_postgres' SIGTERM SIGINT # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then - /./docker-entrypoint-initdb.d/10-vector.sh & VECTOR_PID=$! + /./docker-entrypoint-initdb.d/10-vector.sh & true - docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & POSTGRES_PID=$! + docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & true else bashio::log.warning "ARMv7 detected: Starting without vectors.so" - docker-entrypoint.sh postgres & POSTGRES_PID=$! + docker-entrypoint.sh postgres & true fi + +while :; do sleep infinity & wait $!; done From 1febea55b0eb436c2de03fcfe161d238a4771e73 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:18:55 +0100 Subject: [PATCH 62/80] Clean close postgres --- postgres/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 053600694..881a11985 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -73,7 +73,7 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh RUN chmod 777 /docker-entrypoint-initdb.d/* && \ - sed -i "/Termination signal received/a trap 'gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop' SIGTERM SIGINT" /ha_entrypoint.sh + sed -i "/Termination signal received/a gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop" /ha_entrypoint.sh WORKDIR /config ENTRYPOINT [ "/usr/bin/env" ] From 02f157500c91f971a0fa346122837469b741db38 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:19:56 +0100 Subject: [PATCH 63/80] Remove trap --- postgres/rootfs/etc/cont-init.d/99-run.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 44ea2f150..bbe6bb4fc 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -34,22 +34,11 @@ cd /config || true bashio::log.info "Starting the app" -function shutdown_postgres { - echo "Received SIGTERM/SIGINT, shutting down PostgreSQL..." - gosu postgres pg_ctl -D "$PGDATA" -m fast stop - exit 0 -} - -trap 'shutdown_postgres' SIGTERM SIGINT - # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then /./docker-entrypoint-initdb.d/10-vector.sh & true - docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & true else bashio::log.warning "ARMv7 detected: Starting without vectors.so" docker-entrypoint.sh postgres & true fi - -while :; do sleep infinity & wait $!; done From 4e540222bd0f517f908157d60baa22ef97d79464 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:22:22 +0100 Subject: [PATCH 64/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index ae15d185e..8161968ee 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -53,6 +53,7 @@ done # Starting container # ###################### +# If PID 1, keep alive and manage sigterm if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" @@ -60,13 +61,12 @@ if [ "$$" -eq 1 ]; then echo "Termination signal received, forwarding to subprocesses..." if command -v pgrep &>/dev/null; then - # Use pgrep if available to find child processes for pid in $(pgrep -P $$); do echo "Terminating child PID $pid" kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" done else - # Fallback to iterating through /proc + # Fallback to iterating through /proc if pgrep is not available for pid in /proc/[0-9]*/; do pid=${pid#/proc/} pid=${pid%/} From dd0daa8c9258d8066b773c05e0433f95c016f078 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:22:40 +0100 Subject: [PATCH 65/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index fe0dc57fd..11abf8eb1 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test19" + "version": "15.7-3_test20" } From d08bca6b68af96749727cb5d873598ce1112b156 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:22:51 +0100 Subject: [PATCH 66/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index 11abf8eb1..e8c311a48 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test20" + "version": "15.7-3_test18" } From e6a23dbcfbdb7a4fe4969e081ecbfe1a52dbbb91 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:23:03 +0100 Subject: [PATCH 67/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index e8c311a48..e7bd4df84 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test18" + "version": "15.7-3_test21" } From a4ffbd785b683d042515ea40c2c7c22761b61e0f Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:30:43 +0100 Subject: [PATCH 68/80] Update config.json --- postgres/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/config.json b/postgres/config.json index e7bd4df84..45520388b 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -38,5 +38,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-3_test21" + "version": "15.7-4" } From f0a788054b7d2486aaed3e461ed79c3be162958e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:30:58 +0100 Subject: [PATCH 69/80] Update CHANGELOG.md --- postgres/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 55c3d50e2..1c6bf0d80 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -1,5 +1,5 @@ -## 15.7-3 (04-12-2024) -- Minor bugs fixed +- Fix env error + ## 15.7-2 (02-12-2024) - Fix database shutdown - Update pgvector to v0.3.0 From a74c1b343861c181af16ad6436e1e921c61f2539 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:39:13 +0000 Subject: [PATCH 70/80] GitHub bot : changelog --- postgres/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 1c6bf0d80..168033d86 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -1,3 +1,4 @@ +## 15.7-4 (05-12-2024) - Fix env error ## 15.7-2 (02-12-2024) From 3e274378aef2be45a56b911818a9e190e5856cd3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:45:19 +0100 Subject: [PATCH 71/80] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 8161968ee..40cc197c8 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -59,7 +59,7 @@ if [ "$$" -eq 1 ]; then echo -e "\033[0;32mEverything started!\033[0m" terminate() { echo "Termination signal received, forwarding to subprocesses..." - + # Terminate all subprocesses if command -v pgrep &>/dev/null; then for pid in $(pgrep -P $$); do echo "Terminating child PID $pid" From 890cc2f4773db063e30778fa34bde5123207f9b5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:18:57 +0000 Subject: [PATCH 72/80] Github bot : issues linked to readme --- postgres/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/postgres/README.md b/postgres/README.md index 489d36db5..66deffed9 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -1,3 +1,4 @@ +## ⚠ Open Issue : [🐛 [Postgres 15] Password is not specified (opened 2024-12-04)](https://github.com/alexbelgium/hassio-addons/issues/1654) by [@Foshkey](https://github.com/Foshkey) # Home assistant add-on: Postgres [![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) From 756347580c5a570a6173fe002a50ce396096341b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:58:22 +0100 Subject: [PATCH 73/80] Improve config.env handling, remove erroneous folder https://github.com/alexbelgium/hassio-addons/issues/1655 --- .../rootfs/etc/cont-init.d/99-run.sh | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/free_games_claimer/rootfs/etc/cont-init.d/99-run.sh b/free_games_claimer/rootfs/etc/cont-init.d/99-run.sh index c5d50c88c..a8d6d8e29 100755 --- a/free_games_claimer/rootfs/etc/cont-init.d/99-run.sh +++ b/free_games_claimer/rootfs/etc/cont-init.d/99-run.sh @@ -6,29 +6,35 @@ set -e # Initialize # ############## -# Use new config file CONFIG_HOME="$(bashio::config "CONFIG_LOCATION")" CONFIG_HOME="$(dirname "$CONFIG_HOME")" -if [ ! -f "$CONFIG_HOME"/config.env ]; then + +# Use new config file +if [ ! -f "$CONFIG_HOME/config.env" ]; then # Copy default config.env - cp /templates/config.env "$CONFIG_HOME"/config.env - chmod 777 "$CONFIG_HOME"/config.env - bashio::log.warning "A default config.env file was copied in $CONFIG_HOME. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on" + cp /templates/config.env "$CONFIG_HOME/" + chmod 755 "$CONFIG_HOME/config.env" + bashio::log.warning "A default config.env file was copied to $CONFIG_HOME. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on" else - bashio::log.warning "The config.env file found in $CONFIG_HOME will be used. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on" + bashio::log.info "Using existing config.env file in $CONFIG_HOME. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on" +fi + +# Remove erroneous folder named config.env +if [ -d "$CONFIG_HOME/config.env" ]; then + rm -r "$CONFIG_HOME/config.env" fi # Copy new file mkdir -p /data/data -\cp "$CONFIG_HOME"/config.env /data/data/ +cp "$CONFIG_HOME/config.env" /data/data/ # Permissions -chmod -R 777 "$CONFIG_HOME" +chmod -R 755 "$CONFIG_HOME" # Export variables set -a echo "" -bashio::log.info "Getting variables from $CONFIG_HOME/config.env" +bashio::log.info "Sourcing variables from $CONFIG_HOME/config.env" cp "$CONFIG_HOME"/config.env /config.env # Remove previous instance sed -i "s|export ||g" /config.env @@ -67,8 +73,7 @@ trim() { # Add docker-entrypoint command # Print each value of the array by using the loop -for val in "${strarr[@]}"; -do +for val in "${strarr[@]}"; do #Removes whitespaces val="$(trim "$val")" echo " " @@ -78,6 +83,6 @@ do echo "$val" | xargs docker-entrypoint.sh || true done -bashio::log.info "All actions concluded, addon will stop in 10 seconds" +bashio::log.info "All actions concluded. Stopping in 10 seconds." sleep 10 bashio::addon.stop From 6189f0bbac5b4bbaa1e2b60648cd0fbbd86155be Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:59:12 +0100 Subject: [PATCH 74/80] Try solve issue with config.env https://github.com/alexbelgium/hassio-addons/issues/1655 --- free_games_claimer/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/free_games_claimer/config.json b/free_games_claimer/config.json index c9109bbd0..2f9e6e785 100644 --- a/free_games_claimer/config.json +++ b/free_games_claimer/config.json @@ -92,6 +92,6 @@ "slug": "free_games_claimer", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons", - "version": "1.6", + "version": "1.6-2", "webui": "[PROTO:ssl]://[HOST]:[PORT:6080]" } From 809df7494611f0968ad8a5a0ab91089352c82bf3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:05:24 +0000 Subject: [PATCH 75/80] GitHub bot : changelog --- free_games_claimer/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/free_games_claimer/CHANGELOG.md b/free_games_claimer/CHANGELOG.md index 42bd0eac4..d7f009a3e 100644 --- a/free_games_claimer/CHANGELOG.md +++ b/free_games_claimer/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.6-2 (05-12-2024) +- Minor bugs fixed ## 1.6 (30-12-2023) From 8d5c4b1ceca4934e4b1073135c0f3515f22bfb19 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:18:19 +0100 Subject: [PATCH 76/80] Update CHANGELOG.md --- postgres/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 168033d86..053804ec9 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -1,8 +1,7 @@ ## 15.7-4 (05-12-2024) - Fix env error - -## 15.7-2 (02-12-2024) - Fix database shutdown +- Upgrade postgres to 15.7 - Update pgvector to v0.3.0 ## 15.5-7 (24-02-2024) From 64b6755ee76d1cff0e66ee1e756a742d21ad355c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:51:16 +0100 Subject: [PATCH 77/80] Update 01-config_yaml.sh --- .templates/01-config_yaml.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index a93600b66..43b7d50f8 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -35,6 +35,9 @@ CONFIGSOURCE="$CONFIGLOCATION"/config.yaml if bashio::config.has_value 'CONFIG_LOCATION'; then CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") + if [[ "$CONFIGSOURCE" == *.* ]]; then + CONFIGSOURCE=$(dirname "$CONFIGSOURCE") + fi # If does not end by config.yaml, remove trailing slash and add config.yaml if [[ "$CONFIGSOURCE" != *".yaml" ]]; then CONFIGSOURCE="${CONFIGSOURCE%/}"/config.yaml From c98916e12c40eeaadf12e2c5599e6569aeed15a6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:52:18 +0100 Subject: [PATCH 78/80] Update config.json --- free_games_claimer/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/free_games_claimer/config.json b/free_games_claimer/config.json index 2f9e6e785..a3097a278 100644 --- a/free_games_claimer/config.json +++ b/free_games_claimer/config.json @@ -92,6 +92,6 @@ "slug": "free_games_claimer", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons", - "version": "1.6-2", + "version": "1.6-3", "webui": "[PROTO:ssl]://[HOST]:[PORT:6080]" } From 289ef08d6aefae24e9d410fbff5a1cc785d4526a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:58:46 +0000 Subject: [PATCH 79/80] GitHub bot : changelog --- free_games_claimer/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/free_games_claimer/CHANGELOG.md b/free_games_claimer/CHANGELOG.md index d7f009a3e..c58356706 100644 --- a/free_games_claimer/CHANGELOG.md +++ b/free_games_claimer/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.6-3 (05-12-2024) +- Minor bugs fixed ## 1.6-2 (05-12-2024) - Minor bugs fixed From 1b26c7cd82f9e6364333fd80f7257a99340c3466 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:11:35 +0000 Subject: [PATCH 80/80] Github bot : issues linked to readme --- nextcloud/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/nextcloud/README.md b/nextcloud/README.md index 0f5f309a4..d36df8f4e 100644 --- a/nextcloud/README.md +++ b/nextcloud/README.md @@ -1,4 +1,3 @@ -## ⚠ Open Issue : [🐛 Nextcloud - upload big size files with desktop client - how to change/edit variables, ie: PHP.ini, www.conf, & nextcloud.conf variables - an avoid error 499 from desktop app (big size file) (opened 2024-11-27)](https://github.com/alexbelgium/hassio-addons/issues/1651) by [@aelg305](https://github.com/aelg305) # Home assistant add-on: Nextcloud [![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)