Skip to content

Commit 42cc0cb

Browse files
tonytrgchuckp22
andauthored
removing wrong error output (#591)
* removing wrong error output * fix host-check output * refactor echo --------- Co-authored-by: Chuck Pathanjali <[email protected]>
1 parent 99db4a8 commit 42cc0cb

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

bin/ghe-host-check

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ if [ -z "$supported" ]; then
151151
fi
152152

153153
if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then
154-
cat << SKIP_MSG 1>&2
154+
cat << SKIP_MSG
155155
**You can disable the following storage & version checks by running ghe-backup with option "--skip-checks"
156156
OR updating GHE_SKIP_CHECKS to 'true' in your backup.config file.
157157
@@ -176,10 +176,10 @@ SKIP_MSG
176176
fi
177177

178178
#Display dir requirements for repositories and mysql
179-
echo "" 1>&2
180-
echo "Checking host for sufficient space for a backup..." 1>&2
179+
echo -e "\n"
180+
echo "Checking host for sufficient space for a backup..."
181181
available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}')
182-
echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2
182+
echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time."
183183

184184
repos_disk_size=$(transfer_size repositories /tmp)
185185
pages_disk_size=$(transfer_size pages /tmp)
@@ -192,10 +192,10 @@ SKIP_MSG
192192

193193
min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size))
194194
recommended_disk_req=$((min_disk_req * 5))
195-
echo " - Available space: $((available_space / (1024 ** 2))) MB" 1>&2
196-
echo " - Min Disk required for this backup is at least $min_disk_req MB" 1>&2
197-
echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2
198-
echo "" 1>&2
195+
echo " - Available space: $((available_space / (1024 ** 2))) MB"
196+
echo " - Min Disk required for this backup is at least $min_disk_req MB"
197+
echo " - Recommended Disk requirement is $recommended_disk_req MB"
198+
echo -e "\n"
199199

200200
printf '### Estimated Data Transfer Sizes
201201
@@ -208,7 +208,7 @@ SKIP_MSG
208208
- actions: %d MB
209209
- mssql: %d MB
210210
\n' \
211-
"$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" 1>&2
211+
"$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size"
212212

213213
if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then
214214
echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2
@@ -231,7 +231,7 @@ SKIP_MSG
231231
exit 1
232232
fi
233233

234-
echo "### Software versions" 1>&2
234+
echo "### Software versions"
235235
rsync_version=$(rsync --version | grep 'version' | awk '{print $3}' | tr -cd '[:digit:].\n')
236236
if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then
237237
echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2
@@ -241,17 +241,17 @@ SKIP_MSG
241241
printf "\n **WARNING:** rsync version %s on backup host is less than 3.2.5, which could result in performance degradation.
242242
For more details, please read documentation at https://gh.io/april-2023-update-of-rsync-requirements
243243
You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.\n\n" \
244-
"$rsync_version" 1>&2
244+
"$rsync_version"
245245
fi
246-
echo " - rsync ${rsync_version} >= required ($min_rsync)" 1>&2
246+
echo " - rsync ${rsync_version} >= required ($min_rsync)"
247247

248248
ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n')
249249
if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then
250250
echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2
251251
echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2
252252
exit 1
253253
else
254-
echo " - openSSH ${ssh_version} >= required ($min_openssh)" 1>&2
254+
echo " - openSSH ${ssh_version} >= required ($min_openssh)"
255255
fi
256256

257257
jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n')
@@ -260,8 +260,8 @@ SKIP_MSG
260260
echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2
261261
exit 1
262262
else
263-
echo " - jq ${jq_version} >= required ($min_jq)" 1>&2
263+
echo " - jq ${jq_version} >= required ($min_jq)"
264264
fi
265265
fi
266-
echo "" 1>&2
266+
echo -e "\n"
267267
echo "Connect $hostname:$port OK (v$version)"

share/github-backup-utils/ghe-backup-config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,15 @@ ghe_remote_version_required() {
422422
if [ -z "$GHE_REMOTE_VERSION" ]; then
423423
_out=$(ghe-host-check "$@")
424424
echo "$_out"
425+
_out_hostname=$(echo "$_out" | tail -n 1)
425426

426427
# override hostname w/ ghe-host-check output because the port could have
427428
# been autodetected to 122.
428-
GHE_HOSTNAME="${_out/Connect /}"
429+
GHE_HOSTNAME="${_out_hostname/Connect /}"
429430
GHE_HOSTNAME="${GHE_HOSTNAME/ OK*/}"
430431
export GHE_HOSTNAME
431432

432-
GHE_REMOTE_VERSION="${_out#*\(}"
433+
GHE_REMOTE_VERSION="${_out_hostname#*\(}"
433434
GHE_REMOTE_VERSION="${GHE_REMOTE_VERSION%%\)*}"
434435
export GHE_REMOTE_VERSION
435436

0 commit comments

Comments
 (0)