mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Defensive git cloning
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
7cceb8615a
commit
ad07655630
1 changed files with 19 additions and 12 deletions
|
@ -168,12 +168,16 @@ make_repo() {
|
||||||
|
|
||||||
update_repo() {
|
update_repo() {
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
|
|
||||||
# Pull the latest commits
|
# Pull the latest commits
|
||||||
echo -n "::: Updating repo in $1..."
|
echo -n "::: Updating repo in ${1}..."
|
||||||
cd "${directory}" || exit 1
|
if [[ -d "${directory}" ]]; then
|
||||||
git stash -q &> /dev/null
|
cd "${directory}"
|
||||||
git pull -q &> /dev/null
|
git stash -q &> /dev/null || true # Okay for stash failure
|
||||||
|
git pull -q &> /dev/null || return $?
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getGitFiles() {
|
getGitFiles() {
|
||||||
|
@ -184,12 +188,9 @@ getGitFiles() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking for existing repository..."
|
echo "::: Checking for existing repository..."
|
||||||
if is_repo "${directory}"; then
|
if is_repo "${directory}"; then
|
||||||
update_repo "${directory}"
|
update_repo "${directory}" || return 1
|
||||||
else
|
else
|
||||||
make_repo "${directory}" "${remoteRepo}" || \
|
make_repo "${directory}" "${remoteRepo}" || return 1
|
||||||
{ echo "!!! Unable to clone ${remoteRepo} into ${directory}"; \
|
|
||||||
return 1; \
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1091,8 +1092,14 @@ main() {
|
||||||
echo "::: --reconfigure passed to install script. Not downloading/updating local repos"
|
echo "::: --reconfigure passed to install script. Not downloading/updating local repos"
|
||||||
else
|
else
|
||||||
# Get Git files for Core and Admin
|
# Get Git files for Core and Admin
|
||||||
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || { echo "Unable to clone ${piholeGitUrl}"; exit 1; }
|
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || \
|
||||||
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} || { echo "Unable to clone ${webInterfaceGitUrl}"; exit 1; }
|
{ echo "!!! Unable to clone ${piholeGitUrl} into ${PI_HOLE_LOCAL_REPO}, unable to continue."; \
|
||||||
|
exit 1; \
|
||||||
|
}
|
||||||
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} || \
|
||||||
|
{ echo "!!! Unable to clone ${webInterfaceGitUrl} into ${webInterfaceDir}, unable to continue."; \
|
||||||
|
exit 1; \
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
|
|
Loading…
Reference in a new issue