Add checking for availability of ftl.pi-hole.net when using FTL from a custom branch. If the server is down (or the user is offline, cannot resolve the domain, etc.), we fail early and hard instead of possibly corrupting the installation
echo -e "${INFO} FTL:\\t\\t${COL_LIGHT_RED}Branch is not available.${COL_NC}\\n\\t\\t\\tUse ${COL_LIGHT_GREEN}pihole checkout ftl [branchname]${COL_NC} to switch to a valid branch."
# Check if the download exists and we can reach the server
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}"| head -n 1)
if grep -q "404"<<<"$status";then
return1
else
# Check the status code
if grep -q "200"<<<"$status";then
return0
elif grep -q "404"<<<"$status";then
return1
fi
# Other error or no status code at all, e.g., no Internet, server not
# available/reachable, ...
return2
}
fully_fetch_repo(){
@ -1957,10 +1964,8 @@ get_binary_name() {
}
FTLcheckUpdate(){
#In the next section we check to see if FTL is already installed (in case of pihole -r).
#If the installed version matches the latest version, then check the installed sha1sum of the binary vs the remote sha1sum. If they do not match, then download
printf" %b Checking for existing FTL binary...\\n""${INFO}"
# In the next section we check to see if FTL is already installed (in case of pihole -r).
# If the installed version matches the latest version, then check the installed sha1sum of the binary vs the remote sha1sum. If they do not match, then download
local ftlLoc
ftlLoc=$(command -v pihole-FTL 2>/dev/null)
@ -1979,14 +1984,24 @@ FTLcheckUpdate() {
local localSha1
if[[ ! "${ftlBranch}"=="master"]];then
#Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
#Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
local path
path="${ftlBranch}/${binary}"
# shellcheck disable=SC1090
if ! check_download_exists "$path";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}"
return2
check_download_exists "$path"
localret=$?
if[$ret -ne 0];then
if[[$ret -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}"
return2
elif[[$ret -eq 2]];then
printf" %b Unable to download from ftl.pi-hole.net. Please check your Internet connection and try again later.\\n""${CROSS}"