blob: c5fe190310175a5055726ba38397dc4ff0245cc4 [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#
Jeff Thompson55d2bf42017-12-22 09:14:03 -08004# Copyright (C) 2015-2018, 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
88function forwarder {
89 if [[ $cxx != true ]]; then
90 ndncxx
91 cxx="true"
92 fi
93
94 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
95 $install libpcap-dev pkg-config
96 fi
97
98 if [[ $DIST == Fedora ]]; then
99 $install libpcap-devel
100 fi
101
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500102 git clone --depth 1 https://github.com/named-data/NFD
ashu2ad32e22015-05-29 13:37:40 -0500103 cd NFD
104 ./waf configure --without-websocket
105 ./waf
106 sudo ./waf install
107 cd ../
108}
109
110function routing {
111 if [[ $cxx != true ]]; then
112 ndncxx
113 cxx="true"
114 fi
115
Ashlesh Gawande2b7acee2018-12-14 15:15:44 -0600116 git clone --depth 1 https://github.com/named-data/PSync
117 cd PSync
118 ./waf configure
119 ./waf
120 sudo ./waf install
121 sudo ldconfig
122 cd ../
123
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500124 git clone --depth 1 https://github.com/named-data/ChronoSync
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500125 cd ChronoSync
126 ./waf configure
127 ./waf
128 sudo ./waf install
dmcoomes9850d652017-09-28 16:43:23 -0500129 sudo ldconfig
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500130 cd ../
131
ashu2ad32e22015-05-29 13:37:40 -0500132 git clone --depth 1 https://github.com/named-data/NLSR
133 cd NLSR
134 ./waf configure
135 ./waf
136 sudo ./waf install
137 cd ../
138}
139
140function ndncxx {
141 if [[ updated != true ]]; then
142 $update
143 updated="true"
144 fi
145
146 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500147 $install git libsqlite3-dev libboost-all-dev make g++ libssl-dev
ashu2ad32e22015-05-29 13:37:40 -0500148 fi
149
150 if [[ $DIST == Fedora ]]; then
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500151 $install gcc-c++ sqlite-devel boost-devel openssl-devel
ashu2ad32e22015-05-29 13:37:40 -0500152 fi
153
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500154 git clone --depth 1 https://github.com/named-data/ndn-cxx
ashu2ad32e22015-05-29 13:37:40 -0500155 cd ndn-cxx
156 ./waf configure
157 ./waf
158 sudo ./waf install
Vince Lehman68b08152015-10-23 10:15:36 -0500159 sudo ldconfig
ashu2ad32e22015-05-29 13:37:40 -0500160 cd ../
161}
162
ashu2ad32e22015-05-29 13:37:40 -0500163function tools {
164 if [[ $cxx != true ]]; then
165 ndncxx
166 cxx="true"
167 fi
168
169 git clone --depth 1 https://github.com/named-data/ndn-tools
170 cd ndn-tools
Ashlesh Gawandea80484e2017-10-17 15:52:23 -0500171 ./waf configure
ashu2ad32e22015-05-29 13:37:40 -0500172 ./waf
173 sudo ./waf install
174 cd ../
175}
176
177function mininet {
178 if [[ updated != true ]]; then
179 $update
180 updated="true"
181 fi
182
183 if [[ $pysetup != true ]]; then
184 pysetup="true"
185 fi
186
187 git clone --depth 1 https://github.com/mininet/mininet
188 cd mininet
189 sudo ./util/install.sh -fnv
190 cd ../
191}
192
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000193function infoedit {
194 git clone --depth 1 https://github.com/NDN-Routing/infoedit.git
195 cd infoedit
196 sudo make install
197 cd ../
198}
199
ashu2ad32e22015-05-29 13:37:40 -0500200function minindn {
Philipp Moll61a2be82019-07-12 08:33:09 +0200201 $install libigraph0-dev
202 sudo pip install -r requirements.txt
203
ashu2ad32e22015-05-29 13:37:40 -0500204 if [[ updated != true ]]; then
Ashlesh Gawande52e47e12016-08-09 16:30:42 -0500205 if [ ! -d "build" ]; then
206 $update
207 updated="true"
208 fi
ashu2ad32e22015-05-29 13:37:40 -0500209 fi
210
211 if [[ $pysetup != true ]]; then
212 $install python-setuptools
213 pysetup="true"
214 fi
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500215 install_dir="/usr/local/etc/mini-ndn/"
216
217 sudo mkdir -p "$install_dir"
Ashlesh Gawande532302b2018-02-15 18:58:20 -0600218 sudo cp topologies/default-topology.conf "$install_dir"
219 sudo cp topologies/minindn.caida.conf "$install_dir"
220 sudo cp topologies/minindn.ucla.conf "$install_dir"
221 sudo cp topologies/minindn.testbed.conf "$install_dir"
Ashlesh Gawande27b5e1b2018-08-06 17:47:15 -0500222 sudo cp topologies/current-testbed.conf "$install_dir"
Ashlesh Gawande95789cc2017-02-27 12:38:04 -0600223 sudo python setup.py clean --all install
ashu2ad32e22015-05-29 13:37:40 -0500224}
225
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800226function ndn_cpp {
227 if [[ updated != true ]]; then
228 $update
229 updated="true"
230 fi
231
232 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
233 $install git build-essential libssl-dev libsqlite3-dev libboost-all-dev libprotobuf-dev protobuf-compiler
234 fi
235
236 if [[ $DIST == Fedora ]]; then
237 printf '\nNDN-CPP does not support Fedora yet.\n'
238 return
239 fi
240
241 git clone --depth 1 https://github.com/named-data/ndn-cpp
242 cd ndn-cpp
243 ./configure
244 proc=$(nproc)
245 make -j$proc
246 sudo make install
247 sudo ldconfig
248 cd ..
249}
250
251function pyNDN {
252 if [[ updated != true ]]; then
253 $update
254 updated="true"
255 fi
256
257 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
258 $install git build-essential libssl-dev libffi-dev python-dev python-pip
259 fi
260
261 if [[ $DIST == Fedora ]]; then
262 printf '\nPyNDN does not support Fedora yet.\n'
263 return
264 fi
265
266 sudo pip install cryptography trollius protobuf pytest mock
267 git clone --depth 1 https://github.com/named-data/PyNDN2
268 cd PyNDN2
269 # Update the user's PYTHONPATH.
270 echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" >> ~/.bashrc
271 # Also update root's PYTHONPATH in case of running under sudo.
272 echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" | sudo tee -a /root/.bashrc > /dev/null
273 cd ..
274}
275
276function ndn_js {
277 if [[ updated != true ]]; then
278 $update
279 updated="true"
280 fi
281
282 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
283 $install git nodejs npm
284 fi
285
286 if [[ $DIST == Fedora ]]; then
287 printf '\nNDN-JS does not support Fedora yet.\n'
288 return
289 fi
290
291 sudo ln -fs /usr/bin/nodejs /usr/bin/node
292 sudo npm install -g mocha
293 sudo npm install rsa-keygen sqlite3
294 git clone --depth 1 https://github.com/named-data/ndn-js
295}
296
297function jNDN {
298 if [[ updated != true ]]; then
299 $update
300 updated="true"
301 fi
302
303 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
304 $install git openjdk-8-jdk maven
305 fi
306
307 if [[ $DIST == Fedora ]]; then
308 printf '\nNDN-JS does not support Fedora yet.\n'
309 return
310 fi
311
312 git clone --depth 1 https://github.com/named-data/jndn
313 cd jndn
314 mvn install
315 cd ..
316}
317
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600318function argcomplete {
319 if [[ $SHELL == "/bin/bash" ]]; then
Ashlesh Gawande670ff152018-06-08 12:26:39 -0500320 $install bash-completion
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600321 $install python-argcomplete
322 if ! grep -q 'eval "$(register-python-argcomplete minindn)"' ~/.bashrc; then
323 echo 'eval "$(register-python-argcomplete minindn)"' >> ~/.bashrc
324 fi
325 source ~/.bashrc
326 elif [[ $SHELL == "/bin/zsh" ]] || [[ $SHELL == "/usr/bin/zsh" ]]; then
Ashlesh Gawande670ff152018-06-08 12:26:39 -0500327 $install bash-completion
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600328 $install python-argcomplete
329 if ! grep -z -q 'autoload bashcompinit\sbashcompinit\seval "$(register-python-argcomplete minindn)"' ~/.zshrc; then
330 echo -e 'autoload bashcompinit\nbashcompinit\neval "$(register-python-argcomplete minindn)"' >> ~/.zshrc
331 fi
332 source ~/.zshrc
333 else
334 echo "Skipping argomplete install..."
335 fi
336}
337
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800338function commonClientLibraries {
339 ndn_cpp
340 pyNDN
341 ndn_js
342 jNDN
343}
344
ashu2ad32e22015-05-29 13:37:40 -0500345function usage {
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000346 printf '\nUsage: %s [-a]\n\n' $(basename $0) >&2
ashu2ad32e22015-05-29 13:37:40 -0500347
348 printf 'options:\n' >&2
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000349 printf -- ' -a: install all the required dependencies\n' >&2
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600350 printf -- ' -b: install autocomplete for Bash and Zsh users\n' >&2
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000351 printf -- ' -e: install infoedit\n' >&2
ashu2ad32e22015-05-29 13:37:40 -0500352 printf -- ' -f: install NFD\n' >&2
353 printf -- ' -i: install mini-ndn\n' >&2
354 printf -- ' -m: install mininet and dependencies\n' >&2
355 printf -- ' -r: install NLSR\n' >&2
356 printf -- ' -t: install tools\n' >&2
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800357 printf -- ' -c: install Common Client Libraries\n' >&2
ashu2ad32e22015-05-29 13:37:40 -0500358 exit 2
359}
360
361if [[ $# -eq 0 ]]; then
362 usage
363else
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600364 while getopts 'abemfrtic' OPTION
ashu2ad32e22015-05-29 13:37:40 -0500365 do
366 case $OPTION in
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000367 a)
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000368 forwarder
369 minindn
370 mininet
371 routing
372 tools
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800373 infoedit
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600374 argcomplete
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800375 commonClientLibraries
Saurab Dulal7b3655a2018-01-02 22:40:35 +0000376 break
377 ;;
Ashlesh Gawande212cb822017-02-07 10:42:13 -0600378 b) argcomplete;;
Saurab Dulal5d9ba602017-11-29 21:31:13 +0000379 e) infoedit;;
ashu2ad32e22015-05-29 13:37:40 -0500380 f) forwarder;;
381 i) minindn;;
382 m) mininet;;
383 r) routing;;
384 t) tools;;
Jeff Thompson55d2bf42017-12-22 09:14:03 -0800385 c) commonClientLibraries;;
ashu2ad32e22015-05-29 13:37:40 -0500386 ?) usage;;
387 esac
388 done
389 shift $(($OPTIND - 1))
Ashlesh Gawande670ff152018-06-08 12:26:39 -0500390fi