mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Space/Tab update.sh
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
dc9407281f
commit
1cd40dc9e5
1 changed files with 132 additions and 132 deletions
|
@ -35,157 +35,157 @@ source "/opt/pihole/COL_TABLE"
|
||||||
# FTLcheckUpdate() sourced from basic-install.sh
|
# FTLcheckUpdate() sourced from basic-install.sh
|
||||||
|
|
||||||
GitCheckUpdateAvail() {
|
GitCheckUpdateAvail() {
|
||||||
local directory
|
local directory
|
||||||
directory="${1}"
|
directory="${1}"
|
||||||
curdir=$PWD
|
curdir=$PWD
|
||||||
cd "${directory}" || return
|
cd "${directory}" || return
|
||||||
|
|
||||||
# Fetch latest changes in this repo
|
# Fetch latest changes in this repo
|
||||||
git fetch --quiet origin
|
git fetch --quiet origin
|
||||||
|
|
||||||
# @ alone is a shortcut for HEAD. Older versions of git
|
# @ alone is a shortcut for HEAD. Older versions of git
|
||||||
# need @{0}
|
# need @{0}
|
||||||
LOCAL="$(git rev-parse "@{0}")"
|
LOCAL="$(git rev-parse "@{0}")"
|
||||||
|
|
||||||
# The suffix @{upstream} to a branchname
|
# The suffix @{upstream} to a branchname
|
||||||
# (short form <branchname>@{u}) refers
|
# (short form <branchname>@{u}) refers
|
||||||
# to the branch that the branch specified
|
# to the branch that the branch specified
|
||||||
# by branchname is set to build on top of#
|
# by branchname is set to build on top of#
|
||||||
# (configured with branch.<name>.remote and
|
# (configured with branch.<name>.remote and
|
||||||
# branch.<name>.merge). A missing branchname
|
# branch.<name>.merge). A missing branchname
|
||||||
# defaults to the current one.
|
# defaults to the current one.
|
||||||
REMOTE="$(git rev-parse "@{upstream}")"
|
REMOTE="$(git rev-parse "@{upstream}")"
|
||||||
|
|
||||||
if [[ "${#LOCAL}" == 0 ]]; then
|
if [[ "${#LOCAL}" == 0 ]]; then
|
||||||
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support
|
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
||||||
Additional debugging output:${COL_NC}"
|
echo -e " Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [[ "${#REMOTE}" == 0 ]]; then
|
if [[ "${#REMOTE}" == 0 ]]; then
|
||||||
echo -e "\\n ${COL_LIGHT_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support
|
echo -e "\\n ${COL_LIGHT_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support"
|
||||||
Additional debugging output:${COL_NC}"
|
echo -e " Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change back to original directory
|
# Change back to original directory
|
||||||
cd "${curdir}" || exit
|
cd "${curdir}" || exit
|
||||||
|
|
||||||
if [[ "${LOCAL}" != "${REMOTE}" ]]; then
|
if [[ "${LOCAL}" != "${REMOTE}" ]]; then
|
||||||
# Local branch is behind remote branch -> Update
|
# Local branch is behind remote branch -> Update
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
# Local branch is up-to-date or in a situation
|
# Local branch is up-to-date or in a situation
|
||||||
# where this updater cannot be used (like on a
|
# where this updater cannot be used (like on a
|
||||||
# branch that exists only locally)
|
# branch that exists only locally)
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local basicError="\\n ${COL_LIGHT_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}"
|
local basicError="\\n ${COL_LIGHT_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}"
|
||||||
local core_update
|
local core_update
|
||||||
local web_update
|
local web_update
|
||||||
local FTL_update
|
local FTL_update
|
||||||
|
|
||||||
core_update=false
|
|
||||||
web_update=false
|
|
||||||
FTL_update=false
|
|
||||||
|
|
||||||
# shellcheck disable=1090,2154
|
|
||||||
source "${setupVars}"
|
|
||||||
|
|
||||||
# This is unlikely
|
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
|
||||||
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!
|
|
||||||
Please re-run install script from https://pi-hole.net${COL_NC}"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e " ${INFO} Checking for updates..."
|
|
||||||
|
|
||||||
if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then
|
|
||||||
core_update=true
|
|
||||||
echo -e " ${INFO} Pi-hole Core:\\t${COL_YELLOW}update available${COL_NC}"
|
|
||||||
else
|
|
||||||
core_update=false
|
core_update=false
|
||||||
echo -e " ${INFO} Pi-hole Core:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
web_update=false
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
|
||||||
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
|
||||||
echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!
|
|
||||||
Please re-run install script from https://pi-hole.net${COL_NC}"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
|
||||||
web_update=true
|
|
||||||
echo -e " ${INFO} Web Interface:\\t${COL_YELLOW}update available${COL_NC}"
|
|
||||||
else
|
|
||||||
web_update=false
|
|
||||||
echo -e " ${INFO} Web Interface:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if FTLcheckUpdate > /dev/null; then
|
|
||||||
FTL_update=true
|
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_YELLOW}update available${COL_NC}"
|
|
||||||
else
|
|
||||||
case $? in
|
|
||||||
1)
|
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Branch is not available.${COL_NC}\\n\\t\\t\\tUse ${COL_LIGHT_GREEN}pihole checkout ftl [branchname]${COL_NC} to switch to a valid branch."
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, contact support${COL_NC}"
|
|
||||||
esac
|
|
||||||
FTL_update=false
|
FTL_update=false
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${core_update}" == false && "${web_update}" == false && "${FTL_update}" == false ]]; then
|
# shellcheck disable=1090,2154
|
||||||
echo ""
|
source "${setupVars}"
|
||||||
echo -e " ${TICK} Everything is up to date!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${CHECK_ONLY}" == true ]]; then
|
# This is unlikely
|
||||||
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
|
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
|
||||||
|
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e " ${INFO} Checking for updates..."
|
||||||
|
|
||||||
|
if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then
|
||||||
|
core_update=true
|
||||||
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
|
else
|
||||||
|
core_update=false
|
||||||
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
||||||
|
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
||||||
|
echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!"
|
||||||
|
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
||||||
|
web_update=true
|
||||||
|
echo -e " ${INFO} Web Interface:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
|
else
|
||||||
|
web_update=false
|
||||||
|
echo -e " ${INFO} Web Interface:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if FTLcheckUpdate > /dev/null; then
|
||||||
|
FTL_update=true
|
||||||
|
echo -e " ${INFO} FTL:\\t\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
|
else
|
||||||
|
case $? in
|
||||||
|
1)
|
||||||
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Branch is not available.${COL_NC}\\n\\t\\t\\tUse ${COL_LIGHT_GREEN}pihole checkout ftl [branchname]${COL_NC} to switch to a valid branch."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, contact support${COL_NC}"
|
||||||
|
esac
|
||||||
|
FTL_update=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${core_update}" == false && "${web_update}" == false && "${FTL_update}" == false ]]; then
|
||||||
|
echo ""
|
||||||
|
echo -e " ${TICK} Everything is up to date!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${CHECK_ONLY}" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${core_update}" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo -e " ${INFO} Pi-hole core files out of date, updating local repo."
|
||||||
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
|
echo -e " ${INFO} If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${web_update}" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo -e " ${INFO} Pi-hole Web Admin files out of date, updating local repo."
|
||||||
|
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||||
|
echo -e " ${INFO} If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${FTL_update}" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo -e " ${INFO} FTL out of date, it will be updated by the installer."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${FTL_update}" == true || "${core_update}" == true ]]; then
|
||||||
|
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || \
|
||||||
|
echo -e "${basicError}" && exit 1
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${core_update}" == true ]]; then
|
|
||||||
echo ""
|
|
||||||
echo -e " ${INFO} Pi-hole core files out of date, updating local repo."
|
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
|
||||||
echo -e " ${INFO} If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${web_update}" == true ]]; then
|
|
||||||
echo ""
|
|
||||||
echo -e " ${INFO} Pi-hole Web Admin files out of date, updating local repo."
|
|
||||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
|
||||||
echo -e " ${INFO} If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${FTL_update}" == true ]]; then
|
|
||||||
echo ""
|
|
||||||
echo -e " ${INFO} FTL out of date, it will be updated by the installer."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${FTL_update}" == true || "${core_update}" == true ]]; then
|
|
||||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || \
|
|
||||||
echo -e "${basicError}" && exit 1
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" == "--check-only" ]]; then
|
if [[ "$1" == "--check-only" ]]; then
|
||||||
CHECK_ONLY=true
|
CHECK_ONLY=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in a new issue