-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
52 lines (44 loc) · 1.47 KB
/
launch.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
# sh launch.sh {3 4 5 6 7...} {0 1 2 ...}
# first arg : number of nodes (containers)
# second arg : number of failing nodes (returning random int instead of calculation)
if [ "$1" == '' ]; then
echo "no first argument --> 3 containers is the default"
NUM=3
else
NUM=$1
fi
if [ "$2" == '' ]; then
echo "no second argument --> 0 faulty containers is the default"
BYZ=0
else
BYZ=$2
fi
if [ $NUM -lt 2 ]; then
echo first argument too small choose between 2 and 99
exit 1
fi
if [ $NUM -gt 99 ]; then
echo first argument too big choose between 2 and 99
exit 1
fi
if [ $BYZ -lt 0 ]; then
echo second argument too small choose between 0 and your first argument
exit 1
fi
if [ $BYZ -gt $NUM ]; then
echo second argument too big choose between 0 and your first argument
exit 1
fi
docker network create calculator-network
echo "Building decentralized calculator image"
docker build -t $"decentralized-calculator-app" ./calculator-server/.
for i in $(seq 1 $NUM); do
PORT=$((8000 + i))
if [ $i -le $BYZ ]; then
echo "Launching decentralized calculator n°$i at port $PORT, is byzantine"
docker run -id --rm --name $"decentra-calcu-$i" --net calculator-network -p $PORT:8000 -d $"decentralized-calculator-app" ./calculator-server $i $NUM true
else
echo "Launching decentralized calculator n°$i at port $PORT, not byzantine"
docker run -id --rm --name $"decentra-calcu-$i" --net calculator-network -p $PORT:8000 -d $"decentralized-calculator-app" ./calculator-server $i $NUM false
fi
done