added -r flag to install.sh to provide a convenience to reinstall latest code from current git branch

This commit is contained in:
Blake Harnden 2020-04-16 10:16:35 -07:00
parent 9bd13dce1e
commit ca292cb11e

View file

@ -5,6 +5,7 @@ set -e
ubuntu_py=3.6 ubuntu_py=3.6
centos_py=36 centos_py=36
reinstall=
function install_python_depencencies() { function install_python_depencencies() {
sudo python3 -m pip install -r daemon/requirements.txt sudo python3 -m pip install -r daemon/requirements.txt
@ -33,6 +34,12 @@ function install_core() {
sudo make install sudo make install
} }
function uninstall_core() {
sudo make uninstall
make clean
./bootstrap.sh clean
}
function install_dev_core() { function install_dev_core() {
cd gui cd gui
sudo make install sudo make install
@ -51,7 +58,7 @@ if [[ -f /etc/os-release ]]; then
fi fi
# parse arguments # parse arguments
while getopts "dv:" opt; do while getopts "drv:" opt; do
case ${opt} in case ${opt} in
d) d)
dev=1 dev=1
@ -60,64 +67,89 @@ while getopts "dv:" opt; do
ubuntu_py=${OPTARG} ubuntu_py=${OPTARG}
centos_py=${OPTARG} centos_py=${OPTARG}
;; ;;
r)
reinstall=1
;;
\?) \?)
echo "script usage: $(basename $0) [-d] [-v python version]" >&2 echo "script usage: $(basename $0) [-d] [-r] [-v python version]" >&2
exit 1 exit 1
;; ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
# check install was found # check if we are reinstalling or installing
case ${os} in if [ -z "${reinstall}" ]; then
"ubuntu") echo "installing CORE for ${os}"
echo "Installing CORE for Ubuntu" case ${os} in
echo "installing core system dependencies" "ubuntu")
sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 \ echo "installing core system dependencies"
python${ubuntu_py} python${ubuntu_py}-dev python3-pip python3-tk tk libtk-img ethtool autoconf sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 \
python3 -m pip install grpcio-tools python${ubuntu_py} python${ubuntu_py}-dev python3-pip python3-tk tk libtk-img ethtool autoconf
echo "installing ospf-mdr system dependencies" python3 -m pip install grpcio-tools
sudo apt install -y libtool gawk libreadline-dev echo "installing ospf-mdr system dependencies"
install_ospf_mdr sudo apt install -y libtool gawk libreadline-dev
if [[ -z ${dev} ]]; then install_ospf_mdr
echo "normal install" if [[ -z ${dev} ]]; then
install_python_depencencies 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
echo "building CORE"
case ${os} in
"ubuntu")
build_core build_core
install_core ;;
else "centos")
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 for 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 build_core --prefix=/usr
install_core ;;
else *)
echo "dev install" echo "unknown OS ID ${os} cannot reinstall"
sudo python3 -m pip install pipenv ;;
build_core --prefix=/usr esac
install_dev_core echo "installing CORE"
sudo python3 -m pipenv sync --dev install_core
python3 -m pipenv sync --dev fi
python3 -m pipenv run pre-commit install
fi
;;
*)
echo "unknown OS ID ${os} cannot install"
;;
esac