mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-24 07:03:43 +00:00
Change FTLcheckUpdate logic
- execute `curl` in a separate step - use api.github.com and `jq` to retrieve tag_name - check if current FTL version is less than latest - show error message if return is empty (curl failed) Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
parent
2dd31ce6ee
commit
1f0eb734d9
1 changed files with 17 additions and 3 deletions
|
@ -2442,15 +2442,23 @@ FTLcheckUpdate() {
|
|||
if [[ ${ftlLoc} ]]; then
|
||||
local FTLversion
|
||||
FTLversion=$(/usr/bin/pihole-FTL tag)
|
||||
local FTLlatesttag
|
||||
|
||||
if ! FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep --color=never -i Location: | awk -F / '{print $NF}' | tr -d '[:cntrl:]'); then
|
||||
local FTLlatesttag
|
||||
FTLlatesttag=$(curl -s https://api.github.com/repos/pi-hole/FTL/releases/latest | jq -sRr 'fromjson? | .tag_name | values')
|
||||
|
||||
if [ -z "${FTLlatesttag}" ]; then
|
||||
# There was an issue while retrieving the latest version
|
||||
printf " %b Failed to retrieve latest FTL release metadata" "${CROSS}"
|
||||
return 3
|
||||
fi
|
||||
|
||||
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
|
||||
# Convert version strings into numbers for comparison
|
||||
local convertedFTLversion convertedFTLlatesttag
|
||||
convertedFTLversion="$(VersionConverter "${FTLversion}")"
|
||||
convertedFTLlatesttag="$(VersionConverter "${FTLlatesttag}")"
|
||||
|
||||
if [[ "${convertedFTLversion}" -lt "${convertedFTLlatesttag}" ]]; then
|
||||
# FTL is out of date
|
||||
return 0
|
||||
else
|
||||
printf " %b Latest FTL Binary already installed (%s). Confirming Checksum...\\n" "${INFO}" "${FTLlatesttag}"
|
||||
|
@ -2502,6 +2510,12 @@ copy_to_install_log() {
|
|||
chmod 644 "${installLogLoc}"
|
||||
}
|
||||
|
||||
# converts a given version string e.g. v3.7.1 to 3007001000 to allow for easier comparison of multi digit version numbers
|
||||
# credits https://apple.stackexchange.com/a/123408
|
||||
VersionConverter() {
|
||||
echo "$@" | tr -d '[:alpha:]' | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
|
||||
}
|
||||
|
||||
main() {
|
||||
######## FIRST CHECK ########
|
||||
# Must be root to install
|
||||
|
|
Loading…
Reference in a new issue