Skip to content

Commit

Permalink
ncp-update-nc: check skip major versions
Browse files Browse the repository at this point in the history
Signed-off-by: nachoparker <[email protected]>
  • Loading branch information
nachoparker committed Oct 18, 2021
1 parent cf4cfd8 commit 80575ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/ncp-update-nc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ cd "$BASEDIR"
DATADIR="$( grep datadirectory nextcloud/config/config.php | awk '{ print $3 }' | grep -oP "[^']*[^']" | head -1 )"
ncc status &>/dev/null || { echo "Nextcloud is currently down"; exit 1; }
[[ -d /var/www/nextcloud-old ]] && { echo "Nextcloud backup directory found. Interrupted or already running installation?"; exit 1; }
[[ -d /var/www/nextcloud ]] || { echo "Nextcloud directory not found" ; exit 1; }
[[ -d "$DATADIR" ]] || { echo "Nextcloud data directory not found" ; exit 1; }
[[ -d /var/www/nextcloud ]] || { echo "Nextcloud directory not found" ; exit 1; }
[[ -d "$DATADIR" ]] || { echo "Nextcloud data directory not found" ; exit 1; }

# check version
####################

[[ ${EUID} -eq 0 ]] && SUDO="sudo -u www-data"
CURRENT="$( $SUDO php /var/www/nextcloud/occ status | grep "version:" | awk '{ print $3 }' )"

MAJOR_CUR=$( cut -d. -f1 <<<"${CURRENT}" )
MAJOR_NEW=$( cut -d. -f1 <<<"${VER}" )
if [[ $((MAJOR_NEW - MAJOR_CUR)) -gt 1 ]]; then
echo "Upgrade cannot skip major versions. Please upgrade one major version at a time" >&2
exit 1
fi

grep -qP "\d+\.\d+\.\d+" <<<"$CURRENT" || { echo "Malformed version $CURRENT"; exit 1; }
grep -qP "\d+\.\d+\.\d+" <<<"$VER" || { echo "Malformed version $VER" ; exit 1; }

Expand Down

0 comments on commit 80575ae

Please sign in to comment.