Merge pull request #254 from nextcloud/enh/76/allow-to-define-a-nextcloud-mountpoint

allow nextcloud to access outside directories
This commit is contained in:
Simon L 2022-02-23 18:11:35 +01:00 committed by GitHub
commit af93aeebd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 0 deletions

View file

@ -67,6 +67,18 @@ class ContainerDefinitionFetcher
continue;
}
}
if($value['name'] === '%NEXTCLOUD_MOUNT%') {
$value['name'] = $this->configurationManager->GetNextcloudMount();
if($value['name'] === '') {
continue;
}
}
if($value['location'] === '%NEXTCLOUD_MOUNT%') {
$value['location'] = $this->configurationManager->GetNextcloudMount();
if($value['location'] === '') {
continue;
}
}
$volumes->AddVolume(
new ContainerVolume(
$value['name'],

View file

@ -259,4 +259,27 @@ class ConfigurationManager
return $config['backup-mode'];
}
public function GetNextcloudMount() : string {
$mount = getenv('NEXTCLOUD_MOUNT');
if ($mount === false) {
$config = $this->GetConfig();
if (!isset($config['nextcloud_mount'])) {
$config['nextcloud_mount'] = '';
}
return $config['nextcloud_mount'];
} else {
if(file_exists(DataConst::GetConfigFile())) {
$config = $this->GetConfig();
if (!isset($config['nextcloud_mount'])) {
$config['nextcloud_mount'] = '';
}
if ($mount !== $config['nextcloud_mount']) {
$config['nextcloud_mount'] = $mount;
$this->WriteConfig($config);
}
}
return $mount;
}
}
}