installer: exit if FTL update check fails

The return code of `FTLdetect()` is used in the installer to know whether FTL has been installed or not.

The function however returns an error only, if the download of FTL fails, not if checking for a latest version/update of FTL fails. This way, installs and rapairs can continue without or with ourdated FTL until `pihole-FTL migrate v6`, which hangs endlessly, if it is a v5 FTL.

This commit handles the return code in `FTLdetect()`, and lets it return true only if FTL download succeeded, or if the update check succeeded and FTL is up-to-date. Else, it could neither be repaired, nor installed, and the error message should give a hint what went wrong, hence exit.

`FTLdetect()` is not called by any other script, hence this change has no surprising effect elsewhere.

Additionally, a syntax error in the `FTLcheckUpdate()` function itself is fixed, which masks the `check_download_exists()` return code, hence always leads to error code 4, if the FTL branch is not `master`.

Signed-off-by: MichaIng <micha@dietpi.com>
This commit is contained in:
MichaIng
2025-06-26 00:40:37 +02:00
parent ec892ec096
commit 3a35e589f2

View File

@@ -1940,8 +1940,8 @@ FTLcheckUpdate() {
path="${ftlBranch}/${binary}"
# Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
local status
if ! check_download_exists "$path"; then
local status
status=$?
if [ "${status}" -eq 1 ]; then
printf " %b Branch \"%s\" is not available.\\n" "${INFO}" "${ftlBranch}"
@@ -2031,6 +2031,11 @@ FTLdetect() {
if FTLcheckUpdate "${1}"; then
FTLinstall "${1}" || return 1
else
case $? in
1) :;; # FTL is up-to-date
*) exit 1;; # 404 (2), other HTTP or curl error (3), unknown (4)
esac
fi
}