forked from scaleway/image-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·54 lines (40 loc) · 1.04 KB
/
install.sh
File metadata and controls
executable file
·54 lines (40 loc) · 1.04 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
#!/bin/bash
# Variables
BRANCH=${BRANCH:-master}
FLAVORS=$(echo ${FLAVORS:-${@:-"common"}} | tr "," " ")
ROOTDIR=${ROOTDIR:-/}
DL=${DL:-$(hash curl 2>/dev/null && echo "curl" || echo "wget")}
TMPFILE=/tmp/image-tools-temporary.tar
# Download with curl or wget
dl() {
if [ "$DL" = "wget" ]; then
wget -q -O - --no-check-certificate $@
fi
if [ "$DL" = "curl" ]; then
curl -sLk $@
fi
}
# Apply the flavor directory over the ROOTDIR
apply_flavor() {
local flavor="${1}"
echo "applying flavor '${flavor}'"
tar --strip=2 -C ${ROOTDIR}/ -xzf ${TMPFILE} image-tools-${BRANCH}/skeleton-${flavor};
# Executes flavor's install script
if [ -x /tmp/image-tools-install-${flavor}.sh ]; then
/tmp/image-tools-install-${flavor}.sh
fi
}
# Cleaning
clean() {
rm -rf ${TMPFILE}
}
main() {
# Download tarball
dl https://github.com/scaleway/image-tools/archive/${BRANCH}.tar.gz > ${TMPFILE}
# Apply flavors
for flavor in ${FLAVORS}; do
apply_flavor ${flavor}
done
clean
}
main