From a293b5a3718f3381f9f9fd2cc955127d062e1a99 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Jul 2017 22:49:06 +0100 Subject: [PATCH] prevent `./automated install/basic-install.sh: line 1886: /usr/bin/pihole-FTL: No such file or directory` on new install, or if pihole-FTL is missing for whatever reason. Signed-off-by: Adam Warner --- automated install/basic-install.sh | 38 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f0d6018f..170754f2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1883,25 +1883,35 @@ FTLdetect() { #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 echo -e " ${INFO} Checking for existing FTL binary..." - local FTLversion=$(/usr/bin/pihole-FTL tag) - local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n') - if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then - # Install FTL - FTLinstall "${binary}" || return 1 - else - echo -e " ${INFO} Latest FTL Binary already installed (${FTLlatesttag}). Confirming Checksum..." + local ftlLoc=$(which pihole-FTL) - local remoteSha1=$(curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${FTLversion%$'\r'}/${binary}.sha1" | cut -d ' ' -f 1) - local localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1) + if [[ ${ftlLoc} ]]; then + local FTLversion=$(/usr/bin/pihole-FTL tag) + local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n') - if [[ "${remoteSha1}" != "${localSha1}" ]]; then - echo -e " ${INFO} Corruption detected..." - FTLinstall "${binary}" || return 1 + if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then + # Install FTL + FTLinstall "${binary}" || return 1 else - echo -e " ${INFO} Checksum correct. No need to download!" + echo -e " ${INFO} Latest FTL Binary already installed (${FTLlatesttag}). Confirming Checksum..." + + local remoteSha1=$(curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${FTLversion%$'\r'}/${binary}.sha1" | cut -d ' ' -f 1) + local localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1) + + if [[ "${remoteSha1}" != "${localSha1}" ]]; then + echo -e " ${INFO} Corruption detected..." + FTLinstall "${binary}" || return 1 + else + echo -e " ${INFO} Checksum correct. No need to download!" + fi fi - fi + else + # Install FTL + FTLinstall "${binary}" || return 1 + fi + + } main() {