FTL checkout: Check for availability of branches before trying to download from the webserver. Also, fix check_download_exists() possibly killing the script on non-availability of requested branches

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-08-26 06:11:42 +02:00
parent a302d7b5d7
commit 9e9c985245
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD
3 changed files with 39 additions and 23 deletions

View file

@ -16,10 +16,9 @@
#
# curl -sSL https://install.pi-hole.net | bash
# -e option instructs bash to immediately exit if any command [1] has a non-zero
# exit status We do not want users to end up with a partially working install,
# so we exit the script instead of continuing the installation with something
# broken
# -e option instructs bash to immediately exit if any command [1] has a non-zero exit status
# We do not want users to end up with a partially working install, so we exit the script
# instead of continuing the installation with something broken
set -e
# Append common folders to the PATH to ensure that all basic commands are available.
@ -1694,7 +1693,7 @@ update_dialogs() {
check_download_exists() {
# Check if the download exists and we can reach the server
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
local status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
# Check the status code
if grep -q "200" <<<"$status"; then
@ -2012,14 +2011,12 @@ FTLcheckUpdate() {
# Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
# shellcheck disable=SC1090
check_download_exists "$path"
local ret=$?
if [ $ret -ne 0 ]; then
if [[ $ret -eq 1 ]]; then
if ! check_download_exists "$path"; then
if [ $? -eq 1 ]; then
printf " %b Branch \"%s\" is not available.\\n" "${INFO}" "${ftlBranch}"
printf " %b Use %bpihole checkout ftl [branchname]%b to switch to a valid branch.\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
return 2
elif [[ $ret -eq 2 ]]; then
elif [ $? -eq 2 ]; then
printf " %b Unable to download from ftl.pi-hole.net. Please check your Internet connection and try again later.\\n" "${CROSS}"
return 3
else