From: Sarah Hoffmann Date: Tue, 15 Dec 2020 12:57:34 +0000 (+0100) Subject: introduce dotenv parsing for setup.php X-Git-Tag: v3.7.0~66^2~15 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/25bdd7c6d99f99e5fe01c86477be1dcabc35ec98 introduce dotenv parsing for setup.php This adds the notion of a project directory. This is the directory that holds all necessary files for one specific installation of Nominatim. Dotenv looks for an .env file in this directory and adds it to the global environment together with the defaults from Nominatim's data directory. Add's symfony's dotenv library as a new dependency. --- diff --git a/cmake/script.tmpl b/cmake/script.tmpl index 1b0cab64..4d9224b0 100755 --- a/cmake/script.tmpl +++ b/cmake/script.tmpl @@ -3,7 +3,5 @@ @define('CONST_BinDir', '@CMAKE_SOURCE_DIR@/utils'); @define('CONST_LibDir', '@CMAKE_SOURCE_DIR@/lib'); @define('CONST_DataDir', '@CMAKE_SOURCE_DIR@'); -@define('CONST_InstallDir', '@CMAKE_BINARY_DIR@'); -require_once(CONST_InstallDir.'/settings/settings.php'); require_once(CONST_BinDir.'/@script_source@'); diff --git a/lib/lib.php b/lib/lib.php index fcd22066..9861cdd0 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,5 +1,23 @@ load($sProjectDir.'/.env'); + } + $dotenv->load(CONST_DataDir.'/settings/env.defaults'); +} + function fail($sError, $sUserError = false) { if (!$sUserError) $sUserError = $sError; diff --git a/utils/setup.php b/utils/setup.php index 95ad7992..10d7e155 100644 --- a/utils/setup.php +++ b/utils/setup.php @@ -44,11 +44,13 @@ $aCMDOptions array('create-country-names', '', 0, 1, 0, 0, 'bool', 'Create default list of searchable country names'), array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'), array('setup-website', '', 0, 1, 0, 0, 'bool', 'Used to compile environment variables for the website'), + array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory for this Nominatim installation'), ); // $aCMDOptions passed to getCmdOpt by reference getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true); +loadSettings($aCMDResult['project-dir'] ?? false); setupHTTPProxy(); $bDidSomething = false;