Change dockerfile-local to install osm-im, lib-osm-openvim and RO from source instead of making

Change-Id: I03af69a2f798ed5b0645c2d3eac4ac48b15805a2
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/scripts/RO-of b/scripts/RO-of
index a4e6bbd..1e5c917 100755
--- a/scripts/RO-of
+++ b/scripts/RO-of
@@ -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.
 #
diff --git a/scripts/RO-start.sh b/scripts/RO-start.sh
index afc746a..7d442f0 100755
--- a/scripts/RO-start.sh
+++ b/scripts/RO-start.sh
@@ -66,7 +66,7 @@
         #wait 120 sec
         if [ $attempt -ge $max_attempts ]; then
             echo
-            echo "Can not connect to database ${db_host}:${db_port} during $max_attempts sec"
+            echo "Cannot connect to database ${db_host}:${db_port} during $max_attempts sec"
             return 1
         fi
         attempt=$[$attempt+1]
@@ -78,7 +78,8 @@
 
 
 echo "1/4 Apply config"
-configure || exit 1
+# this is not needed anymore because envioron overwrites config file
+# configure || exit 1
 
 
 echo "2/4 Wait for db up"
@@ -129,4 +130,9 @@
 
 
 echo "4/4 Try to start"
-/usr/bin/openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log --create-tenant=osm
+# look for openmanod.cfg
+RO_CONFIG_FILE="/etc/osm/openmanod.cfg"
+[ -f "$RO_CONFIG_FILE" ] || RO_CONFIG_FILE=$(python -c 'import osm_ro; print(osm_ro.__path__[0])')/openmanod.cfg
+[ -f "$RO_CONFIG_FILE" ] || ! echo "configuration file 'openmanod.cfg' not found" || exit 1
+
+openmanod -c "$RO_CONFIG_FILE" --log-file=/var/log/osm/openmano.log --create-tenant=osm
diff --git a/scripts/get-options.sh b/scripts/get-options.sh
index 82ec06c..8b2968e 100644
--- a/scripts/get-options.sh
+++ b/scripts/get-options.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.
 #
diff --git a/scripts/install-lib-osm-openvim.sh b/scripts/install-lib-osm-openvim.sh
index b43f6fe..c1374d5 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 @@
 
 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
diff --git a/scripts/install-openmano-service.sh b/scripts/install-openmano-service.sh
index 499120d..c19b345 100755
--- a/scripts/install-openmano-service.sh
+++ b/scripts/install-openmano-service.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.
 #
diff --git a/scripts/install-openmano.sh b/scripts/install-openmano.sh
index 9a36116..3b18494 100755
--- a/scripts/install-openmano.sh
+++ b/scripts/install-openmano.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.
 #
diff --git a/scripts/install-osm-im.sh b/scripts/install-osm-im.sh
index 0f9a6c6..2fad214 100755
--- a/scripts/install-osm-im.sh
+++ b/scripts/install-osm-im.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.
 #
@@ -30,6 +30,50 @@
 [ -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 @@
         -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
diff --git a/scripts/openmano-report b/scripts/openmano-report
index 13c941a..f2180af 100755
--- a/scripts/openmano-report
+++ b/scripts/openmano-report
@@ -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.
 #
diff --git a/scripts/service-openmano b/scripts/service-openmano
index 7de9a40..a44743d 100755
--- a/scripts/service-openmano
+++ b/scripts/service-openmano
@@ -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.
 #