- [ -n "$logintry" ] && echo -e "\nInvalid database credentials!!!. Try again (Ctrl+c to abort)"
- [ -z "$logintry" ] && echo -e "\nProvide database name and credentials"
- read -e -p "mysql database name($DBNAME): " KK
- [ -n "$KK" ] && DBNAME="$KK"
- read -e -p "mysql user($DBUSER): " KK
- [ -n "$KK" ] && DBUSER="$KK"
- read -e -s -p "mysql password: " DBPASS
- echo -e "[client]\nuser='${DBUSER}'\npassword='${DBPASS}'" > "$TEMPFILE"
- logintry="yes"
- echo
+ # if password is not provided, try silently with $DEFAULT_DBPASS before exit or prompt for credentials
+ [[ -n "$FIRST_TRY" ]] && [[ -z "$DBPASS" ]] && DBPASS="$DEFAULT_DBPASS" &&
+ echo -e "[client]\n user='${DBUSER}'\n password='$DBPASS'\n host='$DBHOST'\n port='$DBPORT'" > "$TEMPFILE" &&
+ continue
+ echo "$DB_ERROR"
+ [[ -n "$QUIET_MODE" ]] && echo -e "Invalid database credentials!!!" >&2 && exit 1
+ echo -e "Provide database name and credentials (Ctrl+c to abort):"
+ read -e -p " mysql database name($DBNAME): " KK
+ [ -n "$KK" ] && DBNAME="$KK"
+ read -e -p " mysql user($DBUSER): " KK
+ [ -n "$KK" ] && DBUSER="$KK"
+ read -e -s -p " mysql password: " DBPASS
+ echo -e "[client]\n user='${DBUSER}'\n password='$DBPASS'\n host='$DBHOST'\n port='$DBPORT'" > "$TEMPFILE"
+ FIRST_TRY=""
+ echo