-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·435 lines (379 loc) · 12 KB
/
install.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
#!/bin/bash
# -*- Mode:bash; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
# Copyright (C) 2015-2019, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
# This file is part of Mini-NDN.
# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
#
# Mini-NDN is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mini-NDN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mini-NDN, e.g., in COPYING.md file.
# If not, see <http://www.gnu.org/licenses/>.
#
# This file incorporates work covered by the following copyright and
# permission notice:
#
# Mininet 2.3.0d1 License
#
# Copyright (c) 2013-2016 Open Networking Laboratory
# Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
# The Leland Stanford Junior University
#
# Original authors: Bob Lantz and Brandon Heller
#
# We are making Mininet available for public use and benefit with the
# expectation that others will use, modify and enhance the Software and
# contribute those enhancements back to the community. However, since we
# would like to make the Software available for broadest use, with as few
# restrictions as possible permission is hereby granted, free of charge, to
# any person obtaining a copy of this Software to deal in the Software
# under the copyrights without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# The name and trademarks of copyright holder(s) may NOT be used in
# advertising or publicity pertaining to the Software or any derivatives
# without specific, written prior permission.
test -e /etc/debian_version && DIST="Debian"
grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
update='sudo apt-get update'
install='sudo apt-get -y install'
remove='sudo apt-get -y remove'
pkginst='sudo dpkg -i'
# Prereqs for this script
if ! which lsb_release &> /dev/null; then
$install lsb-release
fi
fi
test -e /etc/fedora-release && DIST="Fedora"
if [[ $DIST == Fedora ]]; then
update='sudo yum update'
install='sudo yum -y install'
remove='sudo yum -y erase'
pkginst='sudo rpm -ivh'
# Prereqs for this script
if ! which lsb_release &> /dev/null; then
$install redhat-lsb-core
fi
fi
NDN_SRC="ndn-src"
NDN_GITHUB="https://github.com/named-data"
NDN_CXX_VERSION="ndn-cxx-0.6.1"
NFD_VERSION="NFD-0.6.1"
PSYNC_VERSION="master"
CHRONOSYNC_VERSION="master"
NLSR_VERSION="master"
NDN_TOOLS_VERSION="master"
if [ $SUDO_USER ]; then
REAL_USER=$SUDO_USER
else
REAL_USER=$(whoami)
fi
function patchDummy {
git -C $NDN_SRC/ndn-cxx apply $(pwd)/patches/ndn-cxx-dummy-keychain-from-ndnsim.patch
if [[ "$?" -ne 0 ]]; then
echo "Patch might already be applied"
fi
}
function ndn_install {
mkdir -p $NDN_SRC
name=$1
version=$2
wafOptions=$3
if [[ $version == "master" ]]; then
if [[ -d "$NDN_SRC/$name" ]]; then
pushd $NDN_SRC/$name
git checkout master
else
git clone --depth 1 $NDN_GITHUB/$name $NDN_SRC/$name
pushd $NDN_SRC/$name
fi
else
if [[ -d $NDN_SRC/$name ]]; then
pushd $NDN_SRC/$name
if [[ $(git rev-parse --is-shallow-repository) == "true" ]]; then
git fetch --unshallow
git fetch --all
fi
else
git clone $NDN_GITHUB/$name $NDN_SRC/$name
pushd $NDN_SRC/$name
fi
git checkout $version -b version-$version || git checkout version-$version
fi
# User must use the same python version as root to use ./waf outside of this script
sudo -E -u $REAL_USER ./waf configure $wafOptions
sudo -E -u $REAL_USER ./waf && sudo ./waf install && sudo ldconfig
popd
}
function ndn {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
$install git libsqlite3-dev libboost-all-dev make g++ libssl-dev libpcap-dev pkg-config python-pip
fi
if [[ $DIST == Fedora ]]; then
$install gcc-c++ sqlite-devel boost-devel openssl-devel libpcap-devel python-pip
fi
ndn_install ndn-cxx $NDN_CXX_VERSION
ndn_install NFD $NFD_VERSION --without-websocket
ndn_install PSync $PSYNC_VERSION --with-examples
ndn_install ChronoSync $CHRONOSYNC_VERSION
ndn_install NLSR $NLSR_VERSION
ndn_install ndn-tools $NDN_TOOLS_VERSION
infoedit
}
function mininet {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $pysetup != true ]]; then
pysetup="true"
fi
git clone --depth 1 https://github.com/mininet/mininet
pushd mininet
sudo ./util/install.sh -nv
popd
}
function infoedit {
git clone --depth 1 https://github.com/NDN-Routing/infoedit.git $NDN_SRC/infoedit
pushd $NDN_SRC/infoedit
rm infoedit
sudo make install
popd
}
function minindn {
$install libigraph0-dev tshark
sudo pip install -r requirements.txt
if [[ updated != true ]]; then
if [ ! -d "build" ]; then
$update
updated="true"
fi
fi
if [[ $pysetup != true ]]; then
$install python-setuptools
pysetup="true"
fi
install_dir="/usr/local/etc/mini-ndn/"
sudo mkdir -p "$install_dir"
sudo cp topologies/default-topology.conf "$install_dir"
sudo cp topologies/minindn.caida.conf "$install_dir"
sudo cp topologies/minindn.ucla.conf "$install_dir"
sudo cp topologies/minindn.testbed.conf "$install_dir"
sudo cp topologies/current-testbed.conf "$install_dir"
sudo python setup.py develop
}
function ndn_cpp {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
$install git build-essential libssl-dev libsqlite3-dev libboost-all-dev libprotobuf-dev protobuf-compiler
fi
if [[ $DIST == Fedora ]]; then
printf '\nNDN-CPP does not support Fedora yet.\n'
return
fi
git clone --depth 1 $NDN_GITHUB/ndn-cpp $NDN_SRC/ndn-cpp
pushd $NDN_SRC/ndn-cpp
./configure
proc=$(nproc)
make -j$proc
sudo make install
sudo ldconfig
popd
}
function pyNDN {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
$install git build-essential libssl-dev libffi-dev python-dev python-pip
fi
if [[ $DIST == Fedora ]]; then
printf '\nPyNDN does not support Fedora yet.\n'
return
fi
sudo pip install cryptography trollius protobuf pytest mock
git clone --depth 1 $NDN_GITHUB/PyNDN2 $NDN_SRC/PyNDN2
pushd $NDN_SRC/PyNDN2
# Update the user's PYTHONPATH.
echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" >> ~/.bashrc
# Also update root's PYTHONPATH in case of running under sudo.
echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" | sudo tee -a /root/.bashrc > /dev/null
popd
}
function ndn_js {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
$install git nodejs npm
fi
if [[ $DIST == Fedora ]]; then
printf '\nNDN-JS does not support Fedora yet.\n'
return
fi
sudo ln -fs /usr/bin/nodejs /usr/bin/node
sudo npm install -g mocha
sudo npm install rsa-keygen sqlite3
git clone --depth 1 $NDN_GITHUB/ndn-js $NDN_SRC/ndn-js
}
function jNDN {
if [[ updated != true ]]; then
$update
updated="true"
fi
if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
$install git openjdk-8-jdk maven
fi
if [[ $DIST == Fedora ]]; then
printf '\nNDN-JS does not support Fedora yet.\n'
return
fi
git clone --depth 1 $NDN_GITHUB/jndn $NDN_SRC/jndn
pushd $NDN_SRC/jndn
mvn install
popd
}
function commonClientLibraries {
ndn_cpp
pyNDN
ndn_js
jNDN
}
function buildDocumentation {
sphinxInstalled=$(pip show sphinx | wc -l)
sphinxRtdInstalled=$(pip show sphinx_rtd_theme | wc -l)
if [[ $sphinxInstalled -eq "0" ]]; then
pip install sphinx
fi
if [[ $sphinxRtdInstalled -eq "0" ]]; then
pip install sphinx_rtd_theme
fi
cd docs
make clean
make html
}
function usage {
printf '\nUsage: %s [-a]\n\n' $(basename $0) >&2
printf 'options:\n' >&2
printf -- ' -a: install all the required dependencies\n' >&2
printf -- ' -c: install Common Client Libraries\n' >&2
printf -- ' -d: build documentation\n' >&2
printf -- ' -h: print this (H)elp message\n' >&2
printf -- ' -i: install mini-ndn\n' >&2
printf -- ' -m: install mininet and dependencies\n' >&2
printf -- ' -n: install NDN dependencies of mini-ndn including infoedit\n' >&2
printf -- ' -p: patch ndn-cxx with dummy key chain\n' >&2
exit 2
}
function quadTreeSync {
$install cmake
# Install Catch2
mkdir -p dependencies
pushd dependencies
git clone https://github.com/catchorg/Catch2.git
pushd Catch2
git checkout v2.9.2
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
popd
# Install spdlog
git clone https://github.com/gabime/spdlog.git
pushd spdlog
mkdir build
pushd build
cmake ..
make -j
sudo make install
popd
popd
sudo ldconfig
popd
git clone https://gitlab.itec.aau.at/philipp-moll/QuadTreeSyncEvaluation.git
pushd QuadTreeSyncEvaluation
cmake .
make -j
popd
}
function zmqClient {
git clone https://gitlab.itec.aau.at/minecraft/ZMQSyncPeer.git ZMQSyncPeer
pushd ZMQSyncPeer
$install python3-pip
pip3 install -r requirements.txt
popd
}
function wireshark {
# Install wireshark and NDN dissector
echo "Install wireshark and the ndn dissector"
$install tshark wireshark
if ! test -f /usr/local/share/ndn-dissect-wireshark/ndn.lua; then
git clone https://github.com/named-data/ndn-tools.git
sudo mkdir -p /usr/local/share/ndn-dissect-wireshark/
sudo cp -v ndn-tools/tools/dissect-wireshark/ndn.lua /usr/local/share/ndn-dissect-wireshark/
echo "dofile(\"/usr/local/share/ndn-dissect-wireshark/ndn.lua\")" | sudo tee -a /usr/share/wireshark/init.lua > /dev/null
fi
}
if [[ $# -eq 0 ]]; then
usage
else
while getopts 'acdhimnpqzw' OPTION
do
case $OPTION in
a)
ndn
mininet
minindn
commonClientLibraries
quadTreeSync
zmqClient
break
;;
c) commonClientLibraries;;
d) buildDocumentation;;
h) usage;;
i) minindn;;
m) mininet;;
n) ndn;;
p) patchDummy;;
q) quadTreeSync;;
z) zmqClient;;
w) wireshark;;
?) usage;;
esac
done
shift $(($OPTIND - 1))
fi