From 74eb8c8622ef701aad3d509bf88d9d7e3c6ceb40 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 22 May 2017 23:43:52 +0200 Subject: [PATCH 1/2] Change directory before trying to reset repository. Fixes #1489 --- automated install/basic-install.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5d893067..2f4459d4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -220,6 +220,19 @@ getGitFiles() { return 0 } +resetRepo() { + local directory="${1}" + local curdir + + curdir="${PWD}" + cd "${directory}" &> /dev/null || return 1 + echo -n "::: Resetting repo in ${1}..." + git reset --hard &> /dev/null || return $? + echo " done!" + cd "${curdir}" &> /dev/null || return 1 + return 0 +} + find_IPv4_information() { local route # Find IP used to route to outside world @@ -1182,7 +1195,16 @@ update_dialogs() { clone_or_update_repos() { if [[ "${reconfigure}" == true ]]; then echo "::: --reconfigure passed to install script. Resetting changes to local repos" - git reset --hard + resetRepo ${PI_HOLE_LOCAL_REPO} || \ + { echo "!!! Unable to reset ${PI_HOLE_LOCAL_REPO}, unable to continue."; \ + exit 1; \ + } + if [[ ${INSTALL_WEB} == true ]]; then + resetRepo ${webInterfaceDir} || \ + { echo "!!! Unable to reset ${webInterfaceDir}, unable to continue."; \ + exit 1; \ + } + fi else # Get Git files for Core and Admin getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || \ From 5004cf331abf54a80c12109ecc5f8f80538686f5 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 22 May 2017 15:36:51 -0700 Subject: [PATCH 2/2] No need to `cd $PWD` as it doesn't affect flow of caller script. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2f4459d4..ebf93f4a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -222,14 +222,11 @@ getGitFiles() { resetRepo() { local directory="${1}" - local curdir - curdir="${PWD}" cd "${directory}" &> /dev/null || return 1 echo -n "::: Resetting repo in ${1}..." git reset --hard &> /dev/null || return $? echo " done!" - cd "${curdir}" &> /dev/null || return 1 return 0 }