Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit c9108e1

Browse files
authored
Fix connections to clouds (no ssh support) (#127)
* fix connection path if ssh not working * fix regex for project names * improve comment
1 parent 2988bf8 commit c9108e1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

check

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ validate_arg_type() {
248248
exit 1
249249
fi
250250
elif [ $type = "word" ]; then
251-
re='^[a-zA-Z_-]+$'
251+
re='^[a-zA-Z0-9_-]+$'
252252
if ! [[ $value =~ $re ]]; then
253253
err "'$name' = '$value' => is not a '$type' (${re})"
254254
exit 1
@@ -436,7 +436,7 @@ usage() {
436436
# additional info
437437
echo >&${out_descriptor}
438438
echo "Example:" >&${out_descriptor}
439-
echo "./${SCRIPT_NAME} -h dev -p 5432 --username ${USER} --dbname postgres --project dummy" >&${out_descriptor}
439+
echo "PGPASSWORD=postgres ./${SCRIPT_NAME} -h dev -p 5432 --username ${USER} --dbname postgres --project dummy" >&${out_descriptor}
440440
echo >&${out_descriptor}
441441
echo "Add more checks into './resources/checks/' directory." >&${out_descriptor}
442442
echo >&${out_descriptor}
@@ -676,7 +676,7 @@ check_bin_deps() {
676676
#######################################
677677
# Check rights, set global variables, etc.
678678
# Globals:
679-
# HOST, CHECK_HOST_CMD
679+
# HOST, CHECK_HOST_CMD, NATIVE_HOSTNAME
680680
# Arguments:
681681
# None
682682
# Returns:
@@ -685,12 +685,20 @@ check_bin_deps() {
685685
host_pre_start_checks() {
686686
# choise host connection command
687687
# while checking ssh support
688-
if (ssh $HOST "true" >/dev/null 2>&1); then
688+
# and determine NATIVE_HOSTNAME (a host key in JSON reports)
689+
if NATIVE_HOSTNAME=$(ssh $HOST "hostname" 2>/dev/null); then
690+
# ssh to remote host and use local psql (default)
689691
export CHECK_HOST_CMD="ssh ${HOST}"
690692
else
693+
NATIVE_HOSTNAME="${HOST}"
694+
# swap ssh with bash
691695
export CHECK_HOST_CMD="bash -e -u -o pipefail -c"
696+
# use local psql and connect to remote postgres without ssh
697+
export _PSQL="${_PSQL} -h ${HOST}"
692698
fi
693-
dbg "CHECK_HOST_CMD: ${CHECK_HOST_CMD}"
699+
export NATIVE_HOSTNAME
700+
dbg "CHECK_HOST_CMD: '${CHECK_HOST_CMD}'"
701+
dbg "NATIVE_HOSTNAME: '$NATIVE_HOSTNAME'"
694702
}
695703

696704
#######################################
@@ -784,7 +792,6 @@ update_nodes_json() {
784792
fi
785793

786794
export ALIAS_NAME ALIAS_INDEX ROLE EPOCH
787-
dbg "NATIVE_HOSTNAME: '$NATIVE_HOSTNAME'"
788795
dbg "ALIAS_NAME: '$ALIAS_NAME'"
789796
dbg "ALIAS_INDEX: '$ALIAS_INDEX'"
790797
dbg "ROLE: '$ROLE'"
@@ -832,13 +839,6 @@ update_nodes_json() {
832839
run_checks() {
833840
# perform pre-checks here
834841

835-
# get native hostname from remote host due to accurate
836-
# mapping in the future
837-
if ! NATIVE_HOSTNAME="$(${CHECK_HOST_CMD} "hostname")"; then
838-
NATIVE_HOSTNAME="$HOST"
839-
fi
840-
export NATIVE_HOSTNAME
841-
842842
local pghrep_failed_jsons_stack=""
843843

844844
# perform all checks from './resources/checks/' directory

0 commit comments

Comments
 (0)