From b5ea84d53d453d7bf04802e2e55dec75fec0a66d Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Mon, 1 Aug 2016 15:15:51 -0700 Subject: [PATCH] Support out-of-app config directory. The Nextcloud pi drive device is based upon snappy ubuntu core. Snaps are squashfs images which by definition are read-only. This makes the Nextcloud config read-only as well, which greatly limits its usefulness. This commit introduces support for hosting the config out of the main application (in the case of the snap, in a writable area so the rest of the application can remain read-only). It does this by using the environment variable `$NEXTCLOUD_CONFIG_DIR `. If it's set, it is used as the config directory. If not set, it uses the default `/config/`. Signed-off-by: Kyle Fazzari --- core/Controller/SetupController.php | 7 ++++++- lib/base.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php index fc1efe4c11b5b..a2f06db6d7259 100644 --- a/core/Controller/SetupController.php +++ b/core/Controller/SetupController.php @@ -40,7 +40,12 @@ class SetupController { * @param Setup $setupHelper */ function __construct(Setup $setupHelper) { - $this->autoConfigFile = \OC::$SERVERROOT.'/config/autoconfig.php'; + $config_directory = getenv('NEXTCLOUD_CONFIG_DIR'); + if ($config_directory) { + $this->autoConfigFile = $config_directory.'/autoconfig.php'; + } else { + $this->autoConfigFile = \OC::$SERVERROOT.'/config/autoconfig.php'; + } $this->setupHelper = $setupHelper; } diff --git a/lib/base.php b/lib/base.php index d22490ca5dc7e..bfb860b7c41c5 100644 --- a/lib/base.php +++ b/lib/base.php @@ -124,7 +124,12 @@ public static function initPaths() { } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { self::$configDir = OC::$SERVERROOT . '/tests/config/'; } else { - self::$configDir = OC::$SERVERROOT . '/config/'; + $config_directory = getenv('NEXTCLOUD_CONFIG_DIR'); + if($config_directory) { + self::$configDir = $config_directory.'/'; + } else { + self::$configDir = OC::$SERVERROOT . '/config/'; + } } self::$config = new \OC\Config(self::$configDir);