mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 18:01:03 +01:00
Sigterm handling
This commit is contained in:
@@ -2,6 +2,20 @@
|
||||
# shellcheck shell=bash
|
||||
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 #
|
||||
####################
|
||||
@@ -40,7 +54,7 @@ for SCRIPTS in /etc/cont-init.d/*; do
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user