Added setup-website option

This commit is contained in:
K Rahul Reddy 2020-06-12 19:04:48 +05:30
parent 0f17529486
commit 6c406124dd
3 changed files with 50 additions and 1 deletions

View File

@ -1,3 +1,3 @@
<?php <?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php'); require_once(dirname(dirname(__FILE__)).'/settings/settings-frontend.php');
require_once(CONST_BasePath.'/@script_source@'); require_once(CONST_BasePath.'/@script_source@');

View File

@ -694,6 +694,49 @@ class SetupFunctions
$this->removeFlatnodeFile(); $this->removeFlatnodeFile();
} }
/**
* Setup settings_test.php in the build/settings directory from build/.env file
*
* @return null
*/
public function setupWebsite()
{
$rOutputFile = fopen(CONST_InstallPath.'/settings/settings-frontend.php', 'w');
// Currently using CONST_BasePath and CONST_InstallPath.
// Once dotenv is setup, getenv() can be used, or another
// alternate option is to build settings_test.php using cmake.
fwrite($rOutputFile, "<?php
@define('CONST_BasePath', '".CONST_BasePath."');
if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
@define('CONST_Debug', ". (CONST_Debug? 'true' : 'false').");
@define('CONST_Database_DSN', '".CONST_Database_DSN."'); // or add ;host=...;port=...;user=...;password=...
@define('CONST_Default_Language', ".(CONST_Default_Language ? 'true' : 'false').");
@define('CONST_Default_Lat', ".CONST_Default_Lat.");
@define('CONST_Default_Lon', ".CONST_Default_Lon.");
@define('CONST_Default_Zoom', ".CONST_Default_Zoom.");
@define('CONST_Map_Tile_URL', '".CONST_Map_Tile_URL."');
@define('CONST_Map_Tile_Attribution', '".CONST_Map_Tile_Attribution."'); // Set if tile source isn't osm.org
@define('CONST_Log_DB', ".(CONST_Log_DB ? 'true' : 'false').");
@define('CONST_Log_File', ".(CONST_Log_File ? 'true' : 'false').");
@define('CONST_Max_Word_Frequency', '".CONST_Max_Word_Frequency."');
@define('CONST_NoAccessControl', ".CONST_NoAccessControl.");
@define('CONST_Places_Max_ID_count', ".CONST_Places_Max_ID_count.");
@define('CONST_PolygonOutput_MaximumTypes', ".CONST_PolygonOutput_MaximumTypes.");
@define('CONST_Search_AreaPolygons', ".CONST_Search_AreaPolygons.");
@define('CONST_Search_BatchMode', ".(CONST_Search_BatchMode ? 'true' : 'false').");
@define('CONST_Search_NameOnlySearchFrequencyThreshold', ".CONST_Search_NameOnlySearchFrequencyThreshold.");
@define('CONST_Search_ReversePlanForAll', ".CONST_Search_ReversePlanForAll.");
@define('CONST_Term_Normalization_Rules', \"".CONST_Term_Normalization_Rules."\");
@define('CONST_Use_Aux_Location_data', ".(CONST_Use_Aux_Location_data ? 'true' : 'false').");
@define('CONST_Use_US_Tiger_Data', ".(CONST_Use_US_Tiger_Data ? 'true' : 'false').");
@define('CONST_Website_BaseURL', '".CONST_Website_BaseURL."');
");
info(CONST_InstallPath.'/settings/settings-frontend.php has been set up successfully');
}
private function removeFlatnodeFile() private function removeFlatnodeFile()
{ {
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) { if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {

View File

@ -44,6 +44,7 @@ $aCMDOptions
array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'), array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
array('create-country-names', '', 0, 1, 0, 0, 'bool', 'Create default list of searchable country names'), 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('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 (EXPERIMENTAL)'),
); );
// $aCMDOptions passed to getCmdOpt by reference // $aCMDOptions passed to getCmdOpt by reference
@ -153,6 +154,11 @@ if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
$oSetup->createCountryNames($aCMDResult); $oSetup->createCountryNames($aCMDResult);
} }
if ($aCMDResult['setup-website'] || $aCMDResult['all']) {
$bDidSomething = true;
$oSetup->setupWebsite();
}
// ****************************************************** // ******************************************************
// If we did something, repeat the warnings // If we did something, repeat the warnings
if (!$bDidSomething) { if (!$bDidSomething) {