Skip to content

Commit 0881064

Browse files
committed
move code lower after ssh is resolved with port
1 parent bf9332e commit 0881064

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

bin/ghe-host-check

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@ done
4141
# $GHE_HOSTNAME configured in backup.config when not present.
4242
host="${1:-$GHE_HOSTNAME}"
4343

44-
CLUSTER=false
45-
if ghe-ssh "$host" -- \
46-
"[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then
47-
CLUSTER=true
48-
fi
49-
50-
if "$CLUSTER"; then
51-
node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version)
52-
distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l)
53-
if [ "$distinct_versions" -ne 1 ]; then
54-
echo "$node_version_list" 1>&2
55-
echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
56-
exit 1
57-
fi
58-
fi
59-
6044
# Options to pass to SSH during connection check
6145
options="
6246
-o PasswordAuthentication=no
@@ -100,6 +84,23 @@ if [ $rc -ne 0 ]; then
10084
exit $rc
10185
fi
10286

87+
CLUSTER=false
88+
if ghe-ssh "$host" -- \
89+
"[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then
90+
CLUSTER=true
91+
fi
92+
93+
# ensure all nodes in the cluster are running the same version
94+
if "$CLUSTER"; then
95+
node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version)
96+
distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l)
97+
if [ "$distinct_versions" -ne 1 ]; then
98+
echo "$node_version_list" 1>&2
99+
echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
100+
exit 1
101+
fi
102+
fi
103+
103104
version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}')
104105

105106
if [ -z "$version" ]; then

0 commit comments

Comments
 (0)