-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
51 lines (43 loc) · 971 Bytes
/
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
#!/bin/bash
set -ex
set -o pipefail
function set_mirrors() {
if [ ! "$INPUT_MIRROR" ]; then
INPUT_MIRROR="bfsu"
fi
if [ -e /tmp/"${INPUT_MIRROR}".condarc ]; then
cp -f /tmp/"${INPUT_MIRROR}".condarc "${HOME}"/.condarc
cp -f /tmp/"${INPUT_MIRROR}".sources.list /etc/apt/sources.list
cp -f /tmp/"${INPUT_MIRROR}".Rprofile "${HOME}"/.Rprofile
fi
}
function add_channels() {
if (( ${#INPUT_CHANNELS} != 0 )); then
for C in ${INPUT_CHANNELS}; do
conda config --add channels "$C"
done
fi
}
function install_packages() {
if (( ${#INPUT_PACKAGES} != 0 )); then
conda update --all -y -q
conda install -y ${INPUT_PACKAGES[@]}
fi
}
function run_cmd() {
if (( ${#INPUT_CMD} != 0)); then
${INPUT_CMD}
fi
}
function main() {
if (( $# != 0 )); then
$@
else
/bin/bash
fi
}
set_mirrors
add_channels
install_packages
run_cmd
main $@