mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-24 13:50:17 +00:00
Version remote check returns -1 on failure to detect curl silent failing. Update detects loss of contact to GitHub or fallthrough condition and reports to user.
This commit is contained in:
parent
3d43e1568c
commit
f7266ef4c8
2 changed files with 17 additions and 13 deletions
|
@ -82,11 +82,11 @@ main() {
|
||||||
local web_version_current
|
local web_version_current
|
||||||
local web_version_latest
|
local web_version_latest
|
||||||
|
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then #This is unlikely
|
# if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then #This is unlikely
|
||||||
echo "::: Critical Error: One or more Pi-Hole repos are 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"
|
# echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
exit 1;
|
# exit 1;
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
echo "::: Checking for updates..."
|
echo "::: Checking for updates..."
|
||||||
# Checks Pi-hole version string in format vX.X.X
|
# Checks Pi-hole version string in format vX.X.X
|
||||||
|
@ -95,6 +95,11 @@ main() {
|
||||||
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
||||||
web_version_latest="$(/usr/local/bin/pihole version --admin --latest)"
|
web_version_latest="$(/usr/local/bin/pihole version --admin --latest)"
|
||||||
|
|
||||||
|
if [[ "${pihole_version_latest}" -eq "-1" || "${web_version_latest}" -eq -1 ]]; then
|
||||||
|
echo "*** Unable to contact GitHub for latest version. Please try again later, contact support if this continues."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Logic
|
# Logic
|
||||||
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
||||||
# Update anyway
|
# Update anyway
|
||||||
|
@ -120,35 +125,34 @@ main() {
|
||||||
echo "::: Pi-hole Web Admin files out of date"
|
echo "::: Pi-hole Web Admin files out of date"
|
||||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||||
|
|
||||||
web_version_current="$(/usr/local/bin/pihole -v -a -c)"
|
|
||||||
web_updated=true
|
web_updated=true
|
||||||
|
|
||||||
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
||||||
echo "::: Pi-hole core files out of date"
|
echo "::: Pi-hole core files out of date"
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||||
pihole_version_current="$(/usr/local/bin/pihole -v -p -c)"
|
|
||||||
core_updated=true
|
core_updated=true
|
||||||
|
|
||||||
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then
|
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then
|
||||||
echo "::: Updating Everything"
|
echo "::: Updating Everything"
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
/etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
/etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||||
# Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X
|
|
||||||
web_version_current="$(/usr/local/bin/pihole -v -a -c)"
|
|
||||||
# Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X
|
|
||||||
pihole_version_current="$(/usr/local/bin/pihole -v -p -c)"
|
|
||||||
web_updated=true
|
web_updated=true
|
||||||
core_updated=true
|
core_updated=true
|
||||||
|
else
|
||||||
|
echo "*** Update script has malfunctioned, fallthrough reached. Please contact support"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${web_updated}" == true ]]; then
|
if [[ "${web_updated}" == true ]]; then
|
||||||
|
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Web Admin version is now at ${web_version_current}"
|
echo "::: Web Admin version is now at ${web_version_current}"
|
||||||
echo "::: If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
echo "::: If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${core_updated}" == true ]]; then
|
if [[ "${core_updated}" == true ]]; then
|
||||||
|
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Pi-hole version is now at ${pihole_version_current}"
|
echo "::: Pi-hole version is now at ${pihole_version_current}"
|
||||||
echo "::: If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
echo "::: If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
||||||
|
|
|
@ -58,10 +58,10 @@ coreOutput() {
|
||||||
|
|
||||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
echo ${piholeVersionLatest}
|
echo ${piholeVersionLatest:-"-1"}
|
||||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||||
echo ${piholeVersion}
|
echo ${piholeVersion:-"-1"}
|
||||||
else
|
else
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
|
|
Loading…
Reference in a new issue