-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·36 lines (29 loc) · 851 Bytes
/
Copy pathinstall.sh
File metadata and controls
executable file
·36 lines (29 loc) · 851 Bytes
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
#!/bin/bash
set -e
# Build all the Dockerfiles into images named after their directories.
for file in *; do
if [[ -f $file/Dockerfile ]]; then
echo "Building image: $file"
docker build -t $file $file
fi
done
mkdir -p $HOME/bin
# Write out shims for the commands specified in the commands file
while read cmd; do
parts=($cmd);
cmdName=${parts[0]}
imageName=${parts[1]}
additionalFlags=${parts[@]:2}
shimName=$HOME/bin/$cmdName
echo "Writing $imageName.$cmdName shim"
cat > $shimName << EOF
#!/bin/bash -i
case "\$-" in
*i*)
docker run --rm $additionalFlags -v "\$(pwd)":/workdir -w /workdir -it $imageName $cmdName "\$@";;
*)
docker run --rm $additionalFlags -v "\$(pwd)":/workdir -w /workdir $imageName $cmdName "\$@";;
esac
EOF
chmod +x $shimName
done < commands