Use git diff to determine if code has changed (no need to run the installer if it hasn't changed at all)

This commit is contained in:
DL6ER 2017-03-11 16:24:13 +01:00
parent 1d60b62e7a
commit febdb4a190
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -9,13 +9,15 @@
# Please see LICENSE file for your rights under this license. # Please see LICENSE file for your rights under this license.
readonly PI_HOLE_FILES_DIR="/etc/.pihole" readonly PI_HOLE_FILES_DIR="/etc/.pihole"
PH_TEST="true" source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh PH_TEST="true" source "${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh"
# webInterfaceGitUrl set in basic-install.sh # webInterfaceGitUrl set in basic-install.sh
# webInterfaceDir set in basic-install.sh # webInterfaceDir set in basic-install.sh
# piholeGitURL set in basic-install.sh # piholeGitURL set in basic-install.sh
# is_repo() sourced from basic-install.sh # is_repo() sourced from basic-install.sh
update=false
fully_fetch_repo() { fully_fetch_repo() {
# Add upstream branches to shallow clone # Add upstream branches to shallow clone
local directory="${1}" local directory="${1}"
@ -64,6 +66,10 @@ checkout_pull_branch() {
local branch="${2}" local branch="${2}"
cd "${directory}" || return 1 cd "${directory}" || return 1
if [ "$(git diff "${branch}" | grep -c "^")" -gt "0" ]; then
update=true
fi
git checkout "${branch}" || return 1 git checkout "${branch}" || return 1
git pull || return 1 git pull || return 1
return 0 return 0
@ -169,9 +175,9 @@ checkout()
fi fi
# Force updating everything # Force updating everything
if [[ ! "${1}" == "web" ]]; then if [[ ! "${1}" == "web" && ${update} ]]; then
echo "::: Running installer to upgrade your installation" echo "::: Running installer to upgrade your installation"
if ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended; then if "${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh" --unattended; then
exit 0 exit 0
else else
echo "Unable to complete update, contact Pi-hole" echo "Unable to complete update, contact Pi-hole"