-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·82 lines (63 loc) · 1.96 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·82 lines (63 loc) · 1.96 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
82
#!/usr/bin/env bash
set -o pipefail
set -o nounset
set -x
sleep="${2:-}"
# clean up any existing gpu files
# can happen if using a different version than cached
rm -r /mnt/gpu/* || true
set -o errexit
if [[ -z "${1}" ]]; then
echo "Must provide a non-empty action as first argument"
exit 1
fi
if [[ "${1}" == "copy" ]]; then
echo "copying gpu cache files and exiting"
cp -a /opt/gpu/. /mnt/gpu/
echo "Completed successfully!"
exit 0
fi
# Map the requested action to the install mode passed to install.sh. All three install
# variants stage the same gpu cache files; only the env var handed to install.sh differs.
# install -> full compile + device init (legacy behaviour)
# build-only -> compile/cache the kernel module only (VHD build, no GPU)
# install-skip-build -> device init only, reusing the module prebuilt into the VHD
GPU_INSTALL_MODE_ENV=""
case "${1}" in
build-only) GPU_INSTALL_MODE_ENV="AKSGPU_BUILD_ONLY=1" ;;
install-skip-build) GPU_INSTALL_MODE_ENV="AKSGPU_SKIP_KERNEL_BUILD=1" ;;
esac
if [[ "${1}" == "install" || -n "${GPU_INSTALL_MODE_ENV}" ]]; then
echo "copying gpu cache files (${1})"
cp -a /opt/gpu/. /mnt/gpu/
echo "copied successfully!"
fi
ACTION_FILE="/opt/actions/install.sh"
if [[ ! -f "$ACTION_FILE" ]]; then
echo "Expected to find action file '$ACTION_FILE', but did not exist"
exit 1
fi
echo "Cleaning up stale actions"
rm -rf /mnt/actions/*
echo "Copying fresh actions"
cp -R /opt/actions/. /mnt/actions
echo "Executing nsenter"
if [[ -n "${GPU_INSTALL_MODE_ENV}" ]]; then
nsenter -t 1 -m env "${GPU_INSTALL_MODE_ENV}" bash "${ACTION_FILE}"
else
nsenter -t 1 -m bash "${ACTION_FILE}"
fi
RESULT="${PIPESTATUS[0]}"
if [ $RESULT -eq 0 ]; then
# Success.
rm -rf /mnt/actions/*
echo "Completed successfully!"
else
echo "Failed during nsenter command execution"
exit 1
fi
if [[ -z "${sleep}" ]]; then
exit 0
fi
echo "Sleeping forever"
sleep infinity