forked from ungleich-public/cdist-contrib
__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.
This commit is contained in:
parent
7490cef49e
commit
c24aedd4db
9 changed files with 38 additions and 110 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
# Get the installdir
|
||||
installdir="$( "$__type_explorer/installdir" )"
|
||||
installdir="/$__object_id"
|
||||
|
||||
# Check if the tools are available
|
||||
if [ -d "$installdir" ]; then
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
# __nextcloud/explorer/installdir
|
||||
|
||||
# Detects the directory nextcloud should be installed to.
|
||||
|
||||
|
||||
# by parameter or auto-detection
|
||||
webroot="$( "$__type_explorer/webroot" )"
|
||||
if [ -z "$webroot" ]; then
|
||||
echo "no installdir given and no webroot directory found" >&2
|
||||
echo "no place to install found; set it via --webroot" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# assemble directory with the object id
|
||||
printf "%s/%s\n" "$webroot" "$__object_id"
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
# Get the install directory
|
||||
installdir="$( "$__type_explorer/installdir" )"
|
||||
installdir="/$__object_id"
|
||||
|
||||
# Check if the installation directory exists
|
||||
if [ -d "$installdir" ]; then
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
# __nextcloud/explorer/webroot
|
||||
|
||||
# Detects the webroot if any
|
||||
|
||||
|
||||
# Just check if there is some directory and echo + exit on success
|
||||
#
|
||||
# Arguments:
|
||||
# 1: the directory to check
|
||||
check_dir() {
|
||||
if [ -d "$1" ]; then
|
||||
echo "$1"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Check the user choice
|
||||
parameter="$__object/parameter/webroot"
|
||||
if [ -f "$parameter" ]; then
|
||||
cat "$parameter"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Maybe checking standard webserver configs ..
|
||||
|
||||
# Check if there are default directories
|
||||
check_dir "/srv/www"
|
||||
check_dir "/var/www/html"
|
||||
check_dir "/var/www"
|
||||
|
||||
|
||||
# do nothing if no webroot found
|
|
@ -49,9 +49,8 @@ version_is="$( cat "$__object/explorer/version" )"
|
|||
version_should="$( cat "$__object/parameter/version" )"
|
||||
|
||||
# the install directory
|
||||
installdir="$( cat "$__object/explorer/installdir" )"
|
||||
updatedir="$( dirname "$installdir" )"
|
||||
tarballdir="$updatedir/.$__object_id"
|
||||
installdir="/$__object_id"
|
||||
tarballdir="$(dirname "$installdir")/.$(basename "$installdir")"
|
||||
|
||||
# get used user and group
|
||||
user="$( cat "$__object/parameter/user" )"
|
||||
|
@ -77,11 +76,10 @@ fi
|
|||
# Remove the old folder and replace it with the new one.
|
||||
if [ "$upgrade" ]; then
|
||||
cat << REMOTE
|
||||
cd '$updatedir'
|
||||
|
||||
chown '$user':'$group' -R '$tarballdir'
|
||||
REMOTE
|
||||
|
||||
# no more changes from the user
|
||||
occ_maintainer_mode_on
|
||||
cat << REMOTE
|
||||
|
||||
|
@ -91,8 +89,6 @@ mv '$installdir/data' '$tarballdir'
|
|||
rm -rf '$installdir'
|
||||
mv '$tarballdir' '$installdir'
|
||||
|
||||
cd '$installdir'
|
||||
|
||||
REMOTE
|
||||
|
||||
# do some maintainer stuff
|
||||
|
@ -227,9 +223,11 @@ if [ "$data_old" ] && [ "$data_old" != "$data_new" ]; then
|
|||
# not be moved.
|
||||
occ config:system:set datadirectory --type=string --value "'$data_new'"
|
||||
cat << REMOTE
|
||||
cd '$installdir' # only for the users safety
|
||||
|
||||
rm -rf '$data_new'
|
||||
mkdir -p '$(dirname "$data_new")' # if the parent not exists
|
||||
mv '$data_old' '$data_new'
|
||||
mv -T '$data_old' '$data_new'
|
||||
|
||||
REMOTE
|
||||
fi
|
||||
|
|
|
@ -8,11 +8,9 @@ cdist-type__nextcloud - Installs and manages a nextcloud instance
|
|||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This type installs, upgrades and configure a nextcloud instance.
|
||||
|
||||
It installs the application in the webspace based on the object id as relative
|
||||
path from the webroot. If you want to install it directly in the webroot, you
|
||||
must trick out this type by setting the webroot as parent directory.
|
||||
This type installs, upgrades and configure a nextcloud instance. The object
|
||||
id is the absolute path for the installation directory. Nextcloud will be
|
||||
installed unter that directory.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
|
@ -40,11 +38,6 @@ admin-password
|
|||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
webroot
|
||||
The webroot which will be used as basis for the installation. This may be
|
||||
already detected by an explorer. Must be an absolute path (starting with a
|
||||
slash).
|
||||
|
||||
mode
|
||||
Sets the unix file mode of the nextcloud directory. This is not inherited
|
||||
to child files or folders. Defaults to `755`.
|
||||
|
@ -152,18 +145,6 @@ database-prefix
|
|||
``oc_``.
|
||||
|
||||
|
||||
WEBROOT DETECTION
|
||||
-----------------
|
||||
As the `object id` is the install path relatively from the webroot, it must be
|
||||
known somehow. Therefor, it will try to detect a good location for it. You can
|
||||
set a custom webroot via the `--webroot` parameter. As default, following
|
||||
directories will be checked if they exist to be the webroot:
|
||||
|
||||
1. ``/srv/www/``
|
||||
2. ``/var/www/html/``
|
||||
3. ``/var/www/``
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
installed
|
||||
|
@ -185,10 +166,6 @@ installed. See the parameter description of `--version` for detailed
|
|||
information. The problem can be fixed by bumping the version value to at least
|
||||
the version that is currently installed or use the parameter `--install-only`.
|
||||
|
||||
The type aborts if there is no webroot given as parameter and no could be
|
||||
detected by the type itself. Please set the webroot via `--webroot` or extend
|
||||
this type.
|
||||
|
||||
It may abort if the data directory can not be moved correctly. Then, the
|
||||
nextcloud configuration is broken and must be resolved manually: Move the data
|
||||
directory to the correct location or change the configuration to point to the
|
||||
|
@ -210,20 +187,21 @@ EXAMPLES
|
|||
|
||||
# minimal nextcloud installation with sqlite and other defaults
|
||||
# please only use sqlite for minimal or test installations as recommend :)
|
||||
__nextcloud nextcloud --version 20.0.0 --admin-password "iaminsecure" \
|
||||
__nextcloud /var/www/html/nextcloud --version 20.0.0 \
|
||||
--admin-password "iaminsecure" \
|
||||
--host localhost --host nextcloud
|
||||
|
||||
# installation under the webroot
|
||||
__nextcloud /var/www/html/ --version 20.0.0
|
||||
--admin-password "notthatsecure" --host mycloud.example.com
|
||||
|
||||
# more extensive configuration
|
||||
__nextcloud cloud --version 20.0.0 --admin-password "iaminsecure" \
|
||||
__nextcloud /var/www/cloud --version 20.0.0 --admin-password "iaminsecure" \
|
||||
--host localhost --host nextcloud --host 192.168.1.67 \
|
||||
--data-directory /var/lib/nextcloud/what \
|
||||
--database-type mysql --database-host "localhost" --database-name "nextcloud" \
|
||||
--database-user "test" --database-password "not-a-good-password"
|
||||
|
||||
# install it in the webroot /var/www/html
|
||||
__nextcloud html --version 20.0.0 --admin-password "notthatsecure" \
|
||||
--webroot "/var/www" --host localhost
|
||||
|
||||
|
||||
NOTES
|
||||
-----
|
||||
|
@ -277,6 +255,13 @@ php dependencies, but there are not recognised by the server-internal php
|
|||
environment. This can happen after a database migration between different
|
||||
database types, as it installs the database module only when it is required.
|
||||
|
||||
If the tarball needs to be downloaded, it will be directly downloaded into the
|
||||
directory ``/tmp`` and will be unpacked to the destination for an installation
|
||||
or to the same directory but prefixed with a dot for an update. It will
|
||||
download it into the temp directory because it does not find a better location.
|
||||
In legacy, it was downloaded to the parent directory, but this may not the best
|
||||
location as the installation dir can be everywhere.
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
|
|
@ -76,8 +76,7 @@ user="$(cat "$__object/parameter/user")"
|
|||
group="$(cat "$__object/parameter/group")"
|
||||
|
||||
# Get the installation directory
|
||||
webroot="$(cat "$__object/explorer/webroot")"
|
||||
installdir="$(cat "$__object/explorer/installdir")"
|
||||
installdir="/$__object_id"
|
||||
|
||||
# Set permissions after the nextcloud installation/upgrade is done
|
||||
# FIXME maybe less strict if some parameter is not given by the user?
|
||||
|
@ -111,28 +110,25 @@ if [ "$version_is" ]; then
|
|||
fi
|
||||
|
||||
# Set destination to a temporary directory
|
||||
destination="$webroot/.$__object_id"
|
||||
destination="$(dirname "$installdir")/.$(basename "$installdir")"
|
||||
fi
|
||||
else
|
||||
# Set destination to the real destination
|
||||
destination="$webroot/$__object_id"
|
||||
destination="$installdir"
|
||||
fi
|
||||
|
||||
# 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
|
||||
updatedir="$( dirname "$installdir" )"
|
||||
|
||||
# Be sure the parent directory exists for installation
|
||||
__directory "$updatedir" --parents
|
||||
|
||||
require="__directory$updatedir" \
|
||||
__download "$updatedir/nextcloud.tar.bz2" \
|
||||
# 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}')" # must be a required parameter??
|
||||
--sum "sha256:$(curl -sS -L "$nextcloud_sum" | awk '{print $1}')"
|
||||
|
||||
require="__download$updatedir/nextcloud.tar.bz2" \
|
||||
__unpack "$updatedir/nextcloud.tar.bz2" \
|
||||
# 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"
|
||||
fi
|
||||
|
|
|
@ -270,7 +270,7 @@ fi
|
|||
# misc
|
||||
conf_array host trusted_domains
|
||||
|
||||
# Already set via the installer
|
||||
# If already set via the installer, we don't need to do this
|
||||
# set default values from the nextcloud installer to do not override them
|
||||
if [ -z "$install" ]; then
|
||||
# Database to check if the type changed
|
||||
|
@ -312,5 +312,5 @@ if [ -z "$install" ]; then
|
|||
esac
|
||||
|
||||
# data-dir is handled in the gencode-remote
|
||||
#conf_string data-directory datadirectory installdef "$(cat "$__object/explorer/installdir")/$__object_id/data"
|
||||
#conf_string data-directory datadirectory installdef "/$__object_id/data"
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
mode
|
||||
user
|
||||
group
|
||||
webroot
|
||||
database-type
|
||||
database-host
|
||||
database-name
|
||||
|
|
Loading…
Reference in a new issue