mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Take echos out of utility functions and move up a level.
This commit is contained in:
parent
34be601dd7
commit
b8a5ed710e
1 changed files with 9 additions and 6 deletions
|
@ -22,6 +22,7 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
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
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
|
|
||||||
git -C "${directory}" status --short &> /dev/null
|
git -C "${directory}" status --short &> /dev/null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -29,18 +30,18 @@ is_repo() {
|
||||||
prep_dirs() {
|
prep_dirs() {
|
||||||
# Prepare directory for local repository building
|
# Prepare directory for local repository building
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
|
|
||||||
rm -rf "${directory}" &> /dev/null
|
rm -rf "${directory}" &> /dev/null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
make_repo() {
|
make_repo() {
|
||||||
# Remove the non-repod interface and clone the interface
|
# Remove the non-repod interface and clone the interface
|
||||||
local source_repo="${2}"
|
local remoteRepo="${2}"
|
||||||
local dest_dir="${1}"
|
local directory="${1}"
|
||||||
|
|
||||||
echo -n "::: Cloning ${source_repo} into ${dest_dir}..."
|
if ! (prep_dirs "${directory}" && git clone -q --depth 1 "${remoteRepo}" "${directory}" > /dev/null); then \
|
||||||
if (prep_dirs "${dest_dir}" && git clone -q --depth 1 "${source_repo}" "${dest_dir}" > /dev/null); then \
|
return false
|
||||||
echo " done!" || (echo "Unable to clone repository, please contact support"; exit false)
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,9 @@ getGitFiles() {
|
||||||
if is_repo "${directory}"; then
|
if is_repo "${directory}"; then
|
||||||
update_repo "${directory}" || (echo "*** Error: Could not update local repository. Contact support."; exit 1)
|
update_repo "${directory}" || (echo "*** Error: Could not update local repository. Contact support."; exit 1)
|
||||||
else
|
else
|
||||||
make_repo "${directory}" "${remoteRepo}"
|
echo -n "::: Cloning ${remoteRepo} into ${directory}..."
|
||||||
|
make_repo "${directory}" "${remoteRepo}" || (echo "Unable to clone repository, please contact support"; exit 1)
|
||||||
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue