blob: 87dc96eb0c1153ec8fd41c4dd23b690440292e26 [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 Gawande0cccdb82016-08-15 12:58:06 -05004# Copyright (C) 2015-2016, The University of Memphis,
5# 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#
28# Mininet 2.2.1 License
29#
30# Copyright (c) 2013-2015 Open Networking Laboratory
31# 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
102 git clone --depth 1 https://github.com/named-data/NFD
103 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
116 if [[ $DIST == Ubuntu ]]; then
117 $install liblog4cxx10-dev libprotobuf-dev protobuf-compiler
118 fi
119
120 if [[ $DIST == Fedora ]]; then
121 $install log4cxx log4cxx-devel openssl-devel protobuf-devel
122 fi
123
124 git clone --depth 1 https://github.com/named-data/NLSR
125 cd NLSR
126 ./waf configure
127 ./waf
128 sudo ./waf install
129 cd ../
130}
131
132function ndncxx {
133 if [[ updated != true ]]; then
134 $update
135 updated="true"
136 fi
137
138 if [[ $DIST == Ubuntu || $DIST == Debian ]]; then
139 $install git libsqlite3-dev libboost-all-dev make g++
140 crypto
141 fi
142
143 if [[ $DIST == Fedora ]]; then
144 $install gcc-c++ sqlite-devel boost-devel
145 fi
146
147 git clone --depth 1 https://github.com/named-data/ndn-cxx
148 cd ndn-cxx
149 ./waf configure
150 ./waf
151 sudo ./waf install
Vince Lehman68b08152015-10-23 10:15:36 -0500152 sudo ldconfig
ashu2ad32e22015-05-29 13:37:40 -0500153 cd ../
154}
155
156function crypto {
157 mkdir crypto
158 cd crypto
159 $install unzip
160 wget http://www.cryptopp.com/cryptopp562.zip
161 unzip cryptopp562.zip
Vince Lehman68b08152015-10-23 10:15:36 -0500162
163 # Uncomments flags to build shared object
164 sed -i '/^# CXXFLAGS += -fPIC/s/^# //' GNUmakefile
165
166 make static dynamic
ashu2ad32e22015-05-29 13:37:40 -0500167 sudo make install
168 cd ../
169}
170
171function tools {
172 if [[ $cxx != true ]]; then
173 ndncxx
174 cxx="true"
175 fi
176
177 git clone --depth 1 https://github.com/named-data/ndn-tools
178 cd ndn-tools
179 ./waf configure
180 ./waf
181 sudo ./waf install
182 cd ../
183}
184
185function mininet {
186 if [[ updated != true ]]; then
187 $update
188 updated="true"
189 fi
190
191 if [[ $pysetup != true ]]; then
192 pysetup="true"
193 fi
194
195 git clone --depth 1 https://github.com/mininet/mininet
196 cd mininet
197 sudo ./util/install.sh -fnv
198 cd ../
199}
200
201function minindn {
202 if [[ updated != true ]]; then
Ashlesh Gawande52e47e12016-08-09 16:30:42 -0500203 if [ ! -d "build" ]; then
204 $update
205 updated="true"
206 fi
ashu2ad32e22015-05-29 13:37:40 -0500207 fi
208
209 if [[ $pysetup != true ]]; then
210 $install python-setuptools
211 pysetup="true"
212 fi
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500213 install_dir="/usr/local/etc/mini-ndn/"
214
215 sudo mkdir -p "$install_dir"
216 sudo cp ndn_utils/client.conf.sample "$install_dir"
Ashlesh Gawande20f70762015-06-17 15:18:19 -0500217 sudo cp ndn_utils/nlsr.conf "$install_dir"
218 sudo cp ndn_utils/topologies/default-topology.conf "$install_dir"
219 sudo cp ndn_utils/topologies/minindn.testbed.conf "$install_dir"
ashu2ad32e22015-05-29 13:37:40 -0500220 sudo python setup.py install
221}
222
223
224function usage {
225 printf '\nUsage: %s [-mfrti]\n\n' $(basename $0) >&2
226
227 printf 'options:\n' >&2
228 printf -- ' -f: install NFD\n' >&2
229 printf -- ' -i: install mini-ndn\n' >&2
230 printf -- ' -m: install mininet and dependencies\n' >&2
231 printf -- ' -r: install NLSR\n' >&2
232 printf -- ' -t: install tools\n' >&2
233 exit 2
234}
235
236if [[ $# -eq 0 ]]; then
237 usage
238else
239 while getopts 'mfrti' OPTION
240 do
241 case $OPTION in
242 f) forwarder;;
243 i) minindn;;
244 m) mininet;;
245 r) routing;;
246 t) tools;;
247 ?) usage;;
248 esac
249 done
250 shift $(($OPTIND - 1))
251fi