forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finish
executable file
·30 lines (25 loc) · 1.02 KB
/
finish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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 SIGNAL_NO=${2}
declare NEW_EXIT_CODE=
bashio::log.info "Home Assistant Core finish process exit code ${APP_EXIT_CODE}"
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 ${SIGNAL_NO}"
NEW_EXIT_CODE=$((128 + SIGNAL_NO))
echo ${NEW_EXIT_CODE} > /run/s6-linux-init-container-results/exitcode
if [[ ${SIGNAL_NO} -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