forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base Image: S6 overlay & jemalloc update (home-assistant#72425)
* Update base image with new s6-Overlay & jemalloc * add build version * Update finish
- Loading branch information
Showing
4 changed files
with
77 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 24 additions & 18 deletions
42
rootfs/etc/services.d/home-assistant/finish
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
#!/usr/bin/execlineb -S1 | ||
#!/usr/bin/env bashio | ||
# ============================================================================== | ||
# Take down the S6 supervision tree when Home Assistant fails | ||
# ============================================================================== | ||
define HA_RESTART_EXIT_CODE 100 | ||
define SIGNAL_EXIT_CODE 256 | ||
define SIGTERM 15 | ||
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= | ||
|
||
foreground { s6-echo "[finish] process exit code ${1}" } | ||
bashio::log.info "Home Assistant Core 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}" } | ||
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} } | ||
if { s6-test ${signal} -ne ${SIGTERM} } | ||
s6-svscanctl -t /var/run/s6/services | ||
} | ||
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}" | ||
|
||
foreground { redirfd -w 1 /var/run/s6/env-stage3/S6_STAGE2_EXITED s6-echo -n -- ${1} } | ||
s6-svscanctl -t /var/run/s6/services | ||
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 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,49 @@ | ||
#!/bin/execlineb -S0 | ||
|
||
## | ||
## load default PATH (the same that Docker includes if not provided) if it doesn't exist, | ||
## then go ahead with stage1. | ||
## this was motivated due to this issue: | ||
## - https://github.com/just-containers/s6-overlay/issues/108 | ||
## | ||
|
||
/bin/importas -D /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH | ||
export PATH ${PATH} | ||
|
||
## | ||
## Skip further init if the user has a given CMD. | ||
## This is to prevent Home Assistant from starting twice if the user | ||
## decided to override/start via the CMD. | ||
## | ||
|
||
ifelse { s6-test $# -ne 0 } | ||
{ | ||
$@ | ||
#!/usr/bin/env bashio | ||
|
||
# This is the first program launched at container start. | ||
# We don't know where our binaries are and we cannot guarantee | ||
# that the default PATH can access them. | ||
# So this script needs to be entirely self-contained until it has | ||
# at least /command, /usr/bin and /bin in its PATH. | ||
|
||
addpath () { | ||
x="$1" | ||
IFS=: | ||
set -- $PATH | ||
IFS= | ||
while test "$#" -gt 0 ; do | ||
if test "$1" = "$x" ; then | ||
return | ||
fi | ||
shift | ||
done | ||
PATH="${x}:$PATH" | ||
} | ||
/etc/s6/init/init-stage1 $@ | ||
|
||
if test -z "$PATH" ; then | ||
PATH=/bin | ||
fi | ||
|
||
addpath /bin | ||
addpath /usr/bin | ||
addpath /command | ||
export PATH | ||
|
||
# Now we're good: s6-overlay-suexec is accessible via PATH, as are | ||
# all our binaries. | ||
|
||
# Skip further init if the user has a given CMD. | ||
# This is to prevent Home Assistant from starting twice if the user | ||
# decided to override/start via the CMD. | ||
if test $# -ne 0 ; then | ||
exec "$@" | ||
fi | ||
|
||
# Run preinit as root, then run stage0 as the container's user (can be | ||
# root, can be a normal user). | ||
|
||
exec s6-overlay-suexec \ | ||
' /package/admin/s6-overlay-@VERSION@/libexec/preinit' \ | ||
'' \ | ||
/package/admin/s6-overlay-@VERSION@/libexec/stage0 \ | ||
"$@" |