Change dockerfile-local to install osm-im, lib-osm-openvim and RO from source instead...
[osm/RO.git] / scripts / install-osm-im.sh
index 0f9a6c6..2fad214 100755 (executable)
@@ -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.
 #
 [ -z "$NO_PACKAGES" ] && NO_PACKAGES=""
 [ -z "$_DISTRO" ] && _DISTRO="Ubuntu"
 
+function usage(){
+    echo -e "usage: sudo -E $0 [OPTIONS]"
+    echo -e "Install last stable source code of osm-im 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_OSMIM_URL} IM" ||
     ! echo "Error cannot clone from '${GIT_OSMIM_URL}'" >&2 || exit 1
@@ -64,4 +108,4 @@ for target in vnfd nsd ; do
         -o "${BASEFOLDER}/IM/osm_im/${target}.py" "${BASEFOLDER}/IM/models/yang/${target}.yang"
 done
 
-pip2 install -e "${BASEFOLDER}/IM" || ! echo "ERROR installing python-osm-im library!!!" >&2  || exit 1
\ No newline at end of file
+pip2 install -e "${BASEFOLDER}/IM" || ! echo "ERROR installing python-osm-im library!!!" >&2  || exit 1