mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-09-13 01:56:28 +08:00
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:
commit
af93aeebd7
4 changed files with 55 additions and 0 deletions
|
@ -54,6 +54,21 @@ else
|
||||||
sleep 10
|
sleep 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for other options
|
||||||
|
if [ -n "$NEXTCLOUD_MOUNT" ]; then
|
||||||
|
if ! echo "$NEXTCLOUD_MOUNT" | grep -q "^/mnt/" \
|
||||||
|
&& ! echo "$NEXTCLOUD_MOUNT" | grep -q "^/media/" \
|
||||||
|
&& ! echo "$NEXTCLOUD_MOUNT" | grep -q "^/var/backups$"
|
||||||
|
then
|
||||||
|
echo "You've set NEXCLOUD_MOUNT but not to an allowed value.
|
||||||
|
The string must be equal to/start with '/mnt/' or '/media/' or be equal to '/var/backups'."
|
||||||
|
exit 1
|
||||||
|
elif [ "$NEXTCLOUD_MOUNT" = "/mnt/ncdata" ] || echo "$NEXTCLOUD_MOUNT" | grep -q "^/mnt/ncdata/"; then
|
||||||
|
echo "/mnt/ncdata and /mnt/ncdata/ are not allowed for NEXTCLOUD_MOUNT."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Add important folders
|
# Add important folders
|
||||||
mkdir -p /mnt/docker-aio-config/data/
|
mkdir -p /mnt/docker-aio-config/data/
|
||||||
mkdir -p /mnt/docker-aio-config/session/
|
mkdir -p /mnt/docker-aio-config/session/
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
"name": "nextcloud_aio_nextcloud_data",
|
"name": "nextcloud_aio_nextcloud_data",
|
||||||
"location": "/mnt/ncdata",
|
"location": "/mnt/ncdata",
|
||||||
"writeable": true
|
"writeable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "%NEXTCLOUD_MOUNT%",
|
||||||
|
"location": "%NEXTCLOUD_MOUNT%",
|
||||||
|
"writeable": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"environmentVariables": [
|
"environmentVariables": [
|
||||||
|
|
|
@ -67,6 +67,18 @@ class ContainerDefinitionFetcher
|
||||||
continue;
|
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(
|
$volumes->AddVolume(
|
||||||
new ContainerVolume(
|
new ContainerVolume(
|
||||||
$value['name'],
|
$value['name'],
|
||||||
|
|
|
@ -259,4 +259,27 @@ class ConfigurationManager
|
||||||
|
|
||||||
return $config['backup-mode'];
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue