2019-12-20 00:07:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# exit on error
|
|
|
|
set -e
|
|
|
|
|
2020-03-05 21:19:20 +00:00
|
|
|
ubuntu_py=3.6
|
|
|
|
centos_py=36
|
2020-04-16 18:16:35 +01:00
|
|
|
reinstall=
|
2020-03-05 21:19:20 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-04-16 18:16:35 +01:00
|
|
|
function uninstall_core() {
|
|
|
|
sudo make uninstall
|
|
|
|
make clean
|
|
|
|
./bootstrap.sh clean
|
|
|
|
}
|
|
|
|
|
2019-12-23 17:28:49 +00:00
|
|
|
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
|
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
|
2020-04-16 18:16:35 +01:00
|
|
|
while getopts "drv:" opt; do
|
2019-12-23 17:28:49 +00:00
|
|
|
case ${opt} in
|
|
|
|
d)
|
|
|
|
dev=1
|
|
|
|
;;
|
2020-03-05 21:19:20 +00:00
|
|
|
v)
|
|
|
|
ubuntu_py=${OPTARG}
|
|
|
|
centos_py=${OPTARG}
|
|
|
|
;;
|
2020-04-16 18:16:35 +01:00
|
|
|
r)
|
|
|
|
reinstall=1
|
|
|
|
;;
|
2019-12-23 17:28:49 +00:00
|
|
|
\?)
|
2020-04-16 18:16:35 +01:00
|
|
|
echo "script usage: $(basename $0) [-d] [-r] [-v python version]" >&2
|
2020-03-05 21:19:20 +00:00
|
|
|
exit 1
|
2019-12-23 17:28:49 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
|
2020-04-16 18:16:35 +01:00
|
|
|
# check if we are reinstalling or installing
|
|
|
|
if [ -z "${reinstall}" ]; then
|
|
|
|
echo "installing CORE for ${os}"
|
|
|
|
case ${os} in
|
|
|
|
"ubuntu")
|
|
|
|
echo "installing core system dependencies"
|
|
|
|
sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 \
|
|
|
|
python${ubuntu_py} python${ubuntu_py}-dev python3-pip python3-tk tk libtk-img ethtool autoconf
|
|
|
|
python3 -m pip install grpcio-tools
|
|
|
|
echo "installing ospf-mdr system dependencies"
|
|
|
|
sudo apt install -y libtool gawk libreadline-dev
|
|
|
|
install_ospf_mdr
|
|
|
|
if [[ -z ${dev} ]]; then
|
|
|
|
echo "normal install"
|
|
|
|
install_python_depencencies
|
|
|
|
build_core
|
|
|
|
install_core
|
|
|
|
else
|
|
|
|
echo "dev install"
|
|
|
|
python3 -m pip install pipenv
|
|
|
|
build_core
|
|
|
|
install_dev_core
|
|
|
|
python3 -m pipenv sync --dev
|
|
|
|
python3 -m pipenv run pre-commit install
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"centos")
|
|
|
|
echo "installing core system dependencies"
|
|
|
|
sudo yum install -y automake pkgconf-pkg-config gcc gcc-c++ libev-devel iptables-ebtables iproute \
|
|
|
|
python${centos_py} python${centos_py}-devel python3-pip python3-tkinter tk ethtool autoconf
|
|
|
|
sudo python3 -m pip install grpcio-tools
|
|
|
|
echo "installing ospf-mdr system dependencies"
|
|
|
|
sudo yum install -y libtool gawk readline-devel
|
|
|
|
install_ospf_mdr
|
|
|
|
if [[ -z ${dev} ]]; then
|
|
|
|
echo "normal install"
|
|
|
|
install_python_depencencies
|
|
|
|
build_core --prefix=/usr
|
|
|
|
install_core
|
|
|
|
else
|
|
|
|
echo "dev install"
|
|
|
|
sudo python3 -m pip install pipenv
|
|
|
|
build_core --prefix=/usr
|
|
|
|
install_dev_core
|
|
|
|
sudo python3 -m pipenv sync --dev
|
|
|
|
python3 -m pipenv sync --dev
|
|
|
|
python3 -m pipenv run pre-commit install
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown OS ID ${os} cannot install"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
branch=$(git symbolic-ref --short HEAD)
|
|
|
|
echo "reinstalling CORE on ${os} with latest ${branch}"
|
|
|
|
echo "uninstalling CORE"
|
|
|
|
uninstall_core
|
|
|
|
echo "pulling latest code"
|
|
|
|
git pull
|
2020-05-08 17:22:22 +01:00
|
|
|
echo "installing python dependencies"
|
|
|
|
install_python_depencencies
|
2020-04-16 18:16:35 +01:00
|
|
|
echo "building CORE"
|
|
|
|
case ${os} in
|
|
|
|
"ubuntu")
|
2019-12-23 17:28:49 +00:00
|
|
|
build_core
|
2020-04-16 18:16:35 +01:00
|
|
|
;;
|
|
|
|
"centos")
|
2019-12-23 17:28:49 +00:00
|
|
|
build_core --prefix=/usr
|
2020-04-16 18:16:35 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown OS ID ${os} cannot reinstall"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "installing CORE"
|
|
|
|
install_core
|
|
|
|
fi
|