mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-23 07:18:07 +00:00
Move version messages to main function, check for repos.
This commit is contained in:
parent
d9528dfd09
commit
7d414b5628
@ -63,90 +63,89 @@ getGitFiles() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
is_repo "${PI_HOLE_FILES_DIR}" &> /dev/null
|
is_repo "${PI_HOLE_FILES_DIR}" &> /dev/null
|
||||||
if [[ $? -eq 1 ]]; then #This is unlikely
|
if [[ $? -eq 1 ]]; then #This is unlikely
|
||||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
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
|
||||||
|
|
||||||
is_repo "${ADMIN_INTERFACE_DIR}" &> /dev/null
|
is_repo "${ADMIN_INTERFACE_DIR}" &> /dev/null
|
||||||
if [[ $? -eq 1 ]]; then #This is unlikely
|
if [[ $? -eq 1 ]]; then #This is unlikely
|
||||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
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
|
||||||
|
|
||||||
echo "::: Checking for updates..."
|
echo "::: Checking for updates..."
|
||||||
# Checks Pi-hole version > pihole only > current local git repo version : returns string in format vX.X.X
|
# Checks Pi-hole version > pihole only > current local git repo version : returns string in format vX.X.X
|
||||||
piholeVersion="$(/usr/local/bin/pihole -v -p -c)"
|
local -r pihole_version_current="$(/usr/local/bin/pihole -v -p -c)"
|
||||||
# Checks Pi-hole version > pihole only > remote upstream repo version : returns string in format vX.X.X
|
# Checks Pi-hole version > pihole only > remote upstream repo version : returns string in format vX.X.X
|
||||||
piholeVersionLatest="$(/usr/local/bin/pihole -v -p -l)"
|
local -r pihole_version_latest="$(/usr/local/bin/pihole -v -p -l)"
|
||||||
|
|
||||||
# Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X
|
# Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X
|
||||||
webVersion="$(/usr/local/bin/pihole -v -a -c)"
|
local -r web_version_current="$(/usr/local/bin/pihole -v -a -c)"
|
||||||
# Checks Pi-hole version > admin only > remote upstream repo version : returns string in format vX.X.X
|
# Checks Pi-hole version > admin only > remote upstream repo version : returns string in format vX.X.X
|
||||||
webVersionLatest="$(/usr/local/bin/pihole -v -a -l)"
|
local -r web_version_latest="$(/usr/local/bin/pihole -v -a -l)"
|
||||||
|
|
||||||
echo ":::"
|
# Logic
|
||||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
||||||
echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)"
|
# Update anyway
|
||||||
echo ":::"
|
# If Core up to date AND web up to date:
|
||||||
|
# Do nothing
|
||||||
|
# If Core up to date AND web NOT up to date:
|
||||||
|
# Pull web repo
|
||||||
|
# If Core NOT up to date AND web up to date:
|
||||||
|
# pull pihole repo, run install --unattended -- reconfigure
|
||||||
|
# if Core NOT up to date AND web NOT up to date:
|
||||||
|
# pull pihole repo run install --unattended
|
||||||
|
|
||||||
# Logic
|
if [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
||||||
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
echo "::: Pi-hole version is $pihole_version_current"
|
||||||
# Update anyway
|
echo "::: Web Admin version is $web_version_current"
|
||||||
# If Core up to date AND web up to date:
|
echo "::: Everything is up to date!"
|
||||||
# Do nothing
|
echo ""
|
||||||
# If Core up to date AND web NOT up to date:
|
exit 0
|
||||||
# Pull web repo
|
|
||||||
# If Core NOT up to date AND web up to date:
|
|
||||||
# pull pihole repo, run install --unattended -- reconfigure
|
|
||||||
# if Core NOT up to date AND web NOT up to date:
|
|
||||||
# pull pihole repo run install --unattended
|
|
||||||
|
|
||||||
|
elif [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" != "${web_version_latest}" ]]; then
|
||||||
|
echo "::: Pi-hole Web Admin files out of date"
|
||||||
|
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||||
|
echo ":::"
|
||||||
|
web_version_current="$(/usr/local/bin/pihole -v -a -c)"
|
||||||
|
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 ""
|
||||||
|
elif [[ "${pihole_version_current}" != "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
||||||
|
echo "::: Pi-hole core files out of date"
|
||||||
|
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
|
||||||
|
|
||||||
if [[ "${piholeVersion}" == "${piholeVersionLatest}" ]] && [[ "${webVersion}" == "${webVersionLatest}" ]]; then
|
echo ":::"
|
||||||
echo "::: Everything is up to date!"
|
pihole_version_current="$(/usr/local/bin/pihole -v -p -c)"
|
||||||
echo ""
|
echo "::: Pi-hole version is now at ${pihole_version_current}"
|
||||||
exit 0
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
||||||
|
echo ""
|
||||||
|
elif [[ "${pihole_version_current}" != "${pihole_version_latest}" ]] && [[ "${web_version_current}" != "${web_version_latest}" ]]; then
|
||||||
|
echo "::: Updating Everything"
|
||||||
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
|
|
||||||
elif [[ "${piholeVersion}" == "${piholeVersionLatest}" ]] && [[ "${webVersion}" != "${webVersionLatest}" ]]; then
|
/etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||||
echo "::: Pi-hole Web Admin files out of date"
|
|
||||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
|
||||||
echo ":::"
|
|
||||||
webVersion="$(/usr/local/bin/pihole -v -a -c)"
|
|
||||||
echo "::: Web Admin version is now at ${webVersion}"
|
|
||||||
echo "::: If you had made any changes in '/var/www/html/admin', they have been stashed using 'git stash'"
|
|
||||||
echo ""
|
|
||||||
elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" == "${webVersionLatest}" ]]; then
|
|
||||||
echo "::: Pi-hole core files out of date"
|
|
||||||
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
|
# 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)"
|
||||||
|
echo ":::"
|
||||||
|
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 ":::"
|
||||||
|
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 ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo ":::"
|
main
|
||||||
piholeVersion="$(/usr/local/bin/pihole -v -p -c)"
|
|
||||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
||||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
||||||
echo ""
|
|
||||||
elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" != "${webVersionLatest}" ]]; then
|
|
||||||
echo "::: Updating Everything"
|
|
||||||
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
|
|
||||||
|
|
||||||
# Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X
|
|
||||||
webVersion="$(/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
|
|
||||||
piholeVersion="$(/usr/local/bin/pihole -v -p -c)"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
||||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
||||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user