+function ask_user(){
+ # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
+ # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
+ # Return: true(0) if user type 'yes'; false (1) if user type 'no'
+ read -e -p "$1" USER_CONFIRMATION
+ while true ; do
+ [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
+ [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
+ [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
+ [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
+ read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
+ done
+}
+
+GIT_URL=https://osm.etsi.org/gerrit/osm/RO.git
+GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git
+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" ] && 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