+GIT_URL=https://osm.etsi.org/gerrit/osm/RO.git
+export GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git
+export GIT_OSMIM_URL=https://osm.etsi.org/gerrit/osm/IM.git
+DBUSER="root"
+DBPASSWD=""
+DBPASSWD_PARAM=""
+QUIET_MODE=""
+DEVELOP=""
+DB_FORCE_UPDATE=""
+UPDATEDB=""
+FORCE=""
+NOCLONE=""
+NO_PACKAGES=""
+NO_DB=""
+COMMIT_ID=""
+
+while getopts ":u:p:b:hiq-:" o; do
+ case "${o}" in
+ u)
+ export DBUSER="$OPTARG"
+ ;;
+ p)
+ export DBPASSWD="$OPTARG"
+ export DBPASSWD_PARAM="-p$OPTARG"
+ ;;
+ b)
+ export COMMIT_ID=${OPTARG}
+ ;;
+ q)
+ export QUIET_MODE=yes
+ export DEBIAN_FRONTEND=noninteractive
+ ;;
+ h)
+ usage && exit 0
+ ;;
+ -)
+ [ "${OPTARG}" == "help" ] && usage && exit 0
+ [ "${OPTARG}" == "develop" ] && export DEVELOP="y" && continue
+ [ "${OPTARG}" == "forcedb" ] && DB_FORCE_UPDATE="${DB_FORCE_UPDATE}--forcedb" && continue
+ [ "${OPTARG}" == "updatedb" ] && DB_FORCE_UPDATE="${DB_FORCE_UPDATE}--updatedb" && continue
+ [ "${OPTARG}" == "force" ] && FORCE="y" && continue
+ [ "${OPTARG}" == "noclone" ] && NOCLONE="y" && continue
+ [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue
+ [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue
+ [ "${OPTARG}" == "no-db" ] && NO_DB="y" && 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
+
+if [ "$DB_FORCE_UPDATE" == "--forcedb--updatedb" ] || [ "$DB_FORCE_UPDATE" == "--updatedb--forcedb" ] ; then
+ echo "Error: options --forcedb and --updatedb are mutually exclusive" >&2
+ exit 1
+elif [ -n "$FORCE" ] && [ -z "$DB_FORCE_UPDATE" ] ; then
+ DB_FORCE_UPDATE="--updatedb"
+fi
+
+#check root privileges and non a root user behind
+[ "$USER" != "root" ] && echo "Needed root privileges" >&2 && exit 1
+if [[ -z "$SUDO_USER" ]] || [[ "$SUDO_USER" = "root" ]]
+then
+ [[ -z $QUIET_MODE ]] && ! ask_user "Install in the root user (y/N)? " n && echo "Cancelled" && exit 1
+ export SUDO_USER=root
+fi