2017-03-08 12:16:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Pi-hole: A black hole for Internet advertisements
|
|
|
|
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
|
|
# Network-wide ad blocking via your own hardware.
|
|
|
|
#
|
2017-07-01 12:08:17 +00:00
|
|
|
# Switch Pi-hole subsystems to a different Github branch.
|
2017-03-08 12:16:40 +00:00
|
|
|
#
|
|
|
|
# This file is copyright under the latest version of the EUPL.
|
|
|
|
# Please see LICENSE file for your rights under this license.
|
|
|
|
|
2017-03-08 21:27:48 +00:00
|
|
|
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
2017-06-21 11:49:05 +00:00
|
|
|
PH_TEST="true"
|
|
|
|
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
2017-03-08 21:27:48 +00:00
|
|
|
|
2017-03-08 21:41:11 +00:00
|
|
|
# webInterfaceGitUrl set in basic-install.sh
|
|
|
|
# webInterfaceDir set in basic-install.sh
|
|
|
|
# piholeGitURL set in basic-install.sh
|
2017-03-08 21:27:48 +00:00
|
|
|
# is_repo() sourced from basic-install.sh
|
2017-03-11 15:46:52 +00:00
|
|
|
# setupVars set in basic-install.sh
|
|
|
|
|
|
|
|
source "${setupVars}"
|
2017-03-11 20:21:15 +00:00
|
|
|
update="false"
|
2017-03-11 15:24:13 +00:00
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
coltable="/opt/pihole/COL_TABLE"
|
|
|
|
source ${coltable}
|
2017-05-14 01:11:44 +00:00
|
|
|
|
2017-06-27 12:28:05 +00:00
|
|
|
check_download_exists() {
|
|
|
|
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
|
2017-07-16 12:32:34 +00:00
|
|
|
if grep -q "404" <<< "$status"; then
|
2017-06-27 12:28:05 +00:00
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
FTLinstall() {
|
|
|
|
# Download and install FTL binary
|
2017-07-05 17:34:20 +00:00
|
|
|
local binary
|
|
|
|
binary="${1}"
|
|
|
|
local path
|
|
|
|
path="${2}"
|
|
|
|
local str
|
|
|
|
str="Installing FTL"
|
2017-06-27 12:28:05 +00:00
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
|
|
|
if curl -sSL --fail "https://ftl.pi-hole.net/${path}" -o "/tmp/${binary}"; then
|
|
|
|
# Get sha1 of the binary we just downloaded for verification.
|
|
|
|
curl -sSL --fail "https://ftl.pi-hole.net/${path}.sha1" -o "/tmp/${binary}.sha1"
|
|
|
|
# Check if we just downloaded text, or a binary file.
|
2017-07-05 17:34:20 +00:00
|
|
|
cd /tmp || return 1
|
2017-06-27 12:28:05 +00:00
|
|
|
if sha1sum --status --quiet -c "${binary}".sha1; then
|
|
|
|
echo -n "transferred... "
|
|
|
|
stop_service pihole-FTL &> /dev/null
|
|
|
|
install -T -m 0755 "/tmp/${binary}" "/usr/bin/pihole-FTL"
|
|
|
|
rm "/tmp/${binary}" "/tmp/${binary}.sha1"
|
|
|
|
start_service pihole-FTL &> /dev/null
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo -e "${OVER} ${CROSS} ${str}"
|
|
|
|
echo -e " ${COL_LIGHT_RED}Error: Download of binary from ftl.pi-hole.net failed${COL_NC}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -e "${OVER} ${CROSS} ${str}"
|
|
|
|
echo -e " ${COL_LIGHT_RED}Error: URL not found${COL_NC}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_binary_name() {
|
|
|
|
local machine
|
|
|
|
machine=$(uname -m)
|
|
|
|
|
2017-07-05 17:34:20 +00:00
|
|
|
local str
|
|
|
|
str="Detecting architecture"
|
2017-06-27 12:28:05 +00:00
|
|
|
echo -ne " ${INFO} ${str}..."
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${machine}" == "arm"* || "${machine}" == *"aarch"* ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
# ARM
|
2017-07-05 17:34:20 +00:00
|
|
|
local rev
|
|
|
|
rev=$(uname -m | sed "s/[^0-9]//g;")
|
|
|
|
local lib
|
|
|
|
lib=$(ldd /bin/ls | grep -E '^\s*/lib' | awk '{ print $1 }')
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${lib}" == "/lib/ld-linux-aarch64.so.1" ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
echo -e "${OVER} ${TICK} Detected ARM-aarch64 architecture"
|
|
|
|
binary="pihole-FTL-aarch64-linux-gnu"
|
2017-07-16 12:32:34 +00:00
|
|
|
elif [[ "${lib}" == "/lib/ld-linux-armhf.so.3" ]]; then
|
|
|
|
if [[ "$rev" -gt "6" ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
echo -e "${OVER} ${TICK} Detected ARM-hf architecture (armv7+)"
|
|
|
|
binary="pihole-FTL-arm-linux-gnueabihf"
|
|
|
|
else
|
|
|
|
echo -e "${OVER} ${TICK} Detected ARM-hf architecture (armv6 or lower) Using ARM binary"
|
|
|
|
binary="pihole-FTL-arm-linux-gnueabi"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -e "${OVER} ${TICK} Detected ARM architecture"
|
|
|
|
binary="pihole-FTL-arm-linux-gnueabi"
|
|
|
|
fi
|
2017-07-16 12:32:34 +00:00
|
|
|
elif [[ "${machine}" == "ppc" ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
# PowerPC
|
2017-07-16 12:32:34 +00:00
|
|
|
echo -e "${OVER} ${TICK} Detected PowerPC architecture"
|
2017-06-27 12:28:05 +00:00
|
|
|
binary="pihole-FTL-powerpc-linux-gnu"
|
2017-07-16 12:32:34 +00:00
|
|
|
elif [[ "${machine}" == "x86_64" ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
# 64bit
|
|
|
|
echo -e "${OVER} ${TICK} Detected x86_64 architecture"
|
|
|
|
binary="pihole-FTL-linux-x86_64"
|
|
|
|
else
|
|
|
|
# Something else - we try to use 32bit executable and warn the user
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ ! "${machine}" == "i686" ]]; then
|
2017-06-27 12:28:05 +00:00
|
|
|
echo -e "${OVER} ${CROSS} ${str}...
|
|
|
|
${COL_LIGHT_RED}Not able to detect architecture (unknown: ${machine}), trying 32bit executable
|
|
|
|
Contact support if you experience issues (e.g: FTL not running)${COL_NC}"
|
|
|
|
else
|
|
|
|
echo -e "${OVER} ${TICK} Detected 32bit (i686) architecture"
|
|
|
|
fi
|
|
|
|
binary="pihole-FTL-linux-x86_32"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
fully_fetch_repo() {
|
|
|
|
# Add upstream branches to shallow clone
|
|
|
|
local directory="${1}"
|
|
|
|
|
|
|
|
cd "${directory}" || return 1
|
2017-03-08 21:57:35 +00:00
|
|
|
if is_repo "${directory}"; then
|
2017-03-08 23:28:02 +00:00
|
|
|
git remote set-branches origin '*' || return 1
|
|
|
|
git fetch --quiet || return 1
|
2017-03-08 21:57:35 +00:00
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
2017-03-08 21:30:08 +00:00
|
|
|
return 0
|
2017-03-08 12:16:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
get_available_branches() {
|
2017-03-08 12:16:40 +00:00
|
|
|
# Return available branches
|
2017-07-05 17:34:20 +00:00
|
|
|
local directory
|
|
|
|
directory="${1}"
|
2017-06-21 11:49:05 +00:00
|
|
|
local output
|
2017-03-08 12:16:40 +00:00
|
|
|
|
|
|
|
cd "${directory}" || return 1
|
2017-06-21 11:49:05 +00:00
|
|
|
# Get reachable remote branches, but store STDERR as STDOUT variable
|
|
|
|
output=$( { git remote show origin | grep 'tracked' | sed 's/tracked//;s/ //g'; } 2>&1 )
|
|
|
|
echo "$output"
|
2017-03-08 12:16:40 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:11:23 +00:00
|
|
|
fetch_checkout_pull_branch() {
|
|
|
|
# Check out specified branch
|
2017-07-05 17:34:20 +00:00
|
|
|
local directory
|
|
|
|
directory="${1}"
|
|
|
|
local branch
|
|
|
|
branch="${2}"
|
2017-03-11 15:11:23 +00:00
|
|
|
|
2017-03-11 15:40:10 +00:00
|
|
|
# Set the reference for the requested branch, fetch, check it put and pull it
|
2017-07-05 17:34:20 +00:00
|
|
|
cd "${directory}" || return 1
|
2017-03-11 15:40:10 +00:00
|
|
|
git remote set-branches origin "${branch}" || return 1
|
2017-04-21 15:08:15 +00:00
|
|
|
git stash --all --quiet &> /dev/null || true
|
2017-07-01 12:08:17 +00:00
|
|
|
git clean --quiet --force -d || true
|
2017-03-11 15:40:10 +00:00
|
|
|
git fetch --quiet || return 1
|
|
|
|
checkout_pull_branch "${directory}" "${branch}" || return 1
|
2017-03-11 15:11:23 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
checkout_pull_branch() {
|
|
|
|
# Check out specified branch
|
2017-07-05 17:34:20 +00:00
|
|
|
local directory
|
|
|
|
directory="${1}"
|
|
|
|
local branch
|
|
|
|
branch="${2}"
|
2017-03-11 20:21:15 +00:00
|
|
|
local oldbranch
|
2017-03-08 12:16:40 +00:00
|
|
|
|
|
|
|
cd "${directory}" || return 1
|
2017-03-11 15:55:37 +00:00
|
|
|
|
2017-03-11 20:21:15 +00:00
|
|
|
oldbranch="$(git symbolic-ref HEAD)"
|
2017-06-27 12:28:05 +00:00
|
|
|
|
2017-07-27 20:33:41 +00:00
|
|
|
str="Switching to branch: ${branch}"
|
|
|
|
echo -ne " ${INFO} $str"
|
2017-07-01 12:08:17 +00:00
|
|
|
git checkout "${branch}" --quiet || return 1
|
2017-07-27 20:33:41 +00:00
|
|
|
echo -e "${OVER} ${TICK} $str"
|
|
|
|
|
2017-03-11 15:55:37 +00:00
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
if [[ "$(git diff "${oldbranch}" | grep -c "^")" -gt "0" ]]; then
|
2017-03-11 20:21:15 +00:00
|
|
|
update="true"
|
2017-03-11 15:24:13 +00:00
|
|
|
fi
|
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
git_pull=$(git pull || return 1)
|
2017-06-27 12:28:05 +00:00
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
if [[ "$git_pull" == *"up-to-date"* ]]; then
|
2017-07-27 20:33:41 +00:00
|
|
|
echo -e " ${INFO} ${git_pull}"
|
2017-06-21 11:49:05 +00:00
|
|
|
else
|
2017-07-16 12:32:34 +00:00
|
|
|
echo -e "$git_pull\\n"
|
2017-06-21 11:49:05 +00:00
|
|
|
fi
|
2017-06-27 12:28:05 +00:00
|
|
|
|
2017-03-10 18:57:46 +00:00
|
|
|
return 0
|
2017-03-08 12:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
warning1() {
|
2017-05-14 01:11:44 +00:00
|
|
|
echo " Please note that changing branches severely alters your Pi-hole subsystems"
|
|
|
|
echo " Features that work on the master branch, may not on a development branch"
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${COL_LIGHT_RED}This feature is NOT supported unless a Pi-hole developer explicitly asks!${COL_NC}"
|
2017-06-03 15:23:47 +00:00
|
|
|
read -r -p " Have you read and understood this? [y/N] " response
|
2017-07-16 12:32:34 +00:00
|
|
|
case "${response}" in
|
2017-03-08 12:16:40 +00:00
|
|
|
[yY][eE][sS]|[yY])
|
2017-06-21 11:49:05 +00:00
|
|
|
echo ""
|
2017-03-08 12:16:40 +00:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
*)
|
2017-07-16 12:32:34 +00:00
|
|
|
echo -e "\\n ${INFO} Branch change has been cancelled"
|
2017-03-08 12:16:40 +00:00
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
checkout() {
|
2017-03-08 12:16:40 +00:00
|
|
|
local corebranches
|
|
|
|
local webbranches
|
|
|
|
|
|
|
|
# Avoid globbing
|
|
|
|
set -f
|
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
# This is unlikely
|
2017-03-11 15:30:58 +00:00
|
|
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!
|
|
|
|
Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
2017-03-11 15:30:58 +00:00
|
|
|
exit 1;
|
|
|
|
fi
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${INSTALL_WEB}" == "true" ]]; then
|
2017-03-11 15:38:28 +00:00
|
|
|
if ! is_repo "${webInterfaceDir}" ; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!
|
|
|
|
Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
2017-03-11 15:30:58 +00:00
|
|
|
exit 1;
|
|
|
|
fi
|
2017-03-08 12:16:40 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-10 19:04:37 +00:00
|
|
|
if [[ -z "${1}" ]]; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${COL_LIGHT_RED}Invalid option${COL_NC}
|
|
|
|
Try 'pihole checkout --help' for more information."
|
2017-03-10 19:04:37 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
if ! warning1 ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-03-08 21:57:35 +00:00
|
|
|
if [[ "${1}" == "dev" ]] ; then
|
2017-03-08 12:18:34 +00:00
|
|
|
# Shortcut to check out development branches
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Shortcut \"dev\" detected - checking out development / devel branches..."
|
2017-07-01 12:08:17 +00:00
|
|
|
echo ""
|
|
|
|
echo -e " ${INFO} Pi-hole Core"
|
2017-06-21 11:49:05 +00:00
|
|
|
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo " ${CROSS} Unable to pull Core developement branch"; exit 1; }
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${INSTALL_WEB}" == "true" ]]; then
|
2017-07-01 12:08:17 +00:00
|
|
|
echo ""
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Web interface"
|
|
|
|
fetch_checkout_pull_branch "${webInterfaceDir}" "devel" || { echo " ${CROSS} Unable to pull Web development branch"; exit 1; }
|
2017-03-11 15:30:58 +00:00
|
|
|
fi
|
2017-07-01 12:08:17 +00:00
|
|
|
#echo -e " ${TICK} Pi-hole Core"
|
2017-06-27 12:28:05 +00:00
|
|
|
|
|
|
|
get_binary_name
|
|
|
|
local path
|
|
|
|
path="development/${binary}"
|
|
|
|
FTLinstall "${binary}" "${path}"
|
2017-03-08 21:57:35 +00:00
|
|
|
elif [[ "${1}" == "master" ]] ; then
|
2017-03-08 12:18:34 +00:00
|
|
|
# Shortcut to check out master branches
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Shortcut \"master\" detected - checking out master branches..."
|
|
|
|
echo -e " ${INFO} Pi-hole core"
|
|
|
|
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo " ${CROSS} Unable to pull Core master branch"; exit 1; }
|
2017-03-11 20:21:15 +00:00
|
|
|
if [[ ${INSTALL_WEB} == "true" ]]; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Web interface"
|
|
|
|
fetch_checkout_pull_branch "${webInterfaceDir}" "master" || { echo " ${CROSS} Unable to pull Web master branch"; exit 1; }
|
2017-03-11 15:30:58 +00:00
|
|
|
fi
|
2017-07-01 12:08:17 +00:00
|
|
|
#echo -e " ${TICK} Web Interface"
|
2017-07-16 12:32:34 +00:00
|
|
|
get_binary_name
|
2017-06-27 12:28:05 +00:00
|
|
|
local path
|
|
|
|
path="master/${binary}"
|
|
|
|
FTLinstall "${binary}" "${path}"
|
2017-03-08 21:57:35 +00:00
|
|
|
elif [[ "${1}" == "core" ]] ; then
|
2017-06-21 11:49:05 +00:00
|
|
|
str="Fetching branches from ${piholeGitUrl}"
|
|
|
|
echo -ne " ${INFO} $str"
|
2017-03-10 19:25:35 +00:00
|
|
|
if ! fully_fetch_repo "${PI_HOLE_FILES_DIR}" ; then
|
2017-07-27 20:33:41 +00:00
|
|
|
echo -e "${OVER} ${CROSS} $str"
|
2017-03-10 19:25:35 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
corebranches=($(get_available_branches "${PI_HOLE_FILES_DIR}"))
|
2017-06-21 11:49:05 +00:00
|
|
|
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${corebranches[*]}" == *"master"* ]]; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e "${OVER} ${TICK} $str
|
|
|
|
${INFO} ${#corebranches[@]} branches available for Pi-hole Core"
|
|
|
|
else
|
|
|
|
# Print STDERR output from get_available_branches
|
2017-07-16 12:32:34 +00:00
|
|
|
echo -e "${OVER} ${CROSS} $str\\n\\n${corebranches[*]}"
|
2017-06-21 11:49:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
# Have the user choose the branch they want
|
2017-03-08 22:29:51 +00:00
|
|
|
if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Requested branch \"${2}\" is not available"
|
|
|
|
echo -e " ${INFO} Available branches for Core are:"
|
|
|
|
for e in "${corebranches[@]}"; do echo " - $e"; done
|
2017-03-08 12:16:40 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-03-08 22:29:51 +00:00
|
|
|
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${2}"
|
2017-06-21 11:49:05 +00:00
|
|
|
elif [[ "${1}" == "web" ]] && [[ "${INSTALL_WEB}" == "true" ]] ; then
|
|
|
|
str="Fetching branches from ${webInterfaceGitUrl}"
|
|
|
|
echo -ne " ${INFO} $str"
|
2017-03-10 19:25:35 +00:00
|
|
|
if ! fully_fetch_repo "${webInterfaceDir}" ; then
|
2017-07-27 20:33:41 +00:00
|
|
|
echo -e "${OVER} ${CROSS} $str"
|
2017-03-10 19:25:35 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
webbranches=($(get_available_branches "${webInterfaceDir}"))
|
2017-06-27 12:28:05 +00:00
|
|
|
|
2017-07-16 12:32:34 +00:00
|
|
|
if [[ "${webbranches[*]}" == *"master"* ]]; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e "${OVER} ${TICK} $str
|
|
|
|
${INFO} ${#webbranches[@]} branches available for Web Admin"
|
|
|
|
else
|
|
|
|
# Print STDERR output from get_available_branches
|
2017-07-16 12:32:34 +00:00
|
|
|
echo -e "${OVER} ${CROSS} $str\\n\\n${webbranches[*]}"
|
2017-06-21 11:49:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
# Have the user choose the branch they want
|
2017-03-08 22:29:51 +00:00
|
|
|
if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Requested branch \"${2}\" is not available"
|
|
|
|
echo -e " ${INFO} Available branches for Web Admin are:"
|
|
|
|
for e in "${webbranches[@]}"; do echo " - $e"; done
|
2017-03-08 12:16:40 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-03-08 23:30:36 +00:00
|
|
|
checkout_pull_branch "${webInterfaceDir}" "${2}"
|
2017-06-27 12:28:05 +00:00
|
|
|
elif [[ "${1}" == "ftl" ]] ; then
|
|
|
|
get_binary_name
|
|
|
|
local path
|
|
|
|
path="${2}/${binary}"
|
|
|
|
|
|
|
|
if check_download_exists "$path"; then
|
|
|
|
echo " ${TICK} Branch ${2} exists"
|
2017-07-16 12:22:59 +00:00
|
|
|
FTLinstall "${binary}" "${path}"
|
2017-06-27 12:28:05 +00:00
|
|
|
else
|
2017-07-05 17:30:05 +00:00
|
|
|
echo " ${CROSS} Requested branch \"${2}\" is not available"
|
2017-07-16 12:54:23 +00:00
|
|
|
ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep 'heads' | sed 's/refs\/heads\///;s/ //g' | awk '{print $2}') )
|
|
|
|
echo -e " ${INFO} Available branches for FTL are:"
|
|
|
|
for e in "${ftlbranches[@]}"; do echo " - $e"; done
|
|
|
|
exit 1
|
2017-06-27 12:28:05 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
else
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Requested option \"${1}\" is not available"
|
2017-03-08 12:16:40 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Force updating everything
|
2017-06-27 12:28:05 +00:00
|
|
|
if [[ ( ! "${1}" == "web" && ! "${1}" == "ftl" ) && "${update}" == "true" ]]; then
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${INFO} Running installer to upgrade your installation"
|
2017-03-11 15:36:54 +00:00
|
|
|
if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then
|
2017-05-14 01:11:44 +00:00
|
|
|
exit 0
|
2017-03-10 19:25:35 +00:00
|
|
|
else
|
2017-06-21 11:49:05 +00:00
|
|
|
echo -e " ${COL_LIGHT_RED} Error: Unable to complete update, please contact support${COL_NC}"
|
2017-05-14 01:11:44 +00:00
|
|
|
exit 1
|
2017-03-10 19:25:35 +00:00
|
|
|
fi
|
2017-03-08 22:17:20 +00:00
|
|
|
fi
|
2017-03-08 12:16:40 +00:00
|
|
|
}
|