Skip to content

Commit 56e88a9

Browse files
authored
Merge pull request #406 from github/xn4p4lm-host-check-formatting-update
Update formatting on `ghe-host-check` to improve readability
2 parents a5398a0 + 4c4677a commit 56e88a9

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

bin/ghe-host-check

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ SKIP_MSG
163163
. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size"
164164

165165
#Display dir requirements for repositories and mysql
166+
echo "" 1>&2
166167
echo "Checking host for sufficient space for a backup..." 1>&2
167168
available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}')
168-
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
169+
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
169170

170171
repos_disk_size=$(transfer_size repositories /tmp)
171172
pages_disk_size=$(transfer_size pages /tmp)
@@ -177,21 +178,22 @@ SKIP_MSG
177178
mssql_disk_size=$(transfer_size mssql /tmp)
178179

179180
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))
180-
echo "Available space: $((available_space / (1024 ** 2))) MB" 1>&2
181-
echo -e "Min Disk required for this backup is at least $min_disk_req MB\n" 1>&2
182-
183-
cat <<DATA_TRANSFER_SIZE 1>&2
184-
### Data Transfer Sizes
185-
repositories: $repos_disk_size MB
186-
pages: $pages_disk_size MB
187-
elasticsearch: $es_disk_size MB
188-
storage: $stor_disk_size MB
189-
minio: $minio_disk_size MB
190-
mysql: $mysql_disk_size MB
191-
actions: $actions_disk_size MB
192-
mssql: $mssql_disk_size MB
193-
194-
DATA_TRANSFER_SIZE
181+
recommended_disk_req=$((min_disk_req * 5))
182+
echo " - Available space: $((available_space / (1024 ** 2))) MB" 1>&2
183+
echo " - Min Disk required for this backup is at least $min_disk_req MB" 1>&2
184+
echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2
185+
echo "" 1>&2
186+
187+
printf '### Data Transfer Sizes
188+
- repositories: %d MB
189+
- pages: %d MB
190+
- elasticsearch: %d MB
191+
- storage: %d MB
192+
- minio: %d MB
193+
- mysql: %d MB
194+
- actions: %d MB
195+
- mssql: %d MB\n' \
196+
"$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
195197

196198
if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then
197199
echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2
@@ -221,24 +223,20 @@ DATA_TRANSFER_SIZE
221223
echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2
222224
exit 1
223225
elif [[ $rsync_version < 3.2.5 ]] && [[ $RSYNC_WARNING != "no" ]]; then
224-
cat << WARN_MSG 1>&2
225-
**WARNING:** rsync version $rsync_version on backup host is less than 3.2.5, which could result in performance degradation.
226-
227-
For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements
228-
229-
You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.
230-
231-
WARN_MSG
226+
printf "\n **WARNING:** rsync version %s on backup host is less than 3.2.5, which could result in performance degradation.
227+
For more details, please read documentation at https://gh.io/april-2023-update-of-rsync-requirements
228+
You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.\n\n" \
229+
"$rsync_version" 1>&2
232230
fi
233-
echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2
231+
echo " - rsync ${rsync_version} >= required ($min_rsync)" 1>&2
234232

235233
ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n')
236234
if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then
237235
echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2
238236
echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2
239237
exit 1
240238
else
241-
echo "openSSH ${ssh_version} >= required ($min_openssh)" 1>&2
239+
echo " - openSSH ${ssh_version} >= required ($min_openssh)" 1>&2
242240
fi
243241

244242
jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n')
@@ -247,8 +245,8 @@ WARN_MSG
247245
echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2
248246
exit 1
249247
else
250-
echo "jq ${jq_version} >= required ($min_jq)" 1>&2
248+
echo " - jq ${jq_version} >= required ($min_jq)" 1>&2
251249
fi
252250
fi
253-
251+
echo "" 1>&2
254252
echo "Connect $hostname:$port OK (v$version)"

0 commit comments

Comments
 (0)