blob: e2d93437e29e20c803ee5ef891038840493c7a1c [file] [log] [blame]
ashu2ad32e22015-05-29 13:37:40 -05001#!/bin/bash
Vince Lehmanb8b18062015-07-14 13:07:22 -05002# -*- Mode:bash; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
3#
Philipp Moll55e2dd92020-02-20 09:59:27 +01004# Copyright (C) 2015-2020, The University of Memphis,
Ashlesh Gawande0cccdb82016-08-15 12:58:06 -05005# Arizona Board of Regents,
6# Regents of the University of California.
Vince Lehmanb8b18062015-07-14 13:07:22 -05007#
8# This file is part of Mini-NDN.
9# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
10#
11# Mini-NDN is free software: you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation, either version 3 of the License, or
14# (at your option) any later version.
15#
16# Mini-NDN is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with Mini-NDN, e.g., in COPYING.md file.
23# If not, see <http://www.gnu.org/licenses/>.
24#
25# This file incorporates work covered by the following copyright and
26# permission notice:
27#
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -050028# Mininet 2.3.0d1 License
Vince Lehmanb8b18062015-07-14 13:07:22 -050029#
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -050030# Copyright (c) 2013-2016 Open Networking Laboratory
Vince Lehmanb8b18062015-07-14 13:07:22 -050031# Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
32# The Leland Stanford Junior University
33#
34# Original authors: Bob Lantz and Brandon Heller
35#
36# We are making Mininet available for public use and benefit with the
37# expectation that others will use, modify and enhance the Software and
38# contribute those enhancements back to the community. However, since we
39# would like to make the Software available for broadest use, with as few
40# restrictions as possible permission is hereby granted, free of charge, to
41# any person obtaining a copy of this Software to deal in the Software
42# under the copyrights without restriction, including without limitation
43# the rights to use, copy, modify, merge, publish, distribute, sublicense,
44# and/or sell copies of the Software, and to permit persons to whom the
45# Software is furnished to do so, subject to the following conditions:
46#
47# The above copyright notice and this permission notice shall be included
48# in all copies or substantial portions of the Software.
49#
50# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
51# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57#
58# The name and trademarks of copyright holder(s) may NOT be used in
59# advertising or publicity pertaining to the Software or any derivatives
60# without specific, written prior permission.
ashu2ad32e22015-05-29 13:37:40 -050061
62test -e /etc/debian_version && DIST="Debian"
63grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
64
65if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
66 update='sudo apt-get update'
67 install='sudo apt-get -y install'
68 remove='sudo apt-get -y remove'
69 pkginst='sudo dpkg -i'
70 # Prereqs for this script
71 if ! which lsb_release &> /dev/null; then
72 $install lsb-release
73 fi
74fi
75
76test -e /etc/fedora-release && DIST="Fedora"
77if [[ $DIST == Fedora ]]; then
78 update='sudo yum update'
79 install='sudo yum -y install'
80 remove='sudo yum -y erase'
81 pkginst='sudo rpm -ivh'
82 # Prereqs for this script
83 if ! which lsb_release &> /dev/null; then
84 $install redhat-lsb-core
85 fi
86fi
87
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050088NDN_SRC="ndn-src"
ashu2ad32e22015-05-29 13:37:40 -050089
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050090NDN_GITHUB="https://github.com/named-data"
ashu2ad32e22015-05-29 13:37:40 -050091
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050092NDN_CXX_VERSION="master"
93NFD_VERSION="master"
94PSYNC_VERSION="master"
95CHRONOSYNC_VERSION="master"
96NLSR_VERSION="master"
97NDN_TOOLS_VERSION="master"
ashu2ad32e22015-05-29 13:37:40 -050098
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050099if [ $SUDO_USER ]; then
100 REAL_USER=$SUDO_USER
101else
102 REAL_USER=$(whoami)
103fi
104
105function patchDummy {
Alex Lane587b78f2020-08-13 18:43:14 -0500106 git -C $NDN_SRC/ndn-cxx apply $(pwd)/util/patches/ndn-cxx-dummy-keychain-from-ndnsim.patch
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500107 if [[ "$?" -ne 0 ]]; then
108 echo "Patch might already be applied"
109 fi
ashu2ad32e22015-05-29 13:37:40 -0500110}
111
Giovanni Griecobb31ed22020-03-23 10:04:59 +0100112function quiet_install {
113 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
114 update='sudo DEBIAN_FRONTEND=noninteractive apt-get update'
115 install='sudo DEBIAN_FRONTEND=noninteractive apt-get -y install'
116 remove='sudo DEBIAN_FRONTEND=noninteractive apt-get -y remove'
117
118 echo "wireshark-common wireshark-common/install-setuid boolean false" | sudo debconf-set-selections
119 fi
120}
121
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500122function ndn_install {
123 mkdir -p $NDN_SRC
124 name=$1
125 version=$2
126 wafOptions=$3
127
128 if [[ $version == "master" ]]; then
129 if [[ -d "$NDN_SRC/$name" ]]; then
130 pushd $NDN_SRC/$name
131 git checkout master
132 else
133 git clone --depth 1 $NDN_GITHUB/$name $NDN_SRC/$name
134 pushd $NDN_SRC/$name
135 fi
136 else
137 if [[ -d $NDN_SRC/$name ]]; then
138 pushd $NDN_SRC/$name
139 if [[ $(git rev-parse --is-shallow-repository) == "true" ]]; then
140 git fetch --unshallow
141 git fetch --all
142 fi
143 else
144 git clone $NDN_GITHUB/$name $NDN_SRC/$name
145 pushd $NDN_SRC/$name
146 fi
147 git checkout $version -b version-$version || git checkout version-$version
ashu2ad32e22015-05-29 13:37:40 -0500148 fi
149
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500150 # User must use the same python version as root to use ./waf outside of this script
151 sudo -E -u $REAL_USER ./waf configure $wafOptions
152 sudo -E -u $REAL_USER ./waf && sudo ./waf install && sudo ldconfig
153 popd
ashu2ad32e22015-05-29 13:37:40 -0500154}
155
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500156function ndn {
ashu2ad32e22015-05-29 13:37:40 -0500157 if [[ updated != true ]]; then
158 $update
159 updated="true"
160 fi
161
162 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500163 $install git libsqlite3-dev libboost-all-dev make g++ libssl-dev libpcap-dev pkg-config python-pip
ashu2ad32e22015-05-29 13:37:40 -0500164 fi
165
166 if [[ $DIST == Fedora ]]; then
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500167 $install gcc-c++ sqlite-devel boost-devel openssl-devel libpcap-devel python-pip
ashu2ad32e22015-05-29 13:37:40 -0500168 fi
169
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500170 ndn_install ndn-cxx $NDN_CXX_VERSION
171 ndn_install NFD $NFD_VERSION --without-websocket
172 ndn_install PSync $PSYNC_VERSION --with-examples
173 ndn_install ChronoSync $CHRONOSYNC_VERSION
174 ndn_install NLSR $NLSR_VERSION
175 ndn_install ndn-tools $NDN_TOOLS_VERSION
176 infoedit
ashu2ad32e22015-05-29 13:37:40 -0500177}
178
179function mininet {
180 if [[ updated != true ]]; then
181 $update
182 updated="true"
183 fi
184
185 if [[ $pysetup != true ]]; then
186 pysetup="true"
187 fi
188
189 git clone --depth 1 https://github.com/mininet/mininet
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500190 pushd mininet
191 sudo ./util/install.sh -nv
192 popd
ashu2ad32e22015-05-29 13:37:40 -0500193}
194
Alexander Laneea2d5d62019-10-04 16:48:52 -0500195function wifi {
196 if [[ updated != true ]]; then
197 $update
198 updated="true"
199 fi
200
201 if [[ $pysetup != true ]]; then
202 pysetup="true"
203 fi
204
205 git clone --depth 1 https://github.com/intrig-unicamp/mininet-wifi.git
206 pushd mininet-wifi
207 sudo ./util/install.sh -Wlfnv
208 popd
209}
210
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000211function infoedit {
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500212 git clone --depth 1 https://github.com/NDN-Routing/infoedit.git $NDN_SRC/infoedit
213 pushd $NDN_SRC/infoedit
214 rm infoedit
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000215 sudo make install
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500216 popd
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000217}
218
ashu2ad32e22015-05-29 13:37:40 -0500219function minindn {
Philipp Moll55e2dd92020-02-20 09:59:27 +0100220 $install libigraph0-dev tshark
Philipp Moll61a2be82019-07-12 08:33:09 +0200221 sudo pip install -r requirements.txt
222
ashu2ad32e22015-05-29 13:37:40 -0500223 if [[ updated != true ]]; then
Ashlesh Gawande52e47e12016-08-09 16:30:42 -0500224 if [ ! -d "build" ]; then
225 $update
226 updated="true"
227 fi
ashu2ad32e22015-05-29 13:37:40 -0500228 fi
229
230 if [[ $pysetup != true ]]; then
231 $install python-setuptools
232 pysetup="true"
233 fi
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500234 install_dir="/usr/local/etc/mini-ndn/"
235
236 sudo mkdir -p "$install_dir"
Ashlesh Gawande532302b2018-02-15 18:58:20 -0600237 sudo cp topologies/default-topology.conf "$install_dir"
238 sudo cp topologies/minindn.caida.conf "$install_dir"
239 sudo cp topologies/minindn.ucla.conf "$install_dir"
240 sudo cp topologies/minindn.testbed.conf "$install_dir"
Ashlesh Gawande27b5e1b2018-08-06 17:47:15 -0500241 sudo cp topologies/current-testbed.conf "$install_dir"
Saurab Dulal082e4442020-03-02 15:49:03 -0600242 sudo cp topologies/geo_hyperbolic_test.conf "$install_dir"
phmoll1f1de1f2020-02-27 14:32:35 +0100243 sudo cp topologies/geant.conf "$install_dir"
Alexander Laneea2d5d62019-10-04 16:48:52 -0500244 sudo cp topologies/wifi/singleap-topology.conf "$install_dir"
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500245 sudo python setup.py develop
ashu2ad32e22015-05-29 13:37:40 -0500246}
247
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800248function ndn_cpp {
249 if [[ updated != true ]]; then
250 $update
251 updated="true"
252 fi
253
254 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
255 $install git build-essential libssl-dev libsqlite3-dev libboost-all-dev libprotobuf-dev protobuf-compiler
256 fi
257
258 if [[ $DIST == Fedora ]]; then
259 printf '\nNDN-CPP does not support Fedora yet.\n'
260 return
261 fi
262
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500263 git clone --depth 1 $NDN_GITHUB/ndn-cpp $NDN_SRC/ndn-cpp
264 pushd $NDN_SRC/ndn-cpp
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800265 ./configure
266 proc=$(nproc)
267 make -j$proc
268 sudo make install
269 sudo ldconfig
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500270 popd
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800271}
272
273function pyNDN {
274 if [[ updated != true ]]; then
275 $update
276 updated="true"
277 fi
278
279 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
280 $install git build-essential libssl-dev libffi-dev python-dev python-pip
281 fi
282
283 if [[ $DIST == Fedora ]]; then
284 printf '\nPyNDN does not support Fedora yet.\n'
285 return
286 fi
287
288 sudo pip install cryptography trollius protobuf pytest mock
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500289 git clone --depth 1 $NDN_GITHUB/PyNDN2 $NDN_SRC/PyNDN2
290 pushd $NDN_SRC/PyNDN2
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800291 # Update the user's PYTHONPATH.
292 echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" >> ~/.bashrc
293 # Also update root's PYTHONPATH in case of running under sudo.
294 echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" | sudo tee -a /root/.bashrc > /dev/null
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500295 popd
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800296}
297
298function ndn_js {
299 if [[ updated != true ]]; then
300 $update
301 updated="true"
302 fi
303
304 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
305 $install git nodejs npm
306 fi
307
308 if [[ $DIST == Fedora ]]; then
309 printf '\nNDN-JS does not support Fedora yet.\n'
310 return
311 fi
312
313 sudo ln -fs /usr/bin/nodejs /usr/bin/node
314 sudo npm install -g mocha
315 sudo npm install rsa-keygen sqlite3
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500316 git clone --depth 1 $NDN_GITHUB/ndn-js $NDN_SRC/ndn-js
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800317}
318
319function jNDN {
320 if [[ updated != true ]]; then
321 $update
322 updated="true"
323 fi
324
325 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
326 $install git openjdk-8-jdk maven
327 fi
328
329 if [[ $DIST == Fedora ]]; then
330 printf '\nNDN-JS does not support Fedora yet.\n'
331 return
332 fi
333
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500334 git clone --depth 1 $NDN_GITHUB/jndn $NDN_SRC/jndn
335 pushd $NDN_SRC/jndn
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800336 mvn install
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500337 popd
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600338}
339
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800340function commonClientLibraries {
341 ndn_cpp
342 pyNDN
343 ndn_js
344 jNDN
345}
346
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500347function buildDocumentation {
348 sphinxInstalled=$(pip show sphinx | wc -l)
349 sphinxRtdInstalled=$(pip show sphinx_rtd_theme | wc -l)
350 if [[ $sphinxInstalled -eq "0" ]]; then
351 pip install sphinx
352 fi
353
354 if [[ $sphinxRtdInstalled -eq "0" ]]; then
355 pip install sphinx_rtd_theme
356 fi
357 cd docs
358 make clean
359 make html
360}
361
ashu2ad32e22015-05-29 13:37:40 -0500362function usage {
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000363 printf '\nUsage: %s [-a]\n\n' $(basename $0) >&2
ashu2ad32e22015-05-29 13:37:40 -0500364
365 printf 'options:\n' >&2
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000366 printf -- ' -a: install all the required dependencies\n' >&2
Alexander Laneea2d5d62019-10-04 16:48:52 -0500367 printf -- ' -A: install all the required dependencies (wired only)\n' >&2
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500368 printf -- ' -c: install Common Client Libraries\n' >&2
369 printf -- ' -d: build documentation\n' >&2
370 printf -- ' -h: print this (H)elp message\n' >&2
ashu2ad32e22015-05-29 13:37:40 -0500371 printf -- ' -i: install mini-ndn\n' >&2
Alexander Laneea2d5d62019-10-04 16:48:52 -0500372 printf -- ' -m: install mininet and dependencies (for wired-only installation)\n' >&2
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500373 printf -- ' -n: install NDN dependencies of mini-ndn including infoedit\n' >&2
374 printf -- ' -p: patch ndn-cxx with dummy key chain\n' >&2
Giovanni Griecobb31ed22020-03-23 10:04:59 +0100375 printf -- ' -q: quiet install (must be specified first)\n' >&2
Alexander Laneea2d5d62019-10-04 16:48:52 -0500376 printf -- ' -w: install mininet-wifi and dependencies\n' >&2
ashu2ad32e22015-05-29 13:37:40 -0500377 exit 2
378}
379
380if [[ $# -eq 0 ]]; then
381 usage
382else
Alexander Laneea2d5d62019-10-04 16:48:52 -0500383 while getopts 'aAcdhimnpqw' OPTION
ashu2ad32e22015-05-29 13:37:40 -0500384 do
385 case $OPTION in
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000386 a)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500387 ndn
Alexander Laneea2d5d62019-10-04 16:48:52 -0500388 wifi
389 minindn
390 commonClientLibraries
391 break
392 ;;
393 A)
394 ndn
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000395 mininet
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500396 minindn
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800397 commonClientLibraries
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000398 break
399 ;;
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500400 c) commonClientLibraries;;
401 d) buildDocumentation;;
402 h) usage;;
ashu2ad32e22015-05-29 13:37:40 -0500403 i) minindn;;
404 m) mininet;;
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500405 n) ndn;;
406 p) patchDummy;;
Giovanni Griecobb31ed22020-03-23 10:04:59 +0100407 q) quiet_install;;
Alexander Laneea2d5d62019-10-04 16:48:52 -0500408 w) wifi ;;
ashu2ad32e22015-05-29 13:37:40 -0500409 ?) usage;;
410 esac
411 done
412 shift $(($OPTIND - 1))
Ashlesh Gawande670ff152018-06-08 12:26:39 -0500413fi