blob: c4f6f24f05cc00d84e7e672b7ef8c03e18c77077 [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#
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -05004# Copyright (C) 2015-2017, 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 Gawandeec084832017-06-23 17:47:25 -0500102 git clone https://github.com/named-data/NFD
ashu2ad32e22015-05-29 13:37:40 -0500103 cd NFD
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500104 current=$(git rev-parse HEAD)
105 if [[ $current != "f4056d0242536f85b7d7b4de1b5ac50dad65c233" ]]; then
106 git checkout f4056d0242536f85b7d7b4de1b5ac50dad65c233
107 git checkout -b fix-commit
108 fi
ashu2ad32e22015-05-29 13:37:40 -0500109 ./waf configure --without-websocket
110 ./waf
111 sudo ./waf install
112 cd ../
113}
114
115function routing {
116 if [[ $cxx != true ]]; then
117 ndncxx
118 cxx="true"
119 fi
120
121 if [[ $DIST == Ubuntu ]]; then
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500122 $install liblog4cxx10-dev
ashu2ad32e22015-05-29 13:37:40 -0500123 fi
124
125 if [[ $DIST == Fedora ]]; then
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500126 $install log4cxx log4cxx-devel openssl-devel
ashu2ad32e22015-05-29 13:37:40 -0500127 fi
128
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500129 git clone --depth 1 https://github.com/named-data/ChronoSync
130 cd ChronoSync
131 ./waf configure
132 ./waf
133 sudo ./waf install
134 cd ../
135
ashu2ad32e22015-05-29 13:37:40 -0500136 git clone --depth 1 https://github.com/named-data/NLSR
137 cd NLSR
138 ./waf configure
139 ./waf
140 sudo ./waf install
141 cd ../
142}
143
144function ndncxx {
145 if [[ updated != true ]]; then
146 $update
147 updated="true"
148 fi
149
150 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
Ashlesh Gawande95789cc2017-02-27 12:38:04 -0600151 $install git libsqlite3-dev libboost-all-dev make g++ libssl-dev libcrypto++-dev
ashu2ad32e22015-05-29 13:37:40 -0500152 fi
153
154 if [[ $DIST == Fedora ]]; then
Ashlesh Gawande95789cc2017-02-27 12:38:04 -0600155 $install gcc-c++ sqlite-devel boost-devel openssl-devel cryptopp-devel
ashu2ad32e22015-05-29 13:37:40 -0500156 fi
157
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500158 git clone https://github.com/named-data/ndn-cxx
ashu2ad32e22015-05-29 13:37:40 -0500159 cd ndn-cxx
Ashlesh Gawandeec084832017-06-23 17:47:25 -0500160 current=$(git rev-parse HEAD)
161 if [[ $current != "b555b00c280b9c9ed46f24a1fbebc73b720601af" ]]; then
162 git checkout b555b00c280b9c9ed46f24a1fbebc73b720601af
163 git checkout -b fix-commit
164 fi
ashu2ad32e22015-05-29 13:37:40 -0500165 ./waf configure
166 ./waf
167 sudo ./waf install
Vince Lehman68b08152015-10-23 10:15:36 -0500168 sudo ldconfig
ashu2ad32e22015-05-29 13:37:40 -0500169 cd ../
170}
171
ashu2ad32e22015-05-29 13:37:40 -0500172function tools {
173 if [[ $cxx != true ]]; then
174 ndncxx
175 cxx="true"
176 fi
177
178 git clone --depth 1 https://github.com/named-data/ndn-tools
179 cd ndn-tools
180 ./waf configure
181 ./waf
182 sudo ./waf install
183 cd ../
184}
185
186function mininet {
187 if [[ updated != true ]]; then
188 $update
189 updated="true"
190 fi
191
192 if [[ $pysetup != true ]]; then
193 pysetup="true"
194 fi
195
196 git clone --depth 1 https://github.com/mininet/mininet
197 cd mininet
198 sudo ./util/install.sh -fnv
199 cd ../
200}
201
202function minindn {
203 if [[ updated != true ]]; then
Ashlesh Gawande52e47e12016-08-09 16:30:42 -0500204 if [ ! -d "build" ]; then
205 $update
206 updated="true"
207 fi
ashu2ad32e22015-05-29 13:37:40 -0500208 fi
209
210 if [[ $pysetup != true ]]; then
211 $install python-setuptools
212 pysetup="true"
213 fi
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500214 install_dir="/usr/local/etc/mini-ndn/"
215
216 sudo mkdir -p "$install_dir"
217 sudo cp ndn_utils/client.conf.sample "$install_dir"
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500218 sudo cp ndn_utils/topologies/default-topology.conf "$install_dir"
Ashlesh Gawande5f470202017-02-25 12:02:53 -0600219 sudo cp ndn_utils/topologies/minindn.caida.conf "$install_dir"
220 sudo cp ndn_utils/topologies/minindn.ucla.conf "$install_dir"
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500221 sudo cp ndn_utils/topologies/minindn.testbed.conf "$install_dir"
Ashlesh Gawande95789cc2017-02-27 12:38:04 -0600222 sudo python setup.py clean --all install
ashu2ad32e22015-05-29 13:37:40 -0500223}
224
225
226function usage {
227 printf '\nUsage: %s [-mfrti]\n\n' $(basename $0) >&2
228
229 printf 'options:\n' >&2
230 printf -- ' -f: install NFD\n' >&2
231 printf -- ' -i: install mini-ndn\n' >&2
232 printf -- ' -m: install mininet and dependencies\n' >&2
233 printf -- ' -r: install NLSR\n' >&2
234 printf -- ' -t: install tools\n' >&2
235 exit 2
236}
237
238if [[ $# -eq 0 ]]; then
239 usage
240else
241 while getopts 'mfrti' OPTION
242 do
243 case $OPTION in
244 f) forwarder;;
245 i) minindn;;
246 m) mininet;;
247 r) routing;;
248 t) tools;;
249 ?) usage;;
250 esac
251 done
252 shift $(($OPTIND - 1))
253fi