From ee06a04f5191628691c843af667143aa1a163256 Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 27 Feb 2023 14:48:49 +0100 Subject: [PATCH] fix datadir permission check Signed-off-by: Simon L --- Containers/nextcloud/entrypoint.sh | 4 ++++ manual-install/update-yaml.sh | 1 + php/containers.json | 3 ++- php/src/Data/ConfigurationManager.php | 8 ++++++++ php/src/Docker/DockerActionManager.php | 6 ++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 70f381f5..5316fb18 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -212,6 +212,10 @@ if ! [ -f "$NEXTCLOUD_DATA_DIR/skip.update" ]; then exit 1 fi + if [ "$SKIP_DATA_DIRECTORY_PERMISSION_CHECK" = yes ]; then + php /var/www/html/occ config:system:set check_data_directory_permissions --value=false --type=bool + fi + # Try to force generation of appdata dir: php /var/www/html/occ maintenance:repair diff --git a/manual-install/update-yaml.sh b/manual-install/update-yaml.sh index 7d2446a1..82206a2e 100644 --- a/manual-install/update-yaml.sh +++ b/manual-install/update-yaml.sh @@ -71,6 +71,7 @@ sed -i 's|APACHE_MAX_SIZE=|APACHE_MAX_SIZE=10737418240 # This needs to sed -i 's|NEXTCLOUD_MAX_TIME=|NEXTCLOUD_MAX_TIME=3600 # This allows to change the upload time limit of the Nextcloud container|' sample.conf sed -i 's|NEXTCLOUD_TRUSTED_CACERTS_DIR=|NEXTCLOUD_TRUSTED_CACERTS_DIR=/usr/local/share/ca-certificates/my-custom-ca # Nextcloud container will trust all the Certification Authorities, whose certificates are included in the given directory.|' sample.conf sed -i 's|UPDATE_NEXTCLOUD_APPS=|UPDATE_NEXTCLOUD_APPS="no" # When setting to "yes" (with quotes), it will automatically update all installed Nextcloud apps upon container startup on saturdays.|' sample.conf +sed -i 's|SKIP_DATA_DIRECTORY_PERMISSION_CHECK=|SKIP_DATA_DIRECTORY_PERMISSION_CHECK="no" # When setting to "yes" (with quotes), it will skip the datadir permission check upon the initial Nextcloud installation.|' sample.conf sed -i 's|APACHE_PORT=|APACHE_PORT=443 # Changing this to a different value than 443 will allow you to run it behind a web server or reverse proxy (like Apache, Nginx and else).|' sample.conf sed -i 's|APACHE_IP_BINDING=|APACHE_IP_BINDING=0.0.0.0 # This can be changed to e.g. 127.0.0.1 if you want to run AIO behind a web server or reverse proxy (like Apache, Nginx and else) and if that is running on the same host and using localhost to connect|' sample.conf sed -i 's|TALK_PORT=|TALK_PORT=3478 # This allows to adjust the port that the talk container is using.|' sample.conf diff --git a/php/containers.json b/php/containers.json index 154c8bb1..a0294656 100644 --- a/php/containers.json +++ b/php/containers.json @@ -160,7 +160,8 @@ "TRUSTED_CACERTS_DIR=%NEXTCLOUD_TRUSTED_CACERTS_DIR%", "STARTUP_APPS=%NEXTCLOUD_STARTUP_APPS%", "ADDITIONAL_APKS=%NEXTCLOUD_ADDITIONAL_APKS%", - "ADDITIONAL_PHP_EXTENSIONS=%NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS%" + "ADDITIONAL_PHP_EXTENSIONS=%NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS%", + "SKIP_DATA_DIRECTORY_PERMISSION_CHECK=%SKIP_DATA_DIRECTORY_PERMISSION_CHECK%" ], "restart": "unless-stopped", "devices": [ diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index e116e44b..b7f48176 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -736,6 +736,14 @@ class ConfigurationManager return false; } + public function shouldDataDirectoryPermissionCheckGetSkipped() : bool { + $datadir = $this->GetNextcloudDatadirMount(); + if ($datadir === 'nextcloud_aio_nextcloud_datadir' || str_starts_with($datadir, '/run/desktop/mnt/host/')) { + return true; + } + return false; + } + public function GetNextcloudStartupApps() : string { $apps = getenv('NEXTCLOUD_STARTUP_APPS'); if (is_string($apps)) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 715869a0..b22ca032 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -348,6 +348,12 @@ class DockerActionManager $replacements[1] = $this->configurationManager->GetNextcloudAdditionalApks(); } elseif ($out[1] === 'NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS') { $replacements[1] = $this->configurationManager->GetNextcloudAdditionalPhpExtensions(); + } elseif ($out[1] === 'SKIP_DATA_DIRECTORY_PERMISSION_CHECK') { + if ($this->configurationManager->shouldDataDirectoryPermissionCheckGetSkipped()) { + $replacements[1] = 'yes'; + } else { + $replacements[1] = ''; + } } else { $secret = $this->configurationManager->GetSecret($out[1]); if ($secret === "") {