2020-04-10 20:04:50 +00:00
|
|
|
#!/usr/bin/execlineb -S1
|
2020-03-22 23:39:37 +00:00
|
|
|
# ==============================================================================
|
|
|
|
# Take down the S6 supervision tree when Home Assistant fails
|
|
|
|
# ==============================================================================
|
2021-09-06 12:37:33 +00:00
|
|
|
define HA_RESTART_EXIT_CODE 100
|
|
|
|
define SIGNAL_EXIT_CODE 256
|
|
|
|
define SIGTERM 15
|
|
|
|
|
|
|
|
foreground { s6-echo "[finish] process exit code ${1}" }
|
|
|
|
|
|
|
|
if { s6-test ${1} -ne ${HA_RESTART_EXIT_CODE} }
|
|
|
|
ifelse { s6-test ${1} -eq ${SIGNAL_EXIT_CODE} } {
|
|
|
|
# Process terminated by a signal
|
|
|
|
define signal ${2}
|
|
|
|
foreground { s6-echo "[finish] process received signal ${signal}" }
|
2021-11-14 15:56:09 +00:00
|
|
|
backtick -n new_exit_code { s6-expr 128 + ${signal} }
|
|
|
|
importas -ui new_exit_code new_exit_code
|
|
|
|
foreground { redirfd -w 1 /var/run/s6/env-stage3/S6_STAGE2_EXITED s6-echo -n -- ${new_exit_code} }
|
2021-09-06 12:37:33 +00:00
|
|
|
if { s6-test ${signal} -ne ${SIGTERM} }
|
|
|
|
s6-svscanctl -t /var/run/s6/services
|
|
|
|
}
|
2020-03-25 09:14:15 +00:00
|
|
|
|
2021-11-14 15:56:09 +00:00
|
|
|
foreground { redirfd -w 1 /var/run/s6/env-stage3/S6_STAGE2_EXITED s6-echo -n -- ${1} }
|
2020-04-10 20:04:50 +00:00
|
|
|
s6-svscanctl -t /var/run/s6/services
|