X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=scripts%2Finstall-lib-osm-openvim.sh;h=c1374d501ec70557e3f2cd5a250c33ef72682a63;hb=14a823d1da13f3a9890ae0ae2b7162c60e451a14;hp=b43f6fe3b6a551c75f90af407724cc191d22a35b;hpb=a7f744d3f1a2aa124ccb6a471b25199fc7e7f31b;p=osm%2FRO.git diff --git a/scripts/install-lib-osm-openvim.sh b/scripts/install-lib-osm-openvim.sh index b43f6fe3..c1374d50 100755 --- a/scripts/install-lib-osm-openvim.sh +++ b/scripts/install-lib-osm-openvim.sh @@ -1,7 +1,7 @@ #!/bin/bash ## -# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. +# Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. # This file is part of openmano # All Rights Reserved. # @@ -31,6 +31,51 @@ [ -z "$_DISTRO" ] && _DISTRO="Ubuntu" +function usage(){ + echo -e "usage: sudo -E $0 [OPTIONS]" + echo -e "Install last stable source code of lib-osm-openvim and the needed packages" + echo -e " OPTIONS" + echo -e " -h --help: show this help" + echo -e " -b REFSPEC: install from source code using a specific branch (master, v2.0, ...) or tag" + echo -e " -b master (main branch)" + echo -e " -b v2.0 (v2.0 branch)" + echo -e " -b tags/v1.1.0 (a specific tag)" + echo -e " ..." + echo -e " --develop: install last master version for developers" + echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This" \ + "avoid wasting time if you are sure requires packages are present e.g. because of a previous installation" +} +while getopts ":b:h-:" o; do + case "${o}" in + b) + export COMMIT_ID=${OPTARG} + ;; + h) + usage && exit 0 + ;; + -) + [ "${OPTARG}" == "help" ] && usage && exit 0 + [ "${OPTARG}" == "develop" ] && export DEVELOP="y" && continue + [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue + [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue + echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2 + exit 1 + ;; + \?) + echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2 + exit 1 + ;; + :) + echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2 + exit 1 + ;; + *) + usage >&2 + exit 1 + ;; + esac +done + su $SUDO_USER -c "git -C '${BASEFOLDER}' clone ${GIT_OVIM_URL} lib-openvim" || ! echo "Error cannot clone from '${GIT_OVIM_URL}'" >&2 || exit 1 if [[ -n $COMMIT_ID ]] ; then @@ -48,4 +93,5 @@ fi make -C "${BASEFOLDER}/lib-openvim" prepare_lite export LANG="en_US.UTF-8" -pip2 install -e "${BASEFOLDER}/lib-openvim/build" +pip2 install -e "${BASEFOLDER}/lib-openvim/build" || ! echo "ERROR installing lib-osm-openvim library!!!" >&2 || + exit 1