-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit-stack
More file actions
executable file
·48 lines (42 loc) · 1.08 KB
/
init-stack
File metadata and controls
executable file
·48 lines (42 loc) · 1.08 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
#!/bin/bash
# check to see if this file is being run or sourced from another script
_is_sourced() {
# https://unix.stackexchange.com/a/215279
[ "${#FUNCNAME[@]}" -ge 2 ] \
&& [ "${FUNCNAME[0]}" = '_is_sourced' ] \
&& [ "${FUNCNAME[1]}" = 'source' ]
}
env_list=$(find /opt/drycc/*/env/* 2>/dev/null || echo "")
for env in ${env_list}
do
key=$(echo "${env}" | awk -F "/" '{print $NF}')
value=$(<"${env}")
# shellcheck source=/dev/null
export "${key}=${value}"
done
env_launch_list=$(find /opt/drycc/*/env.launch/* 2>/dev/null || echo "")
for env in ${env_launch_list}
do
key=$(echo "${env}" | awk -F "/" '{print $NF}')
value=$(<"${env}")
# shellcheck source=/dev/null
export "${key}=${value}"
done
profile_list=$(find /opt/drycc/*/profile.d/* 2>/dev/null || echo "")
for profile in ${profile_list}
do
# shellcheck source=/dev/null
. "${profile}"
done
exec_list=$(find /opt/drycc/*/exec.d/* 2>/dev/null) || echo ""
for _exec in ${exec_list}
do
"${_exec}"
done
if ! _is_sourced; then
if [[ "$$" == "1" ]] ; then
exec tini -g -- "$@"
else
exec tini -sg -- "$@"
fi
fi