Update local and remote versions at the same time

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König 2022-10-06 12:36:17 +02:00
parent 56527e5dd9
commit 18d28533eb
No known key found for this signature in database
5 changed files with 60 additions and 66 deletions

View file

@ -42,11 +42,6 @@ warning1() {
esac esac
} }
updateCheckFunc() {
/opt/pihole/updatecheck.sh
/opt/pihole/updatecheck.sh x remote
}
checkout() { checkout() {
local corebranches local corebranches
local webbranches local webbranches
@ -169,8 +164,8 @@ checkout() {
exit 1 exit 1
fi fi
checkout_pull_branch "${webInterfaceDir}" "${2}" checkout_pull_branch "${webInterfaceDir}" "${2}"
# Force an update of the updatechecker # Update local and remote versions via updatechecker
updateCheckFunc /opt/pihole/updatecheck.sh
elif [[ "${1}" == "ftl" ]] ; then elif [[ "${1}" == "ftl" ]] ; then
local path local path
local oldbranch local oldbranch
@ -185,8 +180,8 @@ checkout() {
FTLinstall "${binary}" FTLinstall "${binary}"
restart_service pihole-FTL restart_service pihole-FTL
enable_service pihole-FTL enable_service pihole-FTL
# Force an update of the updatechecker # Update local and remote versions via updatechecker
updateCheckFunc /opt/pihole/updatecheck.sh
else else
echo " ${CROSS} Requested branch \"${2}\" is not available" echo " ${CROSS} Requested branch \"${2}\" is not available"
ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep 'heads' | sed 's/refs\/heads\///;s/ //g' | awk '{print $2}') ) ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep 'heads' | sed 's/refs\/heads\///;s/ //g' | awk '{print $2}') )

View file

@ -216,9 +216,8 @@ main() {
fi fi
if [[ "${FTL_update}" == true || "${core_update}" == true || "${web_update}" == true ]]; then if [[ "${FTL_update}" == true || "${core_update}" == true || "${web_update}" == true ]]; then
# Force an update of the updatechecker # Update local and remote versions via updatechecker
/opt/pihole/updatecheck.sh /opt/pihole/updatecheck.sh
/opt/pihole/updatecheck.sh x remote
echo -e " ${INFO} Local version file information updated." echo -e " ${INFO} Local version file information updated."
fi fi

View file

@ -28,7 +28,7 @@ function get_remote_version() {
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /etc/pihole/setupVars.conf . /etc/pihole/setupVars.conf
# Source the utils file # Source the utils file for addOrEditKeyValPair()
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /opt/pihole/utils.sh . /opt/pihole/utils.sh
@ -50,54 +50,55 @@ if [[ ! "${DOCKER_TAG}" =~ $regex ]]; then
unset DOCKER_TAG unset DOCKER_TAG
fi fi
if [[ "$2" == "remote" ]]; then # used in cronjob
if [[ "$1" == "reboot" ]]; then
if [[ "$3" == "reboot" ]]; then
sleep 30 sleep 30
fi fi
GITHUB_CORE_VERSION="$(get_remote_version pi-hole)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_CORE_VERSION" "${GITHUB_CORE_VERSION}" # get local versions
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then CORE_BRANCH="$(get_local_branch /etc/.pihole)"
GITHUB_WEB_VERSION="$(get_remote_version AdminLTE)" addOrEditKeyValPair "${VERSION_FILE}" "CORE_BRANCH" "${CORE_BRANCH}"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_WEB_VERSION" "${GITHUB_WEB_VERSION}"
fi if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
WEB_BRANCH="$(get_local_branch /var/www/html/admin)"
GITHUB_FTL_VERSION="$(get_remote_version FTL)" addOrEditKeyValPair "${VERSION_FILE}" "WEB_BRANCH" "${WEB_BRANCH}"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_FTL_VERSION" "${GITHUB_FTL_VERSION}" fi
if [[ "${DOCKER_TAG}" ]]; then FTL_BRANCH="$(pihole-FTL branch)"
GITHUB_DOCKER_VERSION="$(get_remote_version docker-pi-hole)" addOrEditKeyValPair "${VERSION_FILE}" "FTL_BRANCH" "${FTL_BRANCH}"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_DOCKER_VERSION" "${GITHUB_DOCKER_VERSION}"
fi CORE_VERSION="$(get_local_version /etc/.pihole)"
addOrEditKeyValPair "${VERSION_FILE}" "CORE_VERSION" "${CORE_VERSION}"
else
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
CORE_BRANCH="$(get_local_branch /etc/.pihole)" WEB_VERSION="$(get_local_version /var/www/html/admin)"
addOrEditKeyValPair "${VERSION_FILE}" "CORE_BRANCH" "${CORE_BRANCH}" addOrEditKeyValPair "${VERSION_FILE}" "WEB_VERSION" "${WEB_VERSION}"
fi
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
WEB_BRANCH="$(get_local_branch /var/www/html/admin)" FTL_VERSION="$(pihole-FTL version)"
addOrEditKeyValPair "${VERSION_FILE}" "WEB_BRANCH" "${WEB_BRANCH}" addOrEditKeyValPair "${VERSION_FILE}" "FTL_VERSION" "${FTL_VERSION}"
fi
if [[ "${DOCKER_TAG}" ]]; then
FTL_BRANCH="$(pihole-FTL branch)" addOrEditKeyValPair "${VERSION_FILE}" "DOCKER_VERSION" "${DOCKER_TAG}"
addOrEditKeyValPair "${VERSION_FILE}" "FTL_BRANCH" "${FTL_BRANCH}" fi
CORE_VERSION="$(get_local_version /etc/.pihole)"
addOrEditKeyValPair "${VERSION_FILE}" "CORE_VERSION" "${CORE_VERSION}" # get remote versions
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then GITHUB_CORE_VERSION="$(get_remote_version pi-hole)"
WEB_VERSION="$(get_local_version /var/www/html/admin)" addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_CORE_VERSION" "${GITHUB_CORE_VERSION}"
addOrEditKeyValPair "${VERSION_FILE}" "WEB_VERSION" "${WEB_VERSION}"
fi if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
GITHUB_WEB_VERSION="$(get_remote_version AdminLTE)"
FTL_VERSION="$(pihole-FTL version)" addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_WEB_VERSION" "${GITHUB_WEB_VERSION}"
addOrEditKeyValPair "${VERSION_FILE}" "FTL_VERSION" "${FTL_VERSION}" fi
if [[ "${DOCKER_TAG}" ]]; then GITHUB_FTL_VERSION="$(get_remote_version FTL)"
addOrEditKeyValPair "${VERSION_FILE}" "DOCKER_VERSION" "${DOCKER_TAG}" addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_FTL_VERSION" "${GITHUB_FTL_VERSION}"
fi
if [[ "${DOCKER_TAG}" ]]; then
GITHUB_DOCKER_VERSION="$(get_remote_version docker-pi-hole)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_DOCKER_VERSION" "${GITHUB_DOCKER_VERSION}"
fi fi

View file

@ -28,6 +28,6 @@
@reboot root /usr/sbin/logrotate --state /var/lib/logrotate/pihole /etc/pihole/logrotate @reboot root /usr/sbin/logrotate --state /var/lib/logrotate/pihole /etc/pihole/logrotate
# Pi-hole: Grab remote version every 24 hours # Pi-hole: Grab remote and local version every 24 hours
59 17 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker remote 59 17 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker
@reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker remote reboot @reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker reboot

View file

@ -2694,9 +2694,8 @@ main() {
# Download and compile the aggregated block list # Download and compile the aggregated block list
runGravity runGravity
# Force an update of the updatechecker # Update local and remote versions via updatechecker
/opt/pihole/updatecheck.sh /opt/pihole/updatecheck.sh
/opt/pihole/updatecheck.sh x remote
if [[ "${useUpdateVars}" == false ]]; then if [[ "${useUpdateVars}" == false ]]; then
displayFinalMessage "${pw}" displayFinalMessage "${pw}"