From b207ceeab2e485a03a2b3451b59b2d1a1d80e2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 27 Jul 2020 17:01:55 +0200 Subject: [PATCH 1/2] Report and exit if dig supportedOS returns nothing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1bbfd7c4..d1a74b40 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -190,24 +190,29 @@ os_check() { IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net | tr -d '"') - for i in "${supportedOS[@]}" - do - os_part=$(echo "$i" | cut -d '=' -f1) - versions_part=$(echo "$i" | cut -d '=' -f2-) - - if [[ "${detected_os}" =~ ${os_part} ]]; then - valid_os=true - IFS="," read -r -a supportedVer <<<"${versions_part}" - for x in "${supportedVer[@]}" - do - if [[ "${detected_version}" =~ $x ]];then - valid_version=true + if [ -z "$supportedOS" ]; then + printf " %b %bRetrieval of supported OS failed. Please contact support. %b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" + exit 1 + else + for i in "${supportedOS[@]}" + do + os_part=$(echo "$i" | cut -d '=' -f1) + versions_part=$(echo "$i" | cut -d '=' -f2-) + + if [[ "${detected_os}" =~ ${os_part} ]]; then + valid_os=true + IFS="," read -r -a supportedVer <<<"${versions_part}" + for x in "${supportedVer[@]}" + do + if [[ "${detected_version}" =~ $x ]];then + valid_version=true + break + fi + done break - fi + fi done - break - fi - done + fi if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then display_warning=false From 6fc7dc28a2c8966549d67523dcfc3f40317e092d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 28 Jul 2020 10:25:57 +0200 Subject: [PATCH 2/2] Count elements of array instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d1a74b40..a4c93391 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -190,7 +190,7 @@ os_check() { IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net | tr -d '"') - if [ -z "$supportedOS" ]; then + if [ ${#supportedOS[@]} -eq 0 ]; then printf " %b %bRetrieval of supported OS failed. Please contact support. %b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" exit 1 else