-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·149 lines (141 loc) · 3.41 KB
/
run.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
#======================================================================================
#
# FILE: run.sh
#
# USAGE: run.sh [-s] [-a] [-b] [--server] [--alice] [--bob]
#
# DESCRPITION: Execute TwoPartyComputation, as Server or Client.
#
# OPTIONS: see function 'usage' below
# REQUIREMENTS: docker
#======================================================================================
usage () {
cat <<-EOF
usage: $0 [-h] [-s [-n]]
usage: $0 [-a FUNCTION INPUT... -cn NAME -s SERVER_IP -p PORT]
usage: $0 [-b FUNCTION INPUT... -cn NAME -s SERVER_IP -p PORT]
usage: $0 [-a FUNCTION INPUT... -n]
usage: $0 [-b FUNCTION INPUT... -n]
-h | --help print this help
-s | --server start Server
-a | --alice start Alice
-b | --bob start Bob
-cn specify common name you want to talk to
-n no certificates
EOF
}
server () {
echo "server"
mkdir -p .server
mkdir .server/conf
mkdir .server/data
cp -r exceptions/ .server/
cp -r fpre/ .server/
cp -r protobuf/ .server/
cp -r tests/ .server/
cp -r tools/ .server/
cp MPC.py .server/
cp Server.py .server/
cp TwoPartyComputation.py .server/
cp -r data/certificates_server/ .server/data/certificates
cp docker/Dockerfile_server .server/Dockerfile
cp conf/conf.py .server/conf/conf.py
cp conf/cert_conf_server.py .server/conf/cert_conf.py
cd .server/
docker build -t server .
cd ..
rm -r .server/
clear
echo "Docker container built"
docker run --net=host server python3 -u Server.py $@
}
client () {
echo "client"
mkdir -p .client_base/data/CBMC-GC-2/bin
cp -r cbmc_parser/ .client_base/
cp -r exceptions/ .client_base/
cp -r fpre/ .client_base/
cp -r protobuf/ .client_base/
cp -r tests/ .client_base/
cp -r tools/ .client_base/
cp MPC.py .client_base/
cp TwoPartyComputation.py .client_base/
mkdir -p .client_base/CBMC-GC-2/bin/
cp data/CBMC-GC-2/bin/cbmc-gc .client_base/data/CBMC-GC-2/bin/cbmc-gc
cp docker/Dockerfile_client_base .client_base/Dockerfile
chmod +x .client_base/data/CBMC-GC-2/bin/cbmc-gc
cd .client_base/
docker build -t client_base .
cd ..
rm -r .client_base/
clear
echo "client built"
}
alice () {
noslash=$(echo $1 | sed 's/\///g')
newfile=".alice/$noslash"
echo "alice"
mkdir -p .alice
mkdir .alice/conf
mkdir .alice/data
cp -r data/certificates_alice .alice/data/certificates
cp docker/Dockerfile_alice .alice/Dockerfile
cp conf/conf.py .alice/conf/conf.py
cp conf/cert_conf_alice.py .alice/conf/cert_conf.py
cp $1 $newfile
chmod +x .alice/data/CBMC-GC-2/bin/cbmc-gc
cd .alice/
docker build -t alice .
cd ..
rm -r .alice/
clear
echo "Alice built"
shift
docker run --net=host alice python3 -u TwoPartyComputation.py $noslash $@
}
bob () {
noslash=$(echo $1 | sed 's/\///g')
newfile=".bob/$noslash"
echo "bob"
mkdir -p .bob
mkdir .bob/conf
mkdir .bob/data
cp -r data/certificates_bob .bob/data/certificates
cp docker/Dockerfile_bob .bob/Dockerfile
cp conf/conf.py .bob/conf/conf.py
cp conf/cert_conf_bob.py .bob/conf/cert_conf.py
cp $1 $newfile
chmod +x .bob/data/CBMC-GC-2/bin/cbmc-gc
cd .bob/
docker build -t bob .
cd ..
rm -r .bob/
clear
echo "Bob built"
shift
docker run --net=host bob python3 -u TwoPartyComputation.py $noslash $@
}
## Main
fullpath=$2
case "$1" in
--server | -s)
shift
server "$@"
;;
--alice | -a)
shift
client
alice $noslash $@
;;
--bob | -b)
shift
client
bob "$@"
;;
--help | -h)
usage
;;
*)
usage
esac