matze c24aedd4db __nextcloud: remove --webroot parameter
Because the detection of the webroot is not that good, it was removed.
Now, the object id contains the full path of the nextcloud installation.

This changes the installation process a bit, as it will download the
tarball to /tmp rather the webroot.

Also, this commit contains a bit overhaul work.
2020-11-15 16:21:56 +01:00

135 lines
4.5 KiB
Executable file

#!/bin/sh -e
# __nextcloud/manifest
# Version compare function original from __sensible_editor
# Arguments:
# 1: version of which $2 should be checked against
# 2: version which should be bigger than or equal with $1
# Return code:
# 0: $1 is bigger than $2
# 1-n: $1 is smaller than or equal $2
version_ge() {
printf "%s" "$1" | awk -F '[^0-9.]' -v target="$2" '
function max(x, y) { return x > y ? x : y }
nx = split($1, x, ".")
ny = split(target, y, ".")
for (i = 1; i <= max(nx, ny); ++i) {
diff = int(x[i]) - int(y[i])
if (diff == 0) continue
exit (diff < 0)
exit 1
}'; return $?
# Check support status
os="$(cat "$__global/explorer/os")"
case "$os" in
# PHP main
__package php-cli
# to unpack the package
__package bzip2
# install misc packages for nextcloud
__package ffmpeg
# PHP modules
for package in php-gd php-json php-mysql php-curl php-mbstring php-intl \
php-imagick php-xml php-zip php-bz2 php-bcmath php-gmp
require="__package/php-cli" __package $package
# check support database additions (but don't remove junk of old ones)
case "$(cat "$__object/parameter/database-type")" in
__package php-sqlite3
__package php-mysql
__package php-pgsql
# unkown distro - what to install?
printf "unkown %s, don't know what to install ..\n" "$os" >&2
echo "checkout the __nextcloud/manifest to contribute a working package list" >&2
exit 1
# Get the user and group
mode="$(cat "$__object/parameter/mode")"
user="$(cat "$__object/parameter/user")"
group="$(cat "$__object/parameter/group")"
# Get the installation directory
# Set permissions after the nextcloud installation/upgrade is done
# FIXME maybe less strict if some parameter is not given by the user?
# permissions also partily set via the gencode-remote
require="__nextcloud/$__object_id" __directory "$installdir" \
--mode "$mode" --owner "$user" --group "$group"
# Get version information
version_is="$( cat "$__object/explorer/version" )"
version_should="$( cat "$__object/parameter/version" )"
# The version URI
# Check if there is a current installation. It depends where the upstream
# tarball should be unpacked (directly or moved in a later stage).
if [ "$version_is" ]; then
# Only set and check the version if a upgrade is allowed.
# if this block will be skipped, no upgrade will be done
if ! [ -f "$__object/parameter/install-only" ]; then
# Block downgrades as there are may caused from the automatic upgrader
# if the current version is higher than the version that should be installed
if version_ge "$version_is" "$version_should"; then
# it's an error if the current version is higher than the one that should be installed
printf "The current nextcloud version '%s' is higher than the version that should be installed (%s)\n" \
"$version_is" "$version_should" >&2
printf "Please bump the nextcloud version to '%s' or higher!\n" "$version_is" >&2
exit 2
# Set destination to a temporary directory
destination="$(dirname "$installdir")/.$(basename "$installdir")"
# Set destination to the real destination
# Install/Upgrade the nextcloud version if there is a destination set.
# it checks if it is necessary and intended to upgrade
if [ "$destination" ] && [ "$version_is" != "$version_should" ]; then
# download it to the tmp directory
# FIXME --sum is currently rather a hack, see cdist#844
__download "/tmp/nextcloud-${version_should}.tar.bz2" \
--url "$nextcloud_uri" \
--sum "sha256:$(curl -sS -L "$nextcloud_sum" | awk '{print $1}')"
# after this, unpack it from /tmp to $destination
require="__download/tmp/nextcloud-${version_should}.tar.bz2" \
__unpack "/tmp/nextcloud-${version_should}.tar.bz2" \
--tar-strip 1 \
--destination "$destination"