-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
64 lines (47 loc) · 1.28 KB
/
entrypoint.sh
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
#!/bin/bash
#set -ex
# adopted from /opt/nvidia/nvidia-entrypoint.sh
# Gather parts in alpha order
shopt -s nullglob extglob
#_SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
_SCRIPT_DIR="/opt/nvidia"
declare -a _PARTS=( "${_SCRIPT_DIR}/entrypoint.d"/*@(.txt|.sh) )
shopt -u nullglob extglob
print_repeats() {
local -r char="$1" count="$2"
local i
for ((i=1; i<=$count; i++)); do echo -n "$char"; done
echo >&2
}
print_banner_text() {
# $1: Banner char
# $2: Text
local banner_char=$1
local -r text="$2"
local pad="${banner_char}${banner_char}"
print_repeats "${banner_char}" $((${#text} + 6))
echo "${pad} ${text} ${pad}" >&2
print_repeats "${banner_char}" $((${#text} + 6))
}
# Execute the entrypoint parts
for _file in "${_PARTS[@]}"; do
case "${_file}" in
*.txt) cat "${_file}" >&2;;
*.sh) source "${_file}" >&2;;
esac
done
echo >&2
# This script can either be a wrapper around arbitrary command lines,
# or it will simply exec bash if no arguments were given
if [[ $# -eq 0 ]]; then
exec "/bin/bash"
else
exec "$@"
fi
# hand over to nvidia if present
# if [ -r /opt/nvidia/nvidia_entrypoint.sh ]; then
# exec /opt/nvidia/nvidia_entrypoint.sh "$@"
# else
# bash /opt/nvidia/entrypoint.d/90-turbovnc.sh
# exec "$@"
# fi