-
Notifications
You must be signed in to change notification settings - Fork 7
/
entrypoint.sh
executable file
·67 lines (49 loc) · 1.21 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
65
66
67
#!/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
if [[ "${1}" == "install" ]]; then
echo "copying gpu cache files"
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"
nsenter -t 1 -m bash "${ACTION_FILE}"
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