Skip to content

Resolve "ssh vs linux user: if no `-U` specified, something unpredictable happens"

Description

  • Don't add --username to _PSQL (wrapper) if the argument is not given
  • Do not print whole help after error (better attention to error)
  • Improve example with ssh username

Related issue

#312 (closed)

Examples

[[ "${USERNAME}" = "None" ]] && export USERNAME=""
...

  # use default Postgres username or not
  local user_substr=""
  if [[ ! -z ${USERNAME+x} ]]; then
    user_substr=" -U \"${USERNAME}\" "
  fi

  # Construct _PSQL macro for usage inside the check scripts
  export PGOPTIONS="-c statement_timeout=${STIMEOUT}s"
  export PSQL_CONN_OPTIONS="--port=${PGPORT} --dbname=${DBNAME} ${user_substr} ${psql_unix_socket_option}"
  export _PSQL="PGOPTIONS=\"${PGOPTIONS}\" ${pgpas_subst}${psql_bin} -1 -X -At -q -v ON_ERROR_STOP=1 -P pager=off ${PSQL_CONN_OPTIONS}"

image

image

Closes #312 (closed)

Edited by Victor Yagofarov

Merge request reports