forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
executable file
·49 lines (41 loc) · 1.06 KB
/
init
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh -e
# 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"
}
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/libexec/preinit' \
'' \
/package/admin/s6-overlay/libexec/stage0 \
"$@"