mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-09 17:15:57 +02:00
Change order of trap
This commit is contained in:
@@ -3,12 +3,11 @@
|
|||||||
|
|
||||||
# Only trap SIGTERM if the script's PID is 1
|
# Only trap SIGTERM if the script's PID is 1
|
||||||
if [ "$$" -eq 1 ]; then
|
if [ "$$" -eq 1 ]; then
|
||||||
echo "PID is 1, trapping SIGTERM..."
|
|
||||||
set -m
|
set -m
|
||||||
terminate() {
|
terminate() {
|
||||||
echo "Termination signal received, forwarding to subprocesses..."
|
echo "Termination signal received, forwarding to subprocesses..."
|
||||||
|
|
||||||
# Check for available commands to terminate subprocesses
|
# Gracefully terminate subprocesses
|
||||||
if command -v pkill &>/dev/null; then
|
if command -v pkill &>/dev/null; then
|
||||||
pkill -P $$
|
pkill -P $$
|
||||||
elif command -v kill &>/dev/null; then
|
elif command -v kill &>/dev/null; then
|
||||||
@@ -20,7 +19,6 @@ if [ "$$" -eq 1 ]; then
|
|||||||
echo "All subprocesses terminated. Exiting."
|
echo "All subprocesses terminated. Exiting."
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
trap terminate SIGTERM SIGINT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting..."
|
echo "Starting..."
|
||||||
@@ -77,7 +75,8 @@ done
|
|||||||
if [ "$$" -eq 1 ]; then
|
if [ "$$" -eq 1 ]; then
|
||||||
echo " "
|
echo " "
|
||||||
echo -e "\033[0;32mEverything started!\033[0m"
|
echo -e "\033[0;32mEverything started!\033[0m"
|
||||||
sleep infinity
|
trap terminate SIGTERM SIGINT
|
||||||
|
exec sleep infinity
|
||||||
else
|
else
|
||||||
echo " "
|
echo " "
|
||||||
echo -e "\033[0;32mStarting the upstream container\033[0m"
|
echo -e "\033[0;32mStarting the upstream container\033[0m"
|
||||||
|
|||||||
Reference in New Issue
Block a user