-
Notifications
You must be signed in to change notification settings - Fork 1
/
Start-Builder.sh
executable file
·70 lines (63 loc) · 1.99 KB
/
Start-Builder.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
68
69
70
#!/usr/bin/env bash
set -e
#set -x
Configs="\
aarch64-3.10 \
armv5-3.2 \
armv7-2.6 \
armv7-3.2 \
mips-3.4 \
mipsel-3.4 \
x64-3.2 \
x86-2.6"
DockerImage='builder'
PersistentVolume='EntwarePersistent'
EntryScriptName='propagate_env.sh'
StartContainer() {
RunningContainers=$(docker container list --format '{{json .}}' | jq -r '.Names')
ExistingVolumes=$(docker volume list --format '{{json .}}' | jq -r '.Name')
if [ -z "$(echo $ExistingVolumes | grep $PersistentVolume)" ]; then
echo 'Creating volume for persistent storage...'
docker volume create $PersistentVolume
TmpContainer='tmpEntwareContainer'
docker container create --rm --mount source=${PersistentVolume},target=/mnt/${PersistentVolume} \
--name ${TmpContainer} ${DockerImage}
docker cp "${EntryScriptName}" "${TmpContainer}:/mnt/${PersistentVolume}"
docker container rm $TmpContainer
fi
if [ -z "$(echo $RunningContainers | grep $1)" ]; then
if [ -z "$(echo $ExistingVolumes | grep $1)" ]; then
docker volume create $1
fi
gnome-terminal --tab -- \
docker run --rm --mount source=$1,target=/home/me/E \
--mount source=${PersistentVolume},target=/mnt/${PersistentVolume} \
--entrypoint "/mnt/${PersistentVolume}/${EntryScriptName}" --interactive --tty \
--name $1 --hostname $1 --env ENTWARE_ARCH=$1 ${DockerImage}
else
echo 'Already started, attaching'
gnome-terminal --tab -- \
docker exec -it $1 bash
fi
}
i=0
echo '0) All'
for item in $Configs; do
i=$((i+1))
echo "${i}) $item"
done
read -p "Pick some container to run: " ConfigNr
if [ $ConfigNr -gt $i ] || [ $ConfigNr -lt 0 ]; then
echo 'Smart choice (or not?)'
exit 1
fi
i=0
for item in $Configs; do
i=$((i+1))
if [ $ConfigNr -eq 0 ]; then
StartContainer $item
elif [ $i -eq $ConfigNr ]; then
StartContainer $item
break
fi
done