ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | test -e /etc/debian_version && DIST="Debian" |
| 4 | grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu" |
| 5 | |
| 6 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 7 | update='sudo apt-get update' |
| 8 | install='sudo apt-get -y install' |
| 9 | remove='sudo apt-get -y remove' |
| 10 | pkginst='sudo dpkg -i' |
| 11 | # Prereqs for this script |
| 12 | if ! which lsb_release &> /dev/null; then |
| 13 | $install lsb-release |
| 14 | fi |
| 15 | fi |
| 16 | |
| 17 | test -e /etc/fedora-release && DIST="Fedora" |
| 18 | if [[ $DIST == Fedora ]]; then |
| 19 | update='sudo yum update' |
| 20 | install='sudo yum -y install' |
| 21 | remove='sudo yum -y erase' |
| 22 | pkginst='sudo rpm -ivh' |
| 23 | # Prereqs for this script |
| 24 | if ! which lsb_release &> /dev/null; then |
| 25 | $install redhat-lsb-core |
| 26 | fi |
| 27 | fi |
| 28 | |
| 29 | function forwarder { |
| 30 | if [[ $cxx != true ]]; then |
| 31 | ndncxx |
| 32 | cxx="true" |
| 33 | fi |
| 34 | |
| 35 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 36 | $install libpcap-dev pkg-config |
| 37 | fi |
| 38 | |
| 39 | if [[ $DIST == Fedora ]]; then |
| 40 | $install libpcap-devel |
| 41 | fi |
| 42 | |
| 43 | git clone --depth 1 https://github.com/named-data/NFD |
| 44 | cd NFD |
| 45 | ./waf configure --without-websocket |
| 46 | ./waf |
| 47 | sudo ./waf install |
| 48 | cd ../ |
| 49 | } |
| 50 | |
| 51 | function routing { |
| 52 | if [[ $cxx != true ]]; then |
| 53 | ndncxx |
| 54 | cxx="true" |
| 55 | fi |
| 56 | |
| 57 | if [[ $DIST == Ubuntu ]]; then |
| 58 | $install liblog4cxx10-dev libprotobuf-dev protobuf-compiler |
| 59 | fi |
| 60 | |
| 61 | if [[ $DIST == Fedora ]]; then |
| 62 | $install log4cxx log4cxx-devel openssl-devel protobuf-devel |
| 63 | fi |
| 64 | |
| 65 | git clone --depth 1 https://github.com/named-data/NLSR |
| 66 | cd NLSR |
| 67 | ./waf configure |
| 68 | ./waf |
| 69 | sudo ./waf install |
| 70 | cd ../ |
| 71 | } |
| 72 | |
| 73 | function ndncxx { |
| 74 | if [[ updated != true ]]; then |
| 75 | $update |
| 76 | updated="true" |
| 77 | fi |
| 78 | |
| 79 | if [[ $DIST == Ubuntu || $DIST == Debian ]]; then |
| 80 | $install git libsqlite3-dev libboost-all-dev make g++ |
| 81 | crypto |
| 82 | fi |
| 83 | |
| 84 | if [[ $DIST == Fedora ]]; then |
| 85 | $install gcc-c++ sqlite-devel boost-devel |
| 86 | fi |
| 87 | |
| 88 | git clone --depth 1 https://github.com/named-data/ndn-cxx |
| 89 | cd ndn-cxx |
| 90 | ./waf configure |
| 91 | ./waf |
| 92 | sudo ./waf install |
| 93 | cd ../ |
| 94 | } |
| 95 | |
| 96 | function crypto { |
| 97 | mkdir crypto |
| 98 | cd crypto |
| 99 | $install unzip |
| 100 | wget http://www.cryptopp.com/cryptopp562.zip |
| 101 | unzip cryptopp562.zip |
| 102 | make |
| 103 | sudo make install |
| 104 | cd ../ |
| 105 | } |
| 106 | |
| 107 | function tools { |
| 108 | if [[ $cxx != true ]]; then |
| 109 | ndncxx |
| 110 | cxx="true" |
| 111 | fi |
| 112 | |
| 113 | git clone --depth 1 https://github.com/named-data/ndn-tools |
| 114 | cd ndn-tools |
| 115 | ./waf configure |
| 116 | ./waf |
| 117 | sudo ./waf install |
| 118 | cd ../ |
| 119 | } |
| 120 | |
| 121 | function mininet { |
| 122 | if [[ updated != true ]]; then |
| 123 | $update |
| 124 | updated="true" |
| 125 | fi |
| 126 | |
| 127 | if [[ $pysetup != true ]]; then |
| 128 | pysetup="true" |
| 129 | fi |
| 130 | |
| 131 | git clone --depth 1 https://github.com/mininet/mininet |
| 132 | cd mininet |
| 133 | sudo ./util/install.sh -fnv |
| 134 | cd ../ |
| 135 | } |
| 136 | |
| 137 | function minindn { |
| 138 | if [[ updated != true ]]; then |
| 139 | $update |
| 140 | updated="true" |
| 141 | fi |
| 142 | |
| 143 | if [[ $pysetup != true ]]; then |
| 144 | $install python-setuptools |
| 145 | pysetup="true" |
| 146 | fi |
| 147 | sudo mkdir -p /usr/local/etc/mini-ndn/ |
| 148 | sudo cp ndn_utils/client.conf.sample /usr/local/etc/mini-ndn/ |
| 149 | sudo cp ndn_utils/nfd.conf /usr/local/etc/mini-ndn/ |
| 150 | sudo cp ndn_utils/nlsr.conf /usr/local/etc/mini-ndn/ |
| 151 | sudo python setup.py install |
| 152 | } |
| 153 | |
| 154 | |
| 155 | function usage { |
| 156 | printf '\nUsage: %s [-mfrti]\n\n' $(basename $0) >&2 |
| 157 | |
| 158 | printf 'options:\n' >&2 |
| 159 | printf -- ' -f: install NFD\n' >&2 |
| 160 | printf -- ' -i: install mini-ndn\n' >&2 |
| 161 | printf -- ' -m: install mininet and dependencies\n' >&2 |
| 162 | printf -- ' -r: install NLSR\n' >&2 |
| 163 | printf -- ' -t: install tools\n' >&2 |
| 164 | exit 2 |
| 165 | } |
| 166 | |
| 167 | if [[ $# -eq 0 ]]; then |
| 168 | usage |
| 169 | else |
| 170 | while getopts 'mfrti' OPTION |
| 171 | do |
| 172 | case $OPTION in |
| 173 | f) forwarder;; |
| 174 | i) minindn;; |
| 175 | m) mininet;; |
| 176 | r) routing;; |
| 177 | t) tools;; |
| 178 | ?) usage;; |
| 179 | esac |
| 180 | done |
| 181 | shift $(($OPTIND - 1)) |
| 182 | fi |