mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 14:18:15 +00:00
make_repo
more defensive.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
1f9b0f7cef
commit
7cceb8615a
@ -133,26 +133,37 @@ fi
|
|||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
is_repo() {
|
is_repo() {
|
||||||
# Use git to check if directory is currently under VCS, return the value
|
# Use git to check if directory is currently under VCS, return the value 128
|
||||||
|
# if directory is not a repo. Return 1 if directory does not exist.
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
if [ -d $directory ]; then
|
local curdir
|
||||||
|
local rc
|
||||||
|
|
||||||
|
curdir="${PWD}"
|
||||||
|
if [[ -d "${directory}" ]]; then
|
||||||
# git -C is not used here to support git versions older than 1.8.4
|
# git -C is not used here to support git versions older than 1.8.4
|
||||||
curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir
|
cd "${directory}"
|
||||||
return $rc
|
git status --short &> /dev/null || rc=$?
|
||||||
else
|
else
|
||||||
# non-zero return code if directory does not exist OR is not a valid git repository
|
# non-zero return code if directory does not exist
|
||||||
return 1
|
rc=1
|
||||||
fi
|
fi
|
||||||
|
cd "${curdir}"
|
||||||
|
return "${rc:-0}"
|
||||||
}
|
}
|
||||||
|
|
||||||
make_repo() {
|
make_repo() {
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
local remoteRepo="${2}"
|
local remoteRepo="${2}"
|
||||||
# Remove the non-repod interface and clone the interface
|
|
||||||
echo -n "::: Cloning $remoteRepo into $directory..."
|
echo -n "::: Cloning ${remoteRepo} into ${directory}..."
|
||||||
|
# Clean out the directory if it exists for git to clone into
|
||||||
|
if [[ -d "${directory}" ]]; then
|
||||||
rm -rf "${directory}"
|
rm -rf "${directory}"
|
||||||
git clone -q --depth 1 "${remoteRepo}" "${directory}" &> /dev/null
|
fi
|
||||||
|
git clone -q --depth 1 "${remoteRepo}" "${directory}" &> /dev/null || return $?
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
update_repo() {
|
update_repo() {
|
||||||
@ -175,8 +186,12 @@ getGitFiles() {
|
|||||||
if is_repo "${directory}"; then
|
if is_repo "${directory}"; then
|
||||||
update_repo "${directory}"
|
update_repo "${directory}"
|
||||||
else
|
else
|
||||||
make_repo "${directory}" "${remoteRepo}"
|
make_repo "${directory}" "${remoteRepo}" || \
|
||||||
|
{ echo "!!! Unable to clone ${remoteRepo} into ${directory}"; \
|
||||||
|
return 1; \
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
find_IPv4_information() {
|
find_IPv4_information() {
|
||||||
@ -1076,8 +1091,8 @@ 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}
|
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || { echo "Unable to clone ${piholeGitUrl}"; exit 1; }
|
||||||
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} || { echo "Unable to clone ${webInterfaceGitUrl}"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user