1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-01-03 12:40:56 +00:00

Rearrange pull logic, some optimization.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
Dan Schaper 2017-03-10 11:25:35 -08:00
parent d5b88e0df8
commit 41e1e4cb68
No known key found for this signature in database
GPG Key ID: 572E999E385B7BFC

View File

@ -93,6 +93,23 @@ checkout()
exit 1 exit 1
fi fi
if [[ "${1}" == "dev" ]] ; then
# Shortcut to check out development branches
echo "::: Shortcut \"dev\" detected - checking out development / devel branches ..."
echo "::: Pi-hole core"
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo "Unable to pull Core developement branch"; exit 1; }
echo "::: Web interface"
checkout_pull_branch "${webInterfaceDir}" "devel" || { echo "Unable to pull Web development branch"; exit 1; }
echo "::: done!"
elif [[ "${1}" == "master" ]] ; then
# Shortcut to check out master branches
echo "::: Shortcut \"master\" detected - checking out master branches ..."
echo "::: Pi-hole core"
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo "Unable to pull Core master branch"; exit 1; }
echo "::: Web interface"
checkout_pull_branch "${webInterfaceDir}" "master" || { echo "Unable to pull web master branch"; exit 1; }
echo "::: done!"
elif [[ "${1}" == "core" ]] ; then
echo -n "::: Fetching remote branches for Pi-hole core from ${piholeGitUrl} ... " echo -n "::: Fetching remote branches for Pi-hole core from ${piholeGitUrl} ... "
if ! fully_fetch_repo "${PI_HOLE_FILES_DIR}" ; then if ! fully_fetch_repo "${PI_HOLE_FILES_DIR}" ; then
echo "::: Fetching all branches for Pi-hole core repo failed!" echo "::: Fetching all branches for Pi-hole core repo failed!"
@ -102,34 +119,6 @@ checkout()
echo " done!" echo " done!"
echo "::: ${#corebranches[@]} branches available" echo "::: ${#corebranches[@]} branches available"
echo ":::" echo ":::"
echo -n "::: Fetching remote branches for the web interface from ${webInterfaceGitUrl} ... "
if ! fully_fetch_repo "${webInterfaceDir}" ; then
echo "::: Fetching all branches for Pi-hole web interface repo failed!"
exit 1
fi
webbranches=($(get_available_branches "${webInterfaceDir}"))
echo " done!"
echo "::: ${#webbranches[@]} branches available"
echo ":::"
if [[ "${1}" == "dev" ]] ; then
# Shortcut to check out development branches
echo "::: Shortcut \"dev\" detected - checking out development / devel branches ..."
echo "::: Pi-hole core"
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development"
echo "::: Web interface"
checkout_pull_branch "${webInterfaceDir}" "devel"
echo "::: done!"
elif [[ "${1}" == "master" ]] ; then
# Shortcut to check out master branches
echo "::: Shortcut \"master\" detected - checking out master branches ..."
echo "::: Pi-hole core"
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master"
echo "::: Web interface"
checkout_pull_branch "${webInterfaceDir}" "master"
echo "::: done!"
elif [[ "${1}" == "core" ]] ; then
# Have to user chosing the branch he wants # Have to user chosing the branch he wants
if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
echo "::: Requested branch \"${2}\" is not available!" echo "::: Requested branch \"${2}\" is not available!"
@ -139,6 +128,15 @@ checkout()
fi fi
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${2}" checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${2}"
elif [[ "${1}" == "web" ]] ; then elif [[ "${1}" == "web" ]] ; then
echo -n "::: Fetching remote branches for the web interface from ${webInterfaceGitUrl} ... "
if ! fully_fetch_repo "${webInterfaceDir}" ; then
echo "::: Fetching all branches for Pi-hole web interface repo failed!"
exit 1
fi
webbranches=($(get_available_branches "${webInterfaceDir}"))
echo " done!"
echo "::: ${#webbranches[@]} branches available"
echo ":::"
# Have to user chosing the branch he wants # Have to user chosing the branch he wants
if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
echo "::: Requested branch \"${2}\" is not available!" echo "::: Requested branch \"${2}\" is not available!"
@ -153,6 +151,7 @@ checkout()
fi fi
# Force updating everything # Force updating everything
if [[ ! "${1}" == "web" ]]; then
echo "::: Running installer to upgrade your installation" echo "::: Running installer to upgrade your installation"
if ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended; then if ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended; then
exit 0 exit 0
@ -160,5 +159,6 @@ checkout()
echo "Unable to complete update, contact Pi-hole" echo "Unable to complete update, contact Pi-hole"
exit 1 exit 1
fi fi
fi
} }