@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@');
<?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;
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;