mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
library.sh: Respect requested NC version in determine_nc_update_version
Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
parent
e7a40c7cc9
commit
e5113f4601
@ -7,7 +7,7 @@ set -e
|
||||
source /usr/local/etc/library.sh # sets NCLATESTVER
|
||||
|
||||
CURRENT="$(nc_version)"
|
||||
NEXT_VERSION="$(determine_nc_upgrade_version "${CURRENT}" "${NCLATESTVER?}")"
|
||||
NEXT_VERSION="$(determine_nc_update_version "${CURRENT}" "${NCLATESTVER?}")"
|
||||
[[ -n "$NEXT_VERSION" ]] || exit 0
|
||||
|
||||
NOTIFIED=/var/run/.nc-version-notified
|
||||
|
||||
@ -22,7 +22,13 @@ ncc status &>/dev/null || { [[ "$DBG" == x ]] && ncc status; echo "Next
|
||||
|
||||
[[ ${EUID} -eq 0 ]] && SUDO="sudo -u www-data"
|
||||
CURRENT="$(nc_version)"
|
||||
TARGET_VERSION="$(determine_nc_upgrade_version "${CURRENT?}" "${VER?}")"
|
||||
if [[ "$VER" == "0" ]] || [[ "$VER" == "" ]]
|
||||
then
|
||||
REQUESTED_VERSION="${NCLATESTVER?}"
|
||||
else
|
||||
REQUESTED_VERSION="$VER"
|
||||
fi
|
||||
TARGET_VERSION="$(determine_nc_update_version "${CURRENT?}" "${NCLATESTVER}" "${REQUESTED_VERSION}")"
|
||||
[[ "$TARGET_VERSION" == "$CURRENT" ]] && {
|
||||
echo "Nextcloud version ${CURRENT} is already installed. Nothing to do."
|
||||
exit 0
|
||||
@ -52,9 +58,9 @@ grep -qP "\d+\.\d+\.\d+" <<<"$TARGET_VERSION" || { echo "Malformed version $TA
|
||||
|
||||
echo "Current Nextcloud version $CURRENT"
|
||||
echo "Available Nextcloud version $TARGET_VERSION"
|
||||
if [[ "$TARGET_VERSION" != "$VER" ]]
|
||||
if [[ "$TARGET_VERSION" != "$REQUESTED_VERSION" ]]
|
||||
then
|
||||
echo "INFO: You have requested an update to '$VER', but a direct update to '$VER' cannot be performed, so the latest available version that can be updated to has been selected automatically."
|
||||
echo "INFO: You have requested an update to '${REQUESTED_VERSION}', but a direct update to '${REQUESTED_VERSION}' cannot be performed, so the latest available version that can be updated to has been selected automatically."
|
||||
fi
|
||||
|
||||
# make sure that cron.php is not running and there are no pending jobs
|
||||
|
||||
@ -12,12 +12,6 @@ LATEST="$NCLATESTVER"
|
||||
|
||||
configure()
|
||||
{
|
||||
[[ "$VERSION" == "0" ]] && VERSION="$LATEST"
|
||||
if ! is_docker && ! is_more_recent_than "24.0.0" "${VERSION}" && is_more_recent_than "8.1.0" "${PHPVER}.0" && [[ " ${BASH_SOURCE[*]} " =~ .*" /home/www/ncp-launcher.sh ".* ]]
|
||||
then
|
||||
echo "We need to upgrade PHP. This process cannot be performed from the web UI. Please use 'ncp-config' from the terminal (via SSH or direct access) to update Nextcloud instead. Future updates can again be run from the web UI"
|
||||
exit 1
|
||||
fi
|
||||
bash /usr/local/bin/ncp-update-nc "$VERSION"
|
||||
}
|
||||
|
||||
|
||||
@ -519,16 +519,29 @@ function nc_version()
|
||||
ncc status | grep "versionstring:" | awk '{ print $3 }'
|
||||
}
|
||||
|
||||
function determine_nc_upgrade_version() {
|
||||
function determine_nc_update_version() {
|
||||
local current supported current_maj supported_maj versions next_version
|
||||
current="${1?}"
|
||||
supported="${2?}"
|
||||
requested="${3:-latest}"
|
||||
|
||||
#CURRENT="$(ncc status | grep "versionstring:" | awk '{ print $3 }')"
|
||||
current_maj="${current%%.*}"
|
||||
supported_maj="${supported%%.*}"
|
||||
versions="$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/nextcloud/server/releases?per_page=100 | jq -r '.[].tag_name' | grep -v -e 'rc.$' -e 'beta.$' | sort -V)"
|
||||
requested_maj="${requested%%.*}"
|
||||
|
||||
# If valid version is requested -> direct update, don't consider anything else
|
||||
if [[ "$requested" =~ ^[0-9.]*$ ]] && [[ "$requested_maj" -le "$((current_maj + 1))" ]]
|
||||
then
|
||||
echo "$requested"
|
||||
return 0
|
||||
fi
|
||||
|
||||
versions="$(curl -q -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/nextcloud/server/releases?per_page=100 | jq -r '.[].tag_name' | grep -v -e 'rc.$' -e 'beta.$' | sort -V)"
|
||||
next_version="$(grep "v${current_maj}." <<<"${versions}" | tail -n 1 | tr -d 'v')"
|
||||
next_version_maj="${next_version%%.*}"
|
||||
next_version_min="${next_version#*.}"
|
||||
next_version_min="${next_version_min%%.*}"
|
||||
|
||||
if [[ "${next_version}" == "${current}" ]]
|
||||
then
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user