From cb24213a316d41aa6ef96a64932e9b6a3d8e7124 Mon Sep 17 00:00:00 2001 From: szaimen Date: Mon, 23 May 2022 17:19:23 +0200 Subject: [PATCH] fix windows host access correctly Signed-off-by: szaimen --- Containers/mastercontainer/start.sh | 4 +++- php/src/Data/ConfigurationManager.php | 4 ++++ php/src/Docker/DockerActionManager.php | 4 ++++ php/templates/containers.twig | 4 ++-- readme.md | 22 ++++++++++++++++++---- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index fba71033..d008ca91 100755 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -78,7 +78,9 @@ fi # Check for other options if [ -n "$NEXTCLOUD_DATADIR" ]; then - if ! echo "$NEXTCLOUD_DATADIR" | grep -q "^/" || [ "$NEXTCLOUD_DATADIR" = "/" ]; then + if [ "$NEXTCLOUD_DATADIR" = "nextcloud_aio_nextcloud_datadir" ]; then + echo "NEXTCLOUD_DATADIR is set to $NEXTCLOUD_DATADIR" + elif ! echo "$NEXTCLOUD_DATADIR" | grep -q "^/" || [ "$NEXTCLOUD_DATADIR" = "/" ]; then echo "You've set NEXTCLOUD_DATADIR but not to an allowed value. The string must start with '/' and must not be equal to '/'. It is set to '$NEXTCLOUD_DATADIR'." diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index fc440af6..40ecbdde 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -289,6 +289,8 @@ class ConfigurationManager $isValidPath = false; if (str_starts_with($location, '/') && !str_ends_with($location, '/')) { $isValidPath = true; + } elseif ($location === 'nextcloud_aio_backupdir') { + $isValidPath = true; } if (!$isValidPath) { @@ -312,6 +314,8 @@ class ConfigurationManager $isValidPath = false; if (str_starts_with($location, '/') && !str_ends_with($location, '/')) { $isValidPath = true; + } elseif ($location === 'nextcloud_aio_backupdir') { + $isValidPath = true; } if (!$isValidPath) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index b4f03b44..262b0d81 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -185,6 +185,10 @@ class DockerActionManager '/', ]; + if ($volume->name === 'nextcloud_aio_nextcloud_datadir' || $volume->name === 'nextcloud_aio_backupdir') { + return; + } + $firstChar = substr($volume->name, 0, 1); if(!in_array($firstChar, $forbiddenChars)) { $this->guzzleClient->request( diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 003bc249..9c38781d 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -144,7 +144,7 @@ The folder path that you enter must start with / and must not end with /.

An example for Linux is /mnt/backup.
For macOS it may be /var/backup.
- On Windows it might be /host_mnt/c/backup. (This Windows example would be equivalent to 'C:\backup' on the Windows host. So you need to translate the path that you want to use into the correct format.)

+ On Windows it must be nextcloud_aio_backupdir. You need to create the 'nextcloud_aio_backupdir' volume beforehand by following this documentation: click here

⚠ Note that the backup archive must be located in a subfolder of the folder that you enter here and the subfolder which contains the archive must be named 'borg'. Otherwise will the backup container not find the backup archive!

{% endif %} {% else %} @@ -298,7 +298,7 @@ The folder path that you enter must start with / and must not end with /.

An example for Linux is /mnt/backup.
For macOS it may be /var/backup.
- On Windows it might be /host_mnt/c/backup. (This Windows example would be equivalent to 'C:\backup' on the Windows host. So you need to translate the path that you want to use into the correct format.)

+ On Windows it must be nextcloud_aio_backupdir. You need to create the 'nextcloud_aio_backupdir' volume beforehand by following this documentation: click here

{% endif %} {% if borg_backup_host_location != "" %} diff --git a/readme.md b/readme.md index 17b74312..f036cb1f 100644 --- a/readme.md +++ b/readme.md @@ -94,7 +94,14 @@ docker run -it ^ nextcloud/all-in-one:latest ``` -**Please note:** AIO works on Windows in general but due to a bug in `Docker for Windows`, it currently does not support mounting directories from the host into AIO which means that `NEXTCLOUD_DATADIR`, `NEXTCLOUD_MOUNT` do not work and the built-in backup solution is not able to write to the host OS. See https://github.com/nextcloud/all-in-one/discussions/600. +**Please note:** In order to make the built-in backup solution able to back up to the host system, you need to create a volume with the name `nextcloud_aio_backupdir` beforehand: +``` +docker volume create --driver local --name nextcloud_aio_backupdir ^ + -o device="/host_mnt/c/your/backup/path" ^ + -o type="none" ^ + -o o="bind" +``` +(This Windows example would be equivalent to `C:\your\backup\path` on the Windows host. So you need to translate the path that you want to use into the correct format.) @@ -320,7 +327,14 @@ You can configure the Nextcloud container to use a specific directory on your ho - An example for Linux is `-e NEXTCLOUD_DATADIR="/mnt/ncdata"`. - On macOS it might be `-e NEXTCLOUD_DATADIR="/var/nextcloud-data"` - For Synology it may be `-e NEXTCLOUD_DATADIR="/volume1/docker/nextcloud/data"`. -- On Windows it might be `-e NEXTCLOUD_DATADIR="/host_mnt/c/your/data/path"` (This Windows example would be equivalent to `C:\your\data\path` on the Windows host. So you need to translate the path that you want to use into the correct format.) +- On Windows it must be `-e NEXTCLOUD_DATADIR="nextcloud_aio_nextcloud_datadir"`. In order to use this, you need to create the `nextcloud_aio_nextcloud_datadir` volume beforehand: + ``` + docker volume create --driver local --name nextcloud_aio_nextcloud_datadir ^ + -o device="/host_mnt/c/your/data/path" ^ + -o type="none" ^ + -o o="bind" + ``` + (This Windows example would be equivalent to `C:\your\data\path` on the Windows host. So you need to translate the path that you want to use into the correct format.) ⚠ Please make sure to apply the correct permissions to the chosen directory before starting Nextcloud the first time (not needed on Windows). @@ -336,9 +350,9 @@ By default, the Nextcloud container is confined and cannot access directories on - Two examples for Linux are `-e NEXTCLOUD_MOUNT="/mnt/"` and `-e NEXTCLOUD_MOUNT="/media/"`. - For Synology it may be `-e NEXTCLOUD_MOUNT="/volume1/"`. -- On Windows it might be `-e NEXTCLOUD_MOUNT="/host_mnt/c"` (This Windows example would be equivalent to `C:\` on the Windows host. So you need to translate the path that you want to use into the correct format.) +- On Windows is this option not supported. -After using this option, please make sure to apply the correct permissions to the directories that you want to use in Nextcloud (not needed on Windows). E.g. `sudo chown -R 33:0 /mnt/your-drive-mountpoint` and `sudo chmod -R 750 /mnt/your-drive-mountpoint` should make it work on Linux when you have used `-e NEXTCLOUD_MOUNT="/mnt/"`. +After using this option, please make sure to apply the correct permissions to the directories that you want to use in Nextcloud. E.g. `sudo chown -R 33:0 /mnt/your-drive-mountpoint` and `sudo chmod -R 750 /mnt/your-drive-mountpoint` should make it work on Linux when you have used `-e NEXTCLOUD_MOUNT="/mnt/"`. You can then navigate to the apps management page, activate the external storage app, navigate to `https://your-nc-domain.com/settings/admin/externalstorages` and add a local external storage directory that will be accessible inside the container at the same place that you've entered. E.g. `/mnt/your-drive-mountpoint` will be mounted to `/mnt/your-drive-mountpoint` inside the container, etc.