Skip to content

Commit e64002d

Browse files
ggtrdggtrd
authored andcommitted
1.0.12 exit on repository reachability failed check
1 parent 9621867 commit e64002d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

bashpack.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727

28-
export VERSION="1.0.11"
28+
export VERSION="1.0.12"
2929

3030
export NAME="Bashpack"
3131
export NAME_LOWERCASE=$(echo "$NAME" | tr A-Z a-z)
@@ -430,8 +430,12 @@ check_repository_reachability() {
430430
# Need to be improved to all 1**, 2** and 3** codes.
431431
if [[ $http_code -eq 200 ]]; then
432432
echo "Success! HTTP status code $http_code. Repository is reachable."
433+
elif [ -z $http_code ]; then
434+
echo "Error: HTTP status code not found. Repository is not reachable."
435+
exit
433436
else
434437
echo "Error: HTTP status code $http_code. Repository is not reachable."
438+
exit
435439
fi
436440
}
437441
export -f check_repository_reachability
@@ -453,7 +457,7 @@ download_cli() {
453457
rm -rf $archive_dir_tmp
454458
mkdir $archive_dir_tmp
455459

456-
460+
457461
# Download source scripts
458462
# Testing if repository is reachable with HTTP before doing anything.
459463
if ! check_repository_reachability | grep -q 'Error:'; then
@@ -475,9 +479,9 @@ download_cli() {
475479
else
476480
error_file_not_downloaded $archive_url
477481
fi
478-
# else
479-
# # Just call again the same function to get its error message
480-
# check_repository_reachability
482+
else
483+
# Just call again the same function to get its error message
484+
check_repository_reachability
481485
fi
482486

483487
}
@@ -661,7 +665,7 @@ update_cli() {
661665
# # To avoid broken installations, before deleting anything, testing if downloaded archive is a working tarball.
662666
# # (archive is deleted in create_cli, which is called after in the process)
663667
# # if ! $NAME_LOWERCASE verify -d | grep -q 'Error:'; then
664-
if ! check_repository_reachability | grep -q 'Error:'; then
668+
# if ! check_repository_reachability | grep -q 'Error:'; then
665669

666670
# Download latest available version
667671
download_cli "$URL/tarball" $archive_tmp $archive_dir_tmp
@@ -671,9 +675,10 @@ update_cli() {
671675

672676
# Execute the install_cli function of the script downloaded in /tmp
673677
exec "$archive_dir_tmp/$NAME_LOWERCASE.sh" -i
674-
else
675-
error_tarball_non_working $archive_tmp
676-
fi
678+
# else
679+
# # error_tarball_non_working $archive_tmp
680+
# check_repository_reachability
681+
# fi
677682
fi
678683
}
679684

0 commit comments

Comments
 (0)