installation script enhancement. Allow test/basictest install openvim in test mode

Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/scripts/install-openmano-service.sh b/scripts/install-openmano-service.sh
index c5bccec..54783ad 100755
--- a/scripts/install-openmano-service.sh
+++ b/scripts/install-openmano-service.sh
@@ -26,11 +26,11 @@
 
 function usage(){
     echo -e "usage: sudo $0 [OPTIONS]"
-    echo -e "Configures openmano to run as a service"
+    echo -e "Configures openmano to run as a service at /opt"
     echo -e "  OPTIONS"
     echo -e "     -u USER_OWNER  user owner of the service, 'root' by default"
     echo -e "     -f PATH  path where openmano source is located. If missing it is downloaded from git"
-    #echo -e "     -q:  install in an unattended mode"
+    echo -e "     -d --delete:  if -f is provided, delete this path after copying to /opt"
     echo -e "     -h:  show this help"
     echo -e "     --uninstall: remove created service and files"
 }
@@ -50,7 +50,8 @@
 USER_OWNER="root"
 QUIET_MODE=""
 FILE=""
-while getopts ":u:f:hq-:" o; do
+DELETE=""
+while getopts ":u:f:hdq-:" o; do
     case "${o}" in
         u)
             export USER_OWNER="$OPTARG"
@@ -64,10 +65,14 @@
         h)
             usage && exit 0
             ;;
+        d)
+            DELETE=y
+            ;;
         -)
             [ "${OPTARG}" == "help" ] && usage && exit 0
             [ "${OPTARG}" == "uninstall" ] && uninstall && exit 0
-            echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2 
+            [ "${OPTARG}" == "delete" ] && DELETE=y && continue
+            echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
             exit 1
             ;; 
         \?)
@@ -114,6 +119,7 @@
 then
     FILE=__temp__${RANDOM}
     git clone $GIT_URL $FILE || ! echo "Cannot get openmano source code from $GIT_URL" >&2 || exit 1
+    DELETE=y
 else
     [[ -d  "$FILE" ]] || ! echo $BAD_PATH_ERROR >&2 || exit 1
 fi
@@ -130,7 +136,7 @@
 ln -s -v /opt/openmano/scripts/service-openmano.sh /usr/sbin/service-openmano
 ln -s -v /opt/openmano/scripts/openmano-report.sh /usr/bin/openmano-report
 
-chown -R $USER_OWNER /opt/openmano
+chown -R $SUDO_USER /opt/openmano
 
 mkdir -p /etc/systemd/system/
 cat  > /etc/systemd/system/openmano.service  << EOF 
@@ -146,7 +152,7 @@
 WantedBy=multi-user.target
 EOF
 
-rm -rf ${FILE}
+[[ -n $DELETE ]] && rm -rf ${FILE}
 
 service openmano start
 systemctl enable openmano.service
diff --git a/scripts/install-openmano.sh b/scripts/install-openmano.sh
index f55851d..9a01775 100755
--- a/scripts/install-openmano.sh
+++ b/scripts/install-openmano.sh
@@ -173,8 +173,12 @@
 [[ "$_DISTRO" == "Ubuntu" ]] &&  [[ ${_RELEASE%%.*} == 16 ]] && [[ -z $DEVELOP ]] && INSTALL_AS_A_SERVICE="y"
 #Next operations require knowing OPENMANO_BASEFOLDER
 if [[ -z "$NOCLONE" ]]; then
-    OPENMANO_BASEFOLDER="${PWD}/openmano"
-    [[ -n "$FORCE" ]] && rm -rf $OPENMANO_BASEFOLDER #make idenpotent
+    if [[ -n "$INSTALL_AS_A_SERVICE" ]] ; then
+        OPENMANO_BASEFOLDER=__openmano__${RANDOM}
+    else
+        OPENMANO_BASEFOLDER="${PWD}/openmano"
+    fi
+    [[ -n "$FORCE" ]] && rm -rf $OPENMANO_BASEFOLDER #make idempotent
 else
     HERE=$(realpath $(dirname $0))
     OPENMANO_BASEFOLDER=$(dirname $HERE)
@@ -365,9 +369,9 @@
     su $SUDO_USER -c 'rm -f ${HOME}/bin/openmano'
     su $SUDO_USER -c 'rm -f ${HOME}/bin/openmano-report'
     su $SUDO_USER -c 'rm -f ${HOME}/bin/service-openmano'
-    su $SUDO_USER -c 'ln -s '${OPENMANO_BASEFOLDER}'/openmano ${HOME}/bin/openmano'
-    su $SUDO_USER -c 'ln -s '${OPENMANO_BASEFOLDER}'/scripts/openmano-report.sh   ${HOME}/bin/openmano-report'
-    su $SUDO_USER -c 'ln -s '${OPENMANO_BASEFOLDER}'/scripts/service-openmano.sh  ${HOME}/bin/service-openmano'
+    su $SUDO_USER -c "ln -s '${OPENMANO_BASEFOLDER}/openmano' "'${HOME}/bin/openmano'
+    su $SUDO_USER -c "ln -s '${OPENMANO_BASEFOLDER}/scripts/openmano-report.sh'   "'${HOME}/bin/openmano-report'
+    su $SUDO_USER -c "ln -s '${OPENMANO_BASEFOLDER}/scripts/service-openmano.sh'  "'${HOME}/bin/service-openmano'
 
     #insert /home/<user>/bin in the PATH
     #skiped because normally this is done authomatically when ~/bin exist
@@ -406,7 +410,7 @@
 #####             CONFIGURE OPENMANO SERVICE                #####
 #################################################################'
 
-    ${OPENMANO_BASEFOLDER}/scripts/install-openmano-service.sh -f ${OPENMANO_BASEFOLDER} #-u $SUDO_USER
+    ${OPENMANO_BASEFOLDER}/scripts/install-openmano-service.sh -f ${OPENMANO_BASEFOLDER} `[[ -z "$NOCLONE" ]] && echo "-d"`
 #    rm -rf ${OPENMANO_BASEFOLDER}
 #    alias service-openmano="service openmano"
 #    echo 'alias service-openmano="service openmano"' >> ${HOME}/.bashrc