ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Vince Lehman | b8b1806 | 2015-07-14 13:07:22 -0500 | [diff] [blame] | 2 | # -*- Mode:bash; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 3 | # |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 4 | # Copyright (C) 2015-2018, The University of Memphis, |
Ashlesh Gawande | 0cccdb8 | 2016-08-15 12:58:06 -0500 | [diff] [blame] | 5 | # Arizona Board of Regents, |
| 6 | # Regents of the University of California. |
Vince Lehman | b8b1806 | 2015-07-14 13:07:22 -0500 | [diff] [blame] | 7 | # |
| 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 Gawande | f5f304b | 2016-06-16 16:42:41 -0500 | [diff] [blame] | 28 | # Mininet 2.3.0d1 License |
Vince Lehman | b8b1806 | 2015-07-14 13:07:22 -0500 | [diff] [blame] | 29 | # |
Ashlesh Gawande | f5f304b | 2016-06-16 16:42:41 -0500 | [diff] [blame] | 30 | # Copyright (c) 2013-2016 Open Networking Laboratory |
Vince Lehman | b8b1806 | 2015-07-14 13:07:22 -0500 | [diff] [blame] | 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. |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 61 | |
| 62 | test -e /etc/debian_version && DIST="Debian" |
| 63 | grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu" |
| 64 | |
| 65 | if [[ $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 |
| 74 | fi |
| 75 | |
| 76 | test -e /etc/fedora-release && DIST="Fedora" |
| 77 | if [[ $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 |
| 86 | fi |
| 87 | |
| 88 | function 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 Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 102 | git clone --depth 1 https://github.com/named-data/NFD |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 103 | cd NFD |
| 104 | ./waf configure --without-websocket |
| 105 | ./waf |
| 106 | sudo ./waf install |
| 107 | cd ../ |
| 108 | } |
| 109 | |
| 110 | function routing { |
| 111 | if [[ $cxx != true ]]; then |
| 112 | ndncxx |
| 113 | cxx="true" |
| 114 | fi |
| 115 | |
Ashlesh Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 116 | git clone --depth 1 https://github.com/named-data/ChronoSync |
Ashlesh Gawande | ec08483 | 2017-06-23 17:47:25 -0500 | [diff] [blame] | 117 | cd ChronoSync |
| 118 | ./waf configure |
| 119 | ./waf |
| 120 | sudo ./waf install |
dmcoomes | 9850d65 | 2017-09-28 16:43:23 -0500 | [diff] [blame] | 121 | sudo ldconfig |
Ashlesh Gawande | ec08483 | 2017-06-23 17:47:25 -0500 | [diff] [blame] | 122 | cd ../ |
| 123 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 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 | |
| 132 | function ndncxx { |
| 133 | if [[ updated != true ]]; then |
| 134 | $update |
| 135 | updated="true" |
| 136 | fi |
| 137 | |
| 138 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
Ashlesh Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 139 | $install git libsqlite3-dev libboost-all-dev make g++ libssl-dev |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 140 | fi |
| 141 | |
| 142 | if [[ $DIST == Fedora ]]; then |
Ashlesh Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 143 | $install gcc-c++ sqlite-devel boost-devel openssl-devel |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 144 | fi |
| 145 | |
Ashlesh Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 146 | git clone --depth 1 https://github.com/named-data/ndn-cxx |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 147 | cd ndn-cxx |
| 148 | ./waf configure |
| 149 | ./waf |
| 150 | sudo ./waf install |
Vince Lehman | 68b0815 | 2015-10-23 10:15:36 -0500 | [diff] [blame] | 151 | sudo ldconfig |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 152 | cd ../ |
| 153 | } |
| 154 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 155 | function tools { |
| 156 | if [[ $cxx != true ]]; then |
| 157 | ndncxx |
| 158 | cxx="true" |
| 159 | fi |
| 160 | |
| 161 | git clone --depth 1 https://github.com/named-data/ndn-tools |
| 162 | cd ndn-tools |
Ashlesh Gawande | a80484e | 2017-10-17 15:52:23 -0500 | [diff] [blame] | 163 | ./waf configure |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 164 | ./waf |
| 165 | sudo ./waf install |
| 166 | cd ../ |
| 167 | } |
| 168 | |
| 169 | function mininet { |
| 170 | if [[ updated != true ]]; then |
| 171 | $update |
| 172 | updated="true" |
| 173 | fi |
| 174 | |
| 175 | if [[ $pysetup != true ]]; then |
| 176 | pysetup="true" |
| 177 | fi |
| 178 | |
| 179 | git clone --depth 1 https://github.com/mininet/mininet |
| 180 | cd mininet |
| 181 | sudo ./util/install.sh -fnv |
| 182 | cd ../ |
| 183 | } |
| 184 | |
Saurab Dulal | 5d9ba60 | 2017-11-29 21:31:13 +0000 | [diff] [blame] | 185 | function infoedit { |
| 186 | git clone --depth 1 https://github.com/NDN-Routing/infoedit.git |
| 187 | cd infoedit |
| 188 | sudo make install |
| 189 | cd ../ |
| 190 | } |
| 191 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 192 | function minindn { |
| 193 | if [[ updated != true ]]; then |
Ashlesh Gawande | 52e47e1 | 2016-08-09 16:30:42 -0500 | [diff] [blame] | 194 | if [ ! -d "build" ]; then |
| 195 | $update |
| 196 | updated="true" |
| 197 | fi |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 198 | fi |
| 199 | |
| 200 | if [[ $pysetup != true ]]; then |
| 201 | $install python-setuptools |
| 202 | pysetup="true" |
| 203 | fi |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 204 | install_dir="/usr/local/etc/mini-ndn/" |
| 205 | |
| 206 | sudo mkdir -p "$install_dir" |
Ashlesh Gawande | 532302b | 2018-02-15 18:58:20 -0600 | [diff] [blame] | 207 | sudo cp topologies/default-topology.conf "$install_dir" |
| 208 | sudo cp topologies/minindn.caida.conf "$install_dir" |
| 209 | sudo cp topologies/minindn.ucla.conf "$install_dir" |
| 210 | sudo cp topologies/minindn.testbed.conf "$install_dir" |
Ashlesh Gawande | 95789cc | 2017-02-27 12:38:04 -0600 | [diff] [blame] | 211 | sudo python setup.py clean --all install |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 212 | } |
| 213 | |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 214 | function ndn_cpp { |
| 215 | if [[ updated != true ]]; then |
| 216 | $update |
| 217 | updated="true" |
| 218 | fi |
| 219 | |
| 220 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 221 | $install git build-essential libssl-dev libsqlite3-dev libboost-all-dev libprotobuf-dev protobuf-compiler |
| 222 | fi |
| 223 | |
| 224 | if [[ $DIST == Fedora ]]; then |
| 225 | printf '\nNDN-CPP does not support Fedora yet.\n' |
| 226 | return |
| 227 | fi |
| 228 | |
| 229 | git clone --depth 1 https://github.com/named-data/ndn-cpp |
| 230 | cd ndn-cpp |
| 231 | ./configure |
| 232 | proc=$(nproc) |
| 233 | make -j$proc |
| 234 | sudo make install |
| 235 | sudo ldconfig |
| 236 | cd .. |
| 237 | } |
| 238 | |
| 239 | function pyNDN { |
| 240 | if [[ updated != true ]]; then |
| 241 | $update |
| 242 | updated="true" |
| 243 | fi |
| 244 | |
| 245 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 246 | $install git build-essential libssl-dev libffi-dev python-dev python-pip |
| 247 | fi |
| 248 | |
| 249 | if [[ $DIST == Fedora ]]; then |
| 250 | printf '\nPyNDN does not support Fedora yet.\n' |
| 251 | return |
| 252 | fi |
| 253 | |
| 254 | sudo pip install cryptography trollius protobuf pytest mock |
| 255 | git clone --depth 1 https://github.com/named-data/PyNDN2 |
| 256 | cd PyNDN2 |
| 257 | # Update the user's PYTHONPATH. |
| 258 | echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" >> ~/.bashrc |
| 259 | # Also update root's PYTHONPATH in case of running under sudo. |
| 260 | echo "export PYTHONPATH=\$PYTHONPATH:`pwd`/python" | sudo tee -a /root/.bashrc > /dev/null |
| 261 | cd .. |
| 262 | } |
| 263 | |
| 264 | function ndn_js { |
| 265 | if [[ updated != true ]]; then |
| 266 | $update |
| 267 | updated="true" |
| 268 | fi |
| 269 | |
| 270 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 271 | $install git nodejs npm |
| 272 | fi |
| 273 | |
| 274 | if [[ $DIST == Fedora ]]; then |
| 275 | printf '\nNDN-JS does not support Fedora yet.\n' |
| 276 | return |
| 277 | fi |
| 278 | |
| 279 | sudo ln -fs /usr/bin/nodejs /usr/bin/node |
| 280 | sudo npm install -g mocha |
| 281 | sudo npm install rsa-keygen sqlite3 |
| 282 | git clone --depth 1 https://github.com/named-data/ndn-js |
| 283 | } |
| 284 | |
| 285 | function jNDN { |
| 286 | if [[ updated != true ]]; then |
| 287 | $update |
| 288 | updated="true" |
| 289 | fi |
| 290 | |
| 291 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 292 | $install git openjdk-8-jdk maven |
| 293 | fi |
| 294 | |
| 295 | if [[ $DIST == Fedora ]]; then |
| 296 | printf '\nNDN-JS does not support Fedora yet.\n' |
| 297 | return |
| 298 | fi |
| 299 | |
| 300 | git clone --depth 1 https://github.com/named-data/jndn |
| 301 | cd jndn |
| 302 | mvn install |
| 303 | cd .. |
| 304 | } |
| 305 | |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 306 | function argcomplete { |
| 307 | if [[ $SHELL == "/bin/bash" ]]; then |
| 308 | $install python-argcomplete |
| 309 | if ! grep -q 'eval "$(register-python-argcomplete minindn)"' ~/.bashrc; then |
| 310 | echo 'eval "$(register-python-argcomplete minindn)"' >> ~/.bashrc |
| 311 | fi |
| 312 | source ~/.bashrc |
| 313 | elif [[ $SHELL == "/bin/zsh" ]] || [[ $SHELL == "/usr/bin/zsh" ]]; then |
| 314 | $install python-argcomplete |
| 315 | if ! grep -z -q 'autoload bashcompinit\sbashcompinit\seval "$(register-python-argcomplete minindn)"' ~/.zshrc; then |
| 316 | echo -e 'autoload bashcompinit\nbashcompinit\neval "$(register-python-argcomplete minindn)"' >> ~/.zshrc |
| 317 | fi |
| 318 | source ~/.zshrc |
| 319 | else |
| 320 | echo "Skipping argomplete install..." |
| 321 | fi |
| 322 | } |
| 323 | |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 324 | function commonClientLibraries { |
| 325 | ndn_cpp |
| 326 | pyNDN |
| 327 | ndn_js |
| 328 | jNDN |
| 329 | } |
| 330 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 331 | function usage { |
Saurab Dulal | 7b3655a | 2018-01-02 22:40:35 +0000 | [diff] [blame] | 332 | printf '\nUsage: %s [-a]\n\n' $(basename $0) >&2 |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 333 | |
| 334 | printf 'options:\n' >&2 |
Saurab Dulal | 7b3655a | 2018-01-02 22:40:35 +0000 | [diff] [blame] | 335 | printf -- ' -a: install all the required dependencies\n' >&2 |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 336 | printf -- ' -b: install autocomplete for Bash and Zsh users\n' >&2 |
Saurab Dulal | 5d9ba60 | 2017-11-29 21:31:13 +0000 | [diff] [blame] | 337 | printf -- ' -e: install infoedit\n' >&2 |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 338 | printf -- ' -f: install NFD\n' >&2 |
| 339 | printf -- ' -i: install mini-ndn\n' >&2 |
| 340 | printf -- ' -m: install mininet and dependencies\n' >&2 |
| 341 | printf -- ' -r: install NLSR\n' >&2 |
| 342 | printf -- ' -t: install tools\n' >&2 |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 343 | printf -- ' -c: install Common Client Libraries\n' >&2 |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 344 | exit 2 |
| 345 | } |
| 346 | |
| 347 | if [[ $# -eq 0 ]]; then |
| 348 | usage |
| 349 | else |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 350 | while getopts 'abemfrtic' OPTION |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 351 | do |
| 352 | case $OPTION in |
Saurab Dulal | 7b3655a | 2018-01-02 22:40:35 +0000 | [diff] [blame] | 353 | a) |
Saurab Dulal | 7b3655a | 2018-01-02 22:40:35 +0000 | [diff] [blame] | 354 | forwarder |
| 355 | minindn |
| 356 | mininet |
| 357 | routing |
| 358 | tools |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 359 | infoedit |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 360 | argcomplete |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 361 | commonClientLibraries |
Saurab Dulal | 7b3655a | 2018-01-02 22:40:35 +0000 | [diff] [blame] | 362 | break |
| 363 | ;; |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 364 | b) argcomplete;; |
Saurab Dulal | 5d9ba60 | 2017-11-29 21:31:13 +0000 | [diff] [blame] | 365 | e) infoedit;; |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 366 | f) forwarder;; |
| 367 | i) minindn;; |
| 368 | m) mininet;; |
| 369 | r) routing;; |
| 370 | t) tools;; |
Jeff Thompson | 55d2bf4 | 2017-12-22 09:14:03 -0800 | [diff] [blame] | 371 | c) commonClientLibraries;; |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 372 | ?) usage;; |
| 373 | esac |
| 374 | done |
| 375 | shift $(($OPTIND - 1)) |
Ashlesh Gawande | 212cb82 | 2017-02-07 10:42:13 -0600 | [diff] [blame^] | 376 | fi |