2019-12-20 00:07:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# exit on error
|
|
|
|
set -e
|
|
|
|
|
2019-12-21 07:45:05 +00:00
|
|
|
function install_python_depencencies() {
|
2019-12-23 17:28:49 +00:00
|
|
|
sudo python3 -m pip install -r daemon/requirements.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_python_dev_dependencies() {
|
|
|
|
sudp pip install pipenv grpcio-tools
|
2019-12-21 07:45:05 +00:00
|
|
|
}
|
2019-12-20 00:07:17 +00:00
|
|
|
|
2019-12-21 07:45:05 +00:00
|
|
|
function install_ospf_mdr() {
|
2019-12-23 17:28:49 +00:00
|
|
|
rm -rf /tmp/ospf-mdr
|
|
|
|
git clone https://github.com/USNavalResearchLaboratory/ospf-mdr /tmp/ospf-mdr
|
|
|
|
cd /tmp/ospf-mdr
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure --disable-doc --enable-user=root --enable-group=root --with-cflags=-ggdb \
|
|
|
|
--sysconfdir=/usr/local/etc/quagga --enable-vtysh \
|
|
|
|
--localstatedir=/var/run/quagga
|
|
|
|
make -j8
|
|
|
|
sudo make install
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
|
|
|
function build_core() {
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure $1
|
|
|
|
make -j8
|
2019-12-21 07:45:05 +00:00
|
|
|
}
|
2019-12-20 00:07:17 +00:00
|
|
|
|
2019-12-21 07:45:05 +00:00
|
|
|
function install_core() {
|
2019-12-23 17:28:49 +00:00
|
|
|
sudo make install
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_dev_core() {
|
2019-12-23 21:36:25 +00:00
|
|
|
cd gui
|
|
|
|
sudo make install
|
|
|
|
cd -
|
|
|
|
cd netns
|
|
|
|
sudo make install
|
|
|
|
cd -
|
2019-12-23 17:28:49 +00:00
|
|
|
cd daemon
|
|
|
|
pipenv install --dev
|
2019-12-23 21:36:25 +00:00
|
|
|
cd -
|
2019-12-21 07:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# detect os/ver for install type
|
|
|
|
os=""
|
|
|
|
if [[ -f /etc/os-release ]]; then
|
2019-12-23 17:28:49 +00:00
|
|
|
. /etc/os-release
|
|
|
|
os=${ID}
|
2019-12-20 00:07:17 +00:00
|
|
|
fi
|
2019-12-21 07:45:05 +00:00
|
|
|
|
2019-12-23 17:28:49 +00:00
|
|
|
# parse arguments
|
|
|
|
while getopts ":d" opt; do
|
|
|
|
case ${opt} in
|
|
|
|
d)
|
|
|
|
dev=1
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid Option: $OPTARG" 1>&2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
|
2019-12-21 07:45:05 +00:00
|
|
|
# check install was found
|
|
|
|
case ${os} in
|
2019-12-23 17:28:49 +00:00
|
|
|
"ubuntu")
|
|
|
|
echo "Installing CORE for Ubuntu"
|
2019-12-23 22:48:56 +00:00
|
|
|
sudo apt install -y automake pkg-config gcc libev-dev ebtables gawk iproute2 \
|
2019-12-23 17:28:49 +00:00
|
|
|
python3.6 python3.6-dev python3-pip python3-tk tk libtk-img ethtool libtool libreadline-dev autoconf
|
|
|
|
install_ospf_mdr
|
|
|
|
if [[ -z ${dev} ]]; then
|
|
|
|
echo "normal install"
|
2019-12-21 07:45:05 +00:00
|
|
|
install_python_depencencies
|
2019-12-23 17:28:49 +00:00
|
|
|
build_core
|
2019-12-21 07:45:05 +00:00
|
|
|
install_core
|
2019-12-23 17:28:49 +00:00
|
|
|
else
|
|
|
|
echo "dev install"
|
|
|
|
install_python_dev_dependencies
|
|
|
|
build_core
|
|
|
|
install_dev_core
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"centos")
|
2019-12-23 22:48:56 +00:00
|
|
|
sudo yum install -y automake pkgconf-pkg-config gcc gcc-c++ libev-devel iptables-ebtables iproute \
|
2019-12-23 17:28:49 +00:00
|
|
|
python36 python36-devel python3-pip python3-tkinter tk ethtool libtool readline-devel autoconf gawk
|
|
|
|
install_ospf_mdr
|
|
|
|
if [[ -z ${dev} ]]; then
|
2019-12-21 07:45:05 +00:00
|
|
|
install_python_depencencies
|
2019-12-23 17:28:49 +00:00
|
|
|
build_core --prefix=/usr
|
|
|
|
install_core
|
|
|
|
else
|
|
|
|
install_python_dev_dependencies
|
|
|
|
build_core --prefix=/usr
|
|
|
|
install_dev_core
|
|
|
|
fi
|
|
|
|
;;
|
2019-12-21 07:45:05 +00:00
|
|
|
*)
|
2019-12-23 17:28:49 +00:00
|
|
|
echo "unknown OS ID ${os} cannot install"
|
|
|
|
;;
|
2019-12-21 07:45:05 +00:00
|
|
|
esac
|