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 diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index c062fda6c..40cc197c8 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -1,28 +1,6 @@ #!/command/with-contenv bashio # shellcheck shell=bash -# 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 - if command -v pkill &>/dev/null; then - pkill -P $$ - elif command -v kill &>/dev/null; then - kill -TERM -- -$$ - fi - - # Wait for all child processes to terminate - wait - echo "All subprocesses terminated. Exiting." - exit 0 - } - trap terminate SIGTERM SIGINT -fi - echo "Starting..." #################### @@ -34,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 @@ -49,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 @@ -74,9 +53,40 @@ 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 PID 1, keep alive and manage sigterm +if [ "$$" -eq 1 ]; then + echo " " + 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" + kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" + done + else + # Fallback to iterating through /proc if pgrep is not available + 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 + + wait + echo "All subprocesses terminated. Exiting." + exit 0 + } + trap terminate SIGTERM SIGINT + while :; do sleep infinity & wait $!; done +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 diff --git a/free_games_claimer/CHANGELOG.md b/free_games_claimer/CHANGELOG.md index 42bd0eac4..c58356706 100644 --- a/free_games_claimer/CHANGELOG.md +++ b/free_games_claimer/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.6-3 (05-12-2024) +- Minor bugs fixed +## 1.6-2 (05-12-2024) +- Minor bugs fixed ## 1.6 (30-12-2023) diff --git a/free_games_claimer/config.json b/free_games_claimer/config.json index c9109bbd0..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", + "version": "1.6-3", "webui": "[PROTO:ssl]://[HOST]:[PORT:6080]" } 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 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) diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 55c3d50e2..053804ec9 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -1,7 +1,7 @@ -## 15.7-3 (04-12-2024) -- Minor bugs fixed -## 15.7-2 (02-12-2024) +## 15.7-4 (05-12-2024) +- Fix env error - Fix database shutdown +- Upgrade postgres to 15.7 - Update pgvector to v0.3.0 ## 15.5-7 (24-02-2024) diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 45f7030aa..881a11985 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -73,12 +73,12 @@ 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/* && \ - # Close gracefully - cat /etc/cont-init.d/99-run.sh >> /ha_entrypoint.sh && \ - rm /etc/cont-init.d/99-run.sh + sed -i "/Termination signal received/a gosu postgres pg_ctl -D \"\$PGDATA\" -m fast stop" /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 # diff --git a/postgres/README.md b/postgres/README.md index b78da03eb..66deffed9 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -1,4 +1,4 @@ -## ⚠ 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) +## ⚠ 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) diff --git a/postgres/config.json b/postgres/config.json index 1cb04be6e..45520388b 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" + "version": "15.7-4" } diff --git a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh index c97f4fe61..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 diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 0e79069ba..bbe6bb4fc 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -34,26 +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 & - VECTOR_PID=$! - - docker-entrypoint.sh postgres -c shared_preload_libraries=vectors.so & - POSTGRES_PID=$! + /./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 & - POSTGRES_PID=$! + docker-entrypoint.sh postgres & true fi - -# Wait for processes to finish -wait "$VECTOR_PID" "$POSTGRES_PID"