-
Notifications
You must be signed in to change notification settings - Fork 158
/
entrypoint.sh
executable file
·58 lines (44 loc) · 1.1 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
#!/bin/bash
set +e
## Functions
function apk_add {
echo "Installing additional OS packages"
while IFS= read -r pkg
do
echo "Installing ${pkg}"
apk add --no-cache -q "${pkg}"
done < "$1"
}
function pip_install {
echo "Installing Python packages"
pip install -r "$1"
}
function galaxy_install {
echo "Install Ansible Collections"
ansible-galaxy install -r "$1"
}
function run_command {
echo "Executing given commands"
bash -c "$*"
}
if [ "$APK" ]; then APK=$APK
elif [ -f "/extras/apk.txt" ]; then APK="/extras/apk.txt"
else APK=''
fi
if [ "$REQ" ]; then REQ=$REQ
elif [ -f "/extras/requirements.txt" ];then REQ="/extras/requirements.txt"
else REQ=''
fi
if [ "$COLLECTIONS" ]; then COLLECTIONS=$COLLECTIONS
elif [ -f "/extras/requirements.yml" ]; then COLLECTIONS="/extras/requirements.yml"
else COLLECTIONS=''
fi
[[ -z "$APK" ]] || apk_add "$APK"
[[ -z "$REQ" ]] || pip_install "$REQ"
[[ -z "$COLLECTIONS" ]] || galaxy_install "$COLLECTIONS"
if [ -z "$1" ]
then
echo "Starting an interactive Bash session"
/bin/bash
else run_command "$*"
fi