forked from chimera-linux/dinit-chimera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit
More file actions
81 lines (64 loc) · 1.99 KB
/
init
File metadata and controls
81 lines (64 loc) · 1.99 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
#
# Make sure dinit runs with a clean environment,
# while also ensuring that PATH is set in container
# environments
#
# source this file if it exists, for any overrides
if [ -r /etc/dinit/init ]; then
. /etc/dinit/init
fi
# global default, may be "unlimited" or any integer value
if [ -n "$dinit_rlimit_core" ]; then
ulimit -c "$dinit_rlimit_core"
fi
if [ "$dinit_auto_recovery" = "1" ]; then
set -- --auto-recovery "$@"
fi
if [ "$dinit_quiet" = "1" ]; then
set -- --quiet "$@"
fi
if [ -n "$dinit_log_level" ]; then
set -- --log-level "$dinit_log_level" "$@"
fi
if [ -n "$dinit_console_level" ]; then
set -- --console-level "$dinit_console_level" "$@"
fi
if [ -n "$dinit_log_file" ]; then
set -- --log-file "$dinit_log_file" "$@"
fi
unset dinit_auto_recovery dinit_quiet dinit_log_level
unset dinit_console_level dinit_log_file
export PATH=@DEFAULT_PATH_ENV@
# in a container, exec directly as we don't have a way to deal with
# the init env after the fact, and there is no initramfs anyway
if [ -n "${container+x}" ]; then
exec @DINIT_PATH@ "$@"
fi
# afaik getent is not a posix command
getent_cmd=$(command -v getent)
if [ -n "$getent_cmd" ]; then
# retrieve using getent if we can
HOME=$("$getent_cmd" passwd root | cut -f6 -d:)
else
# otherwise just grep from the passwd database...
HOME=$(grep "^root:" /etc/passwd | cut -f6 -d:)
fi
# fallback just in case we don't have anything
[ -n "$HOME" ] || HOME=/
# minimal defaults
set -- PATH=@DEFAULT_PATH_ENV@ "HOME=$HOME" @DINIT_PATH@ "$@"
# these need to be readable before we have procfs
if [ "$dinit_early_debug" ]; then
set -- \
dinit_early_debug=$dinit_early_debug \
dinit_early_debug_slow=$dinit_early_debug_slow \
dinit_early_debug_log=$dinit_early_debug_log \
"$@"
fi
# also respect this
if [ "$dinit_early_root_remount" ]; then
set -- dinit_early_root_remount=$dinit_early_root_remount "$@"
fi
# if not a container, exec in a mostly clean env...
exec env -i "$@"