From d9528dfd0967cb947f42ef6ab0e3d6721c9f71d1 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 2 Nov 2016 00:51:38 -0700 Subject: [PATCH] Bash is funny with returns. --- advanced/Scripts/update.sh | 10 +++++++--- automated install/basic-install.sh | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index fd67a484..8531dc2c 100644 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -25,7 +25,7 @@ is_repo() { local gitRepo=0 echo -n "::: Checking if ${directory} is a repo... " cd "${directory}" &> /dev/null || return 1 - if [[ $(git status --short > /dev/null) ]]; then + if [[ $(git status --short &> /dev/null) ]]; then echo "OK" else echo "not found!" @@ -63,12 +63,16 @@ getGitFiles() { fi } -if [ ! -d "/etc/.pihole" ]; then #This is unlikely + +is_repo "${PI_HOLE_FILES_DIR}" &> /dev/null +if [[ $? -eq 1 ]]; then #This is unlikely echo "::: Critical Error: Pi-Hole repo missing from system!" echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" exit 1; fi -if [ ! -d "/var/www/html/admin" ]; then #This is unlikely + +is_repo "${ADMIN_INTERFACE_DIR}" &> /dev/null +if [[ $? -eq 1 ]]; then #This is unlikely echo "::: Critical Error: Pi-Hole repo missing from system!" echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" exit 1; diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ea1fb8d9..49329f5a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -73,7 +73,7 @@ fi # Compatibility -if [ -x "$(command -v apt-get)" ]; then +if [[ $(command -v apt-get) ]]; then #Debian Family ############################################# PKG_MANAGER="apt-get" @@ -99,9 +99,9 @@ if [ -x "$(command -v apt-get)" ]; then package_check_install() { dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "${1}" } -elif [ -x "$(command -v rpm)" ]; then +elif [ $(command -v rpm) ]; then # Fedora Family - if [ -x "$(command -v dnf)" ]; then + if [ $(command -v dnf) ]; then PKG_MANAGER="dnf" else PKG_MANAGER="yum"