forked from nsacyber/WALKOFF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
walkoff.sh
executable file
·48 lines (40 loc) · 1.45 KB
/
walkoff.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
#!/bin/bash
BUILDARG="^-[a-zA-Z]*b|--build"
CLEANARG="^-[a-zA-Z]*c|--clean"
WALK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ $WALK_DIR != $PWD ]; then
echo "Exiting because you aren't running the walkoff.sh script from within /WALKOFF"
exit
fi
echo "Starting WALKOFF Bootloader..."
if [ ! "$(docker image ls | grep -w "walkoff_bootloader")" ]; then
echo "Building WALKOFF Bootloader as the image didn't exist..."
docker build -t walkoff_bootloader -f bootloader/Dockerfile $WALK_DIR
fi
for var in "$@"
do
if [[ $var =~ $BUILDARG ]]; then
echo "Building WALKOFF Bootloader as you specified -b or --build..."
docker build -t walkoff_bootloader -f bootloader/Dockerfile $WALK_DIR
break
fi
done
if [ ! "$(docker network ls | grep -w "walkoff_network")" ]; then
printf "Creating walkoff_network network: "
docker network create --attachable=True --driver=overlay walkoff_network
fi
docker run --rm -it --network walkoff_network --name walkoff_bootloader \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--mount type=bind,source=$(pwd),target=$(pwd) \
--mount type=bind,source=$(pwd)/data/config.yml,target=/common_env.yml \
-e DOCKER_HOST=unix:///var/run/docker.sock \
-w $(pwd) \
walkoff_bootloader "$@"
for var in "$@"
do
if [[ $var =~ $CLEANARG ]]; then
printf "Removing walkoff_network network: "
docker network rm walkoff_network
break
fi
done