Update ha_entrypoint.sh

This commit is contained in:
Alexandre
2024-12-05 11:03:33 +01:00
committed by GitHub
parent 2150da479b
commit c230d52bec

View File

@@ -8,11 +8,10 @@ if [ "$$" -eq 1 ]; then
echo "Termination signal received, forwarding to subprocesses..." echo "Termination signal received, forwarding to subprocesses..."
# Gracefully terminate subprocesses # Gracefully terminate subprocesses
if command -v pkill &>/dev/null; then for pid in "${pids[@]}"; do
pkill -P $$ echo "Terminating PID $pid"
elif command -v kill &>/dev/null; then kill -TERM "$pid" 2>/dev/null
kill -TERM -- -$$ done
fi
# Wait for all child processes to terminate # Wait for all child processes to terminate
wait wait
@@ -23,6 +22,9 @@ fi
echo "Starting..." echo "Starting..."
# Array to hold the PIDs of the subprocesses
pids=()
#################### ####################
# Starting scripts # # 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.nok/return 1/g" "$SCRIPTS"
sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS" sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS"
# shellcheck source=/dev/null # 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 else
# Support for posix only shell # 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 fi
# Track the PID of the background process
pids+=($!)
# Cleanup # Cleanup
rm "$SCRIPTS" rm "$SCRIPTS"
done done