1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-23 07:18:07 +00:00

Factoring and combining functions

This commit is contained in:
Dan Schaper 2016-11-02 05:34:39 -07:00
parent 7740e4268c
commit a0d9a1133c

View File

@ -23,14 +23,23 @@ is_repo() {
# Use git to check if directory is currently under VCS # Use git to check if directory is currently under VCS
local directory="${1}" local directory="${1}"
cd "${directory}" &> /dev/null || false cd "${directory}" &> /dev/null || false
$(git status --short &> /dev/null) git status --short &> /dev/null
return return
} }
make_repo() { prep_dirs() {
# Prepare directory for local repository building
local dir_to_clean="${1}"
cd "${dir_to_clean}" &> /dev/null || (echo "Unable to prepare directory, please contact support"; exit false)
rm -rf "${dir_to_clean}" &> /dev/null || (echo "Unable to prepare directory, please contact support"; exit false)
}
make_repo() {
# Remove the non-repod interface and clone the interface # Remove the non-repod interface and clone the interface
echo -n "::: Cloning $2 into $1..." local source_repo="${2}"
rm -rf "${1}" local dest_dir="${1}"
echo -n "::: Cloning ${source_repo} into ${dest_dir}..."
rm -rf "${dest_dir}"
git clone -q --depth 1 "${2}" "${1}" > /dev/null || exit 1 git clone -q --depth 1 "${2}" "${1}" > /dev/null || exit 1
echo " done!" echo " done!"
} }
@ -58,14 +67,8 @@ getGitFiles() {
main() { main() {
if ! is_repo "${PI_HOLE_FILES_DIR}"; then #This is unlikely if ! is_repo "${PI_HOLE_FILES_DIR}" && ! is_repo "${ADMIN_INTERFACE_DIR}" ; then #This is unlikely
echo "::: Critical Error: Pi-Hole repo missing from system!" echo "::: Critical Error: One or more Pi-Hole repos are missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
exit 1;
fi
if ! $(is_repo "${ADMIN_INTERFACE_DIR}"); then #This is unlikely
echo "::: Critical Error: Pi-Hole repo missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
exit 1; exit 1;
fi fi