-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit
57 lines (46 loc) · 1.41 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
50
51
52
53
54
55
56
57
#!/bin/sh
#
# Make sure dinit runs with a clean environment,
# while also ensuring that PATH is set in container
# environments
#
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
# in a container, sanitize PATH and 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
export PATH=@DEFAULT_PATH_ENV@
exec @DINIT_PATH@ "$@"
fi
# minimal defaults
set -- PATH=@DEFAULT_PATH_ENV@ 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 /usr/bin/env -i "$@"