Files
ha-core/rootfs/etc/services.d/home-assistant/finish
Pascal Vizeli 6368df5e37 Base Image: S6 overlay & jemalloc update (#72425)
* Update base image with new s6-Overlay & jemalloc

* add build version

* Update finish
2022-05-24 15:51:06 +02:00

31 lines
1.0 KiB
Plaintext
Executable File

#!/usr/bin/env bashio
# ==============================================================================
# Take down the S6 supervision tree when Home Assistant fails
# ==============================================================================
declare RESTART_EXIT_CODE 100
declare SIGNAL_EXIT_CODE 256
declare SIGTERM 15
declare APP_EXIT_CODE=${1}
declare SYS_EXIT_CODE=${2+x}
declare NEW_EXIT_CODE=
bashio::log.info "Home Assistant Core finish process exit code ${1}"
if [[ ${APP_EXIT_CODE} -eq ${RESTART_EXIT_CODE} ]]; then
exit 0
elif [[ ${APP_EXIT_CODE} -eq ${SIGNAL_EXIT_CODE} ]]; then
bashio::log.info "Home Assistant Core finish process received signal ${APP_EXIT_CODE}"
NEW_EXIT_CODE=$((128 + SYS_EXIT_CODE))
echo ${NEW_EXIT_CODE} > /run/s6-linux-init-container-results/exitcode
if [[ ${NEW_EXIT_CODE} -eq ${SIGTERM} ]]; then
/run/s6/basedir/bin/halt
fi
else
bashio::log.info "Home Assistant Core service shutdown"
echo ${APP_EXIT_CODE} > /run/s6-linux-init-container-results/exitcode
/run/s6/basedir/bin/halt
fi