mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
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.
This commit is contained in:
@@ -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@');
|
||||
|
||||
18
lib/lib.php
18
lib/lib.php
@@ -1,5 +1,23 @@
|
||||
<?php
|
||||
|
||||
require('Symfony/Component/Dotenv/autoload.php');
|
||||
|
||||
function loadSettings($sProjectDir)
|
||||
{
|
||||
if (!$sProjectDir) {
|
||||
$sProjectDir = getcwd();
|
||||
}
|
||||
|
||||
@define('CONST_InstallDir', $sProjectDir);
|
||||
|
||||
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
||||
|
||||
if (file_exists($sProjectDir.'/.env')) {
|
||||
$dotenv->load($sProjectDir.'/.env');
|
||||
}
|
||||
$dotenv->load(CONST_DataDir.'/settings/env.defaults');
|
||||
}
|
||||
|
||||
function fail($sError, $sUserError = false)
|
||||
{
|
||||
if (!$sUserError) $sUserError = $sError;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user