mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 06:14:07 +02:00
Sigterm handling
This commit is contained in:
@@ -2,6 +2,20 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
echo "Starting..."
|
echo "Starting..."
|
||||||
|
|
||||||
|
##################
|
||||||
|
# Handle sigterm #
|
||||||
|
##################
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
echo "Caught SIGTERM, cleaning up..."
|
||||||
|
# Sends SIGTERM to all child processes
|
||||||
|
pkill -TERM -P $$ || true
|
||||||
|
wait
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup SIGTERM || true
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Starting scripts #
|
# Starting scripts #
|
||||||
####################
|
####################
|
||||||
@@ -40,7 +54,7 @@ for SCRIPTS in /etc/cont-init.d/*; do
|
|||||||
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
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|||||||
Reference in New Issue
Block a user