Refactor installer
This commit is contained in:
parent
d88dc7484f
commit
69fa6161e5
|
@ -74,6 +74,8 @@ HELP;
|
|||
|
||||
$installer = new Installer();
|
||||
|
||||
$configCache = $a->getConfigCache();
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// Check Environment
|
||||
|
@ -81,7 +83,7 @@ HELP;
|
|||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$this->runBasicChecks($installer)) {
|
||||
if (!$this->runBasicChecks($installer, $configCache)) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
@ -100,41 +102,51 @@ HELP;
|
|||
}
|
||||
}
|
||||
|
||||
$db_host = $a->getConfigCache()->get('database', 'hostname');
|
||||
$db_user = $a->getConfigCache()->get('database', 'username');
|
||||
$db_pass = $a->getConfigCache()->get('database', 'password');
|
||||
$db_data = $a->getConfigCache()->get('database', 'database');
|
||||
//reload the config cache
|
||||
$loader = new Config\Cache\ConfigCacheLoader($a->getBasePath(), $a->getMode());
|
||||
$loader->loadConfigFiles($configCache);
|
||||
|
||||
} else {
|
||||
// Creating config file
|
||||
$this->out("Creating config file...\n");
|
||||
|
||||
$save_db = $this->getOption(['s', 'savedb'], false);
|
||||
|
||||
$db_host = $this->getOption(['H', 'dbhost'], ($save_db) ? getenv('MYSQL_HOST') : '');
|
||||
//$db_host = $this->getOption(['H', 'dbhost'], ($save_db) ? (getenv('MYSQL_HOST') ? getenv('MYSQL_HOST') : Installer::DEFAULT_HOST) : '');
|
||||
$db_host = $this->getOption(['H', 'dbhost'], ($save_db) ? (getenv('MYSQL_HOST')) : Installer::DEFAULT_HOST);
|
||||
$db_port = $this->getOption(['p', 'dbport'], ($save_db) ? getenv('MYSQL_PORT') : null);
|
||||
$db_data = $this->getOption(['d', 'dbdata'], ($save_db) ? getenv('MYSQL_DATABASE') : '');
|
||||
$db_user = $this->getOption(['U', 'dbuser'], ($save_db) ? getenv('MYSQL_USER') . getenv('MYSQL_USERNAME') : '');
|
||||
$db_pass = $this->getOption(['P', 'dbpass'], ($save_db) ? getenv('MYSQL_PASSWORD') : '');
|
||||
$url_path = $this->getOption(['u', 'urlpath'], !empty('FRIENDICA_URL_PATH') ? getenv('FRIENDICA_URL_PATH') : null);
|
||||
$configCache->set('database', 'hostname', $db_host . (!empty($db_port) ? ':' . $db_port : ''));
|
||||
$configCache->set('database', 'database',
|
||||
$this->getOption(['d', 'dbdata'],
|
||||
($save_db) ? getenv('MYSQL_DATABASE') : ''));
|
||||
$configCache->set('database', 'username',
|
||||
$this->getOption(['U', 'dbuser'],
|
||||
($save_db) ? getenv('MYSQL_USER') . getenv('MYSQL_USERNAME') : ''));
|
||||
$configCache->set('database', 'password',
|
||||
$this->getOption(['P', 'dbpass'],
|
||||
($save_db) ? getenv('MYSQL_PASSWORD') : ''));
|
||||
$php_path = $this->getOption(['b', 'phppath'], !empty('FRIENDICA_PHP_PATH') ? getenv('FRIENDICA_PHP_PATH') : null);
|
||||
$admin_mail = $this->getOption(['A', 'admin'], !empty('FRIENDICA_ADMIN_MAIL') ? getenv('FRIENDICA_ADMIN_MAIL') : '');
|
||||
$tz = $this->getOption(['T', 'tz'], !empty('FRIENDICA_TZ') ? getenv('FRIENDICA_TZ') : '');
|
||||
$lang = $this->getOption(['L', 'lang'], !empty('FRIENDICA_LANG') ? getenv('FRIENDICA_LANG') : '');
|
||||
if (!empty($php_path)) {
|
||||
$configCache->set('config', 'php_path', $php_path);
|
||||
}
|
||||
$configCache->set('config', 'admin_email',
|
||||
$this->getOption(['A', 'admin'],
|
||||
!empty(getenv('FRIENDICA_ADMIN_MAIL')) ? getenv('FRIENDICA_ADMIN_MAIL') : ''));
|
||||
$configCache->set('system', 'default_timezone',
|
||||
$this->getOption(['T', 'tz'],
|
||||
!empty(getenv('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : Installer::DEFAULT_TZ));
|
||||
$configCache->set('system', 'language',
|
||||
$this->getOption(['L', 'lang'],
|
||||
!empty(getenv('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : Installer::DEFAULT_LANG));
|
||||
|
||||
|
||||
if (empty($php_path)) {
|
||||
$php_path = $installer->getPHPPath();
|
||||
$configCache->set('config', 'php_path', $installer->getPHPPath());
|
||||
}
|
||||
|
||||
$installer->createConfig(
|
||||
$php_path,
|
||||
$url_path,
|
||||
(!empty($db_port) ? $db_host . ':' . $db_port : $db_host),
|
||||
$db_user,
|
||||
$db_pass,
|
||||
$db_data,
|
||||
$tz,
|
||||
$lang,
|
||||
$admin_mail,
|
||||
$a,
|
||||
$configCache,
|
||||
$a->getBasePath()
|
||||
);
|
||||
}
|
||||
|
@ -146,7 +158,7 @@ HELP;
|
|||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$installer->checkDB($a->getBasePath(), $a->getConfigCache(), $a->getProfiler(), $db_host, $db_user, $db_pass, $db_data)) {
|
||||
if (!$installer->checkDB($a->getBasePath(), $configCache, $a->getProfiler())) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
@ -180,12 +192,13 @@ HELP;
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Installer $installer the Installer instance
|
||||
* @param Installer $installer The Installer instance
|
||||
* @param Config\Cache\IConfigCache $configCache The config cache
|
||||
*
|
||||
* @return bool true if checks were successfully, otherwise false
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private function runBasicChecks(Installer $installer)
|
||||
private function runBasicChecks(Installer $installer, Config\Cache\IConfigCache $configCache)
|
||||
{
|
||||
$checked = true;
|
||||
|
||||
|
@ -207,8 +220,8 @@ HELP;
|
|||
}
|
||||
|
||||
$php_path = null;
|
||||
if (!empty(Config::get('config', 'php_path'))) {
|
||||
$php_path = Config::get('config', 'php_path');
|
||||
if (!$configCache->has('config', 'php_path')) {
|
||||
$php_path = $configCache->get('config', 'php_path');
|
||||
}
|
||||
|
||||
if (!$installer->checkPHP($php_path, true)) {
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Friendica\Core;
|
|||
|
||||
use DOMDocument;
|
||||
use Exception;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
|
@ -129,33 +130,28 @@ class Installer
|
|||
* - Creates `config/local.config.php`
|
||||
* - Installs Database Structure
|
||||
*
|
||||
* @param string $phppath Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
|
||||
* @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica')
|
||||
* @param string $dbhost Hostname/IP of the Friendica Database
|
||||
* @param string $dbuser Username of the Database connection credentials
|
||||
* @param string $dbpass Password of the Database connection credentials
|
||||
* @param string $dbdata Name of the Database
|
||||
* @param string $timezone Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')
|
||||
* @param string $language 2-letter ISO 639-1 code (eg. 'en')
|
||||
* @param string $adminmail Mail-Adress of the administrator
|
||||
* @param App $app The Friendica App
|
||||
* @param IConfigCache $configCache The config cache with all config relevant information
|
||||
* @param string $basepath The basepath of Friendica
|
||||
*
|
||||
* @return bool true if the config was created, otherwise false
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function createConfig($phppath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $basepath)
|
||||
public function createConfig(App $app, IConfigCache $configCache, $basepath)
|
||||
{
|
||||
$tpl = Renderer::getMarkupTemplate('local.config.tpl');
|
||||
$txt = Renderer::replaceMacros($tpl, [
|
||||
'$phpath' => $phppath,
|
||||
'$dbhost' => $dbhost,
|
||||
'$dbuser' => $dbuser,
|
||||
'$dbpass' => $dbpass,
|
||||
'$dbdata' => $dbdata,
|
||||
'$timezone' => $timezone,
|
||||
'$language' => $language,
|
||||
'$urlpath' => $urlpath,
|
||||
'$adminmail' => $adminmail,
|
||||
'$dbhost' => $configCache->get('database', 'hostname'),
|
||||
'$dbuser' => $configCache->get('database', 'username'),
|
||||
'$dbpass' => $configCache->get('database', 'password'),
|
||||
'$dbdata' => $configCache->get('database', 'database'),
|
||||
|
||||
'$phpath' => $this->getPHPPath(),
|
||||
'$adminmail' => $configCache->get('config', 'admin_email'),
|
||||
|
||||
'$timezone' => $configCache->get('system', 'default_timezone'),
|
||||
'$language' => $configCache->get('system', 'language'),
|
||||
'$urlpath' => $app->getURLPath(),
|
||||
]);
|
||||
|
||||
$result = file_put_contents($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php', $txt);
|
||||
|
@ -594,16 +590,17 @@ class Installer
|
|||
* @param string $basePath The basepath of this call
|
||||
* @param IConfigCache $configCache The configuration cache
|
||||
* @param Profiler $profiler The profiler of this app
|
||||
* @param string $dbhost Hostname/IP of the Friendica Database
|
||||
* @param string $dbuser Username of the Database connection credentials
|
||||
* @param string $dbpass Password of the Database connection credentials
|
||||
* @param string $dbdata Name of the Database
|
||||
*
|
||||
* @return bool true if the check was successful, otherwise false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkDB($basePath, IConfigCache $configCache, Profiler $profiler, $dbhost, $dbuser, $dbpass, $dbdata)
|
||||
public function checkDB($basePath, IConfigCache $configCache, Profiler $profiler)
|
||||
{
|
||||
$dbhost = $configCache->get('database', 'hostname');
|
||||
$dbuser = $configCache->get('database', 'username');
|
||||
$dbpass = $configCache->get('database', 'password');
|
||||
$dbdata = $configCache->get('database', 'database');
|
||||
|
||||
if (!DBA::connect($basePath, $configCache, $profiler, $dbhost, $dbuser, $dbpass, $dbdata)) {
|
||||
$this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Friendica\Module;
|
|||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -65,45 +66,48 @@ class Install extends BaseModule
|
|||
public static function post()
|
||||
{
|
||||
$a = self::getApp();
|
||||
$configCache = $a->getConfigCache();
|
||||
|
||||
switch (self::$currentWizardStep) {
|
||||
case self::SYSTEM_CHECK:
|
||||
case self::DATABASE_CONFIG:
|
||||
// Nothing to do in these steps
|
||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||
break;
|
||||
|
||||
case self::SITE_SETTINGS:
|
||||
$dbhost = Strings::escapeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
|
||||
$dbuser = Strings::escapeTags(trim(defaults($_POST, 'dbuser', '')));
|
||||
$dbpass = Strings::escapeTags(trim(defaults($_POST, 'dbpass', '')));
|
||||
$dbdata = Strings::escapeTags(trim(defaults($_POST, 'dbdata', '')));
|
||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||
|
||||
self::checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
||||
self::checkSetting($configCache, $_POST, 'database', 'username', '');
|
||||
self::checkSetting($configCache, $_POST, 'database', 'password', '');
|
||||
self::checkSetting($configCache, $_POST, 'database', 'database', '');
|
||||
|
||||
// If we cannot connect to the database, return to the previous step
|
||||
if (!self::$installer->checkDB($a->getBasePath(), $a->getConfigCache(), $a->getProfiler(), $dbhost, $dbuser, $dbpass, $dbdata)) {
|
||||
if (!self::$installer->checkDB($a->getBasePath(), $configCache, $a->getProfiler())) {
|
||||
self::$currentWizardStep = self::DATABASE_CONFIG;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case self::FINISHED:
|
||||
$urlpath = $a->getURLPath();
|
||||
$dbhost = Strings::escapeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
|
||||
$dbuser = Strings::escapeTags(trim(defaults($_POST, 'dbuser', '')));
|
||||
$dbpass = Strings::escapeTags(trim(defaults($_POST, 'dbpass', '')));
|
||||
$dbdata = Strings::escapeTags(trim(defaults($_POST, 'dbdata', '')));
|
||||
$timezone = Strings::escapeTags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ)));
|
||||
$language = Strings::escapeTags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG)));
|
||||
$adminmail = Strings::escapeTags(trim(defaults($_POST, 'adminmail', '')));
|
||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||
|
||||
self::checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
||||
self::checkSetting($configCache, $_POST, 'database', 'username', '');
|
||||
self::checkSetting($configCache, $_POST, 'database', 'password', '');
|
||||
self::checkSetting($configCache, $_POST, 'database', 'database', '');
|
||||
|
||||
self::checkSetting($configCache, $_POST, 'system', 'default_timezone', Core\Installer::DEFAULT_TZ);
|
||||
self::checkSetting($configCache, $_POST, 'system', 'language', Core\Installer::DEFAULT_LANG);
|
||||
self::checkSetting($configCache, $_POST, 'config', 'admin_email', '');
|
||||
|
||||
// If we cannot connect to the database, return to the Database config wizard
|
||||
if (!self::$installer->checkDB($a->getBasePath(), $a->getConfigCache(), $a->getProfiler(), $dbhost, $dbuser, $dbpass, $dbdata)) {
|
||||
if (!self::$installer->checkDB($a->getBasePath(), $configCache, $a->getProfiler())) {
|
||||
self::$currentWizardStep = self::DATABASE_CONFIG;
|
||||
return;
|
||||
}
|
||||
|
||||
$phpath = self::$installer->getPHPPath();
|
||||
|
||||
if (!self::$installer->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath())) {
|
||||
if (!self::$installer->createConfig($a, $configCache, $a->getBasePath())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,6 +120,7 @@ class Install extends BaseModule
|
|||
public static function content()
|
||||
{
|
||||
$a = self::getApp();
|
||||
$configCache = $a->getConfigCache();
|
||||
|
||||
$output = '';
|
||||
|
||||
|
@ -123,9 +128,9 @@ class Install extends BaseModule
|
|||
|
||||
switch (self::$currentWizardStep) {
|
||||
case self::SYSTEM_CHECK:
|
||||
$phppath = defaults($_POST, 'phpath', null);
|
||||
$php_path = $configCache->get('config', 'php_path');
|
||||
|
||||
$status = self::$installer->checkEnvironment($a->getBaseURL(), $phppath);
|
||||
$status = self::$installer->checkEnvironment($a->getBaseURL(), $php_path);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('install_checks.tpl');
|
||||
$output .= Renderer::replaceMacros($tpl, [
|
||||
|
@ -136,19 +141,12 @@ class Install extends BaseModule
|
|||
'$see_install' => L10n::t('Please see the file "INSTALL.txt".'),
|
||||
'$next' => L10n::t('Next'),
|
||||
'$reload' => L10n::t('Check again'),
|
||||
'$phpath' => $phppath,
|
||||
'$php_path' => $php_path,
|
||||
'$baseurl' => $a->getBaseURL()
|
||||
]);
|
||||
break;
|
||||
|
||||
case self::DATABASE_CONFIG:
|
||||
$dbhost = Strings::escapeTags(trim(defaults($_POST, 'dbhost' , Core\Installer::DEFAULT_HOST)));
|
||||
$dbuser = Strings::escapeTags(trim(defaults($_POST, 'dbuser' , '' )));
|
||||
$dbpass = Strings::escapeTags(trim(defaults($_POST, 'dbpass' , '' )));
|
||||
$dbdata = Strings::escapeTags(trim(defaults($_POST, 'dbdata' , '' )));
|
||||
$phpath = Strings::escapeTags(trim(defaults($_POST, 'phpath' , '' )));
|
||||
$adminmail = Strings::escapeTags(trim(defaults($_POST, 'adminmail', '' )));
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('install_db.tpl');
|
||||
$output .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => $install_title,
|
||||
|
@ -157,51 +155,35 @@ class Install extends BaseModule
|
|||
'$info_02' => L10n::t('Please contact your hosting provider or site administrator if you have questions about these settings.'),
|
||||
'$info_03' => L10n::t('The database you specify below should already exist. If it does not, please create it before continuing.'),
|
||||
'checks' => self::$installer->getChecks(),
|
||||
'$dbhost' => ['dbhost',
|
||||
'$dbhost' => ['database-hostname',
|
||||
L10n::t('Database Server Name'),
|
||||
$dbhost,
|
||||
$configCache->get('database', 'hostname'),
|
||||
'',
|
||||
'required'],
|
||||
'$dbuser' => ['dbuser',
|
||||
'$dbuser' => ['database-username',
|
||||
L10n::t('Database Login Name'),
|
||||
$dbuser,
|
||||
$configCache->get('database', 'username'),
|
||||
'',
|
||||
'required',
|
||||
'autofocus'],
|
||||
'$dbpass' => ['dbpass',
|
||||
'$dbpass' => ['database-password',
|
||||
L10n::t('Database Login Password'),
|
||||
$dbpass,
|
||||
$configCache->get('database', 'password'),
|
||||
L10n::t("For security reasons the password must not be empty"),
|
||||
'required'],
|
||||
'$dbdata' => ['dbdata',
|
||||
'$dbdata' => ['database-database',
|
||||
L10n::t('Database Name'),
|
||||
$dbdata,
|
||||
$configCache->get('database', 'database'),
|
||||
'',
|
||||
'required'],
|
||||
'$adminmail' => ['adminmail',
|
||||
L10n::t('Site administrator email address'),
|
||||
$adminmail,
|
||||
L10n::t('Your account email address must match this in order to use the web admin panel.'),
|
||||
'required',
|
||||
'autofocus',
|
||||
'email'],
|
||||
'$lbl_10' => L10n::t('Please select a default timezone for your website'),
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
'$phpath' => $phpath,
|
||||
'$php_path' => $configCache->get('config', 'php_path'),
|
||||
'$submit' => L10n::t('Submit')
|
||||
]);
|
||||
break;
|
||||
|
||||
case self::SITE_SETTINGS:
|
||||
$dbhost = Strings::escapeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
|
||||
$dbuser = Strings::escapeTags(trim(defaults($_POST, 'dbuser', '' )));
|
||||
$dbpass = Strings::escapeTags(trim(defaults($_POST, 'dbpass', '' )));
|
||||
$dbdata = Strings::escapeTags(trim(defaults($_POST, 'dbdata', '' )));
|
||||
$phpath = Strings::escapeTags(trim(defaults($_POST, 'phpath', '' )));
|
||||
|
||||
$adminmail = Strings::escapeTags(trim(defaults($_POST, 'adminmail', '')));
|
||||
|
||||
$timezone = defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ);
|
||||
/* Installed langs */
|
||||
$lang_choices = L10n::getAvailableLanguages();
|
||||
|
||||
|
@ -210,16 +192,23 @@ class Install extends BaseModule
|
|||
'$title' => $install_title,
|
||||
'$checks' => self::$installer->getChecks(),
|
||||
'$pass' => L10n::t('Site settings'),
|
||||
'$dbhost' => $dbhost,
|
||||
'$dbuser' => $dbuser,
|
||||
'$dbpass' => $dbpass,
|
||||
'$dbdata' => $dbdata,
|
||||
'$phpath' => $phpath,
|
||||
'$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'],
|
||||
'$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''),
|
||||
'$language' => ['language',
|
||||
'$dbhost' => $configCache->get('database', 'hostname'),
|
||||
'$dbuser' => $configCache->get('database', 'username'),
|
||||
'$dbpass' => $configCache->get('database', 'password'),
|
||||
'$dbdata' => $configCache->get('database', 'database'),
|
||||
'$phpath' => $configCache->get('config', 'php_path'),
|
||||
'$adminmail' => ['config-admin_email',
|
||||
L10n::t('Site administrator email address'),
|
||||
$configCache->get('config', 'admin_email'),
|
||||
L10n::t('Your account email address must match this in order to use the web admin panel.'),
|
||||
'required', 'autofocus', 'email'],
|
||||
'$timezone' => Temporal::getTimezoneField('system-default_timezone',
|
||||
L10n::t('Please select a default timezone for your website'),
|
||||
$configCache->get('system', 'default_timezone'),
|
||||
''),
|
||||
'$language' => ['system-language',
|
||||
L10n::t('System Language:'),
|
||||
Core\Installer::DEFAULT_LANG,
|
||||
$configCache->get('system', 'language'),
|
||||
L10n::t('Set the default language for your Friendica installation interface and to send emails.'),
|
||||
$lang_choices],
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
|
@ -269,4 +258,24 @@ class Install extends BaseModule
|
|||
. L10n::t('Go to your new Friendica node <a href="%s/register">registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl)
|
||||
. "</p>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the $_POST settings and updates the config Cache for it
|
||||
*
|
||||
* @param IConfigCache $configCache The current config cache
|
||||
* @param array $post The $_POST data
|
||||
* @param string $cat The category of the setting
|
||||
* @param string $key The key of the setting
|
||||
* @param null|string $default The default value
|
||||
*/
|
||||
private static function checkSetting(IConfigCache $configCache, array $post, $cat, $key, $default = null)
|
||||
{
|
||||
$configCache->set($cat, $key,
|
||||
Strings::escapeTags(
|
||||
trim(defaults($post, sprintf('%s-%s', $cat, $key),
|
||||
(!isset($default) ? $configCache->get($cat, $key) : $default))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ use org\bovigo\vfs\vfsStream;
|
|||
use org\bovigo\vfs\vfsStreamFile;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||
|
@ -277,12 +275,11 @@ FIN;
|
|||
* Asserts all config entries
|
||||
*
|
||||
* @param null|array $assertion The optional assertion array
|
||||
* @param boolean $createConfig True, if a config file has to get generated
|
||||
* @param boolean $saveDb True, if the db credentials should get saved to the file
|
||||
* @param boolean $default True, if we use the default values
|
||||
* @param boolean $defaultDb True, if we use the default value for the DB
|
||||
*/
|
||||
public function assertConfig($assertion = null, $createConfig = true, $saveDb = false, $default = true, $defaultDb = true)
|
||||
public function assertConfig($assertion = null, $saveDb = false, $default = true, $defaultDb = true)
|
||||
{
|
||||
if (!empty($assertion['database']['hostname'])) {
|
||||
$assertion['database']['hostname'] .= (!empty($assertion['database']['port']) ? ':' . $assertion['database']['port'] : '');
|
||||
|
@ -293,15 +290,11 @@ FIN;
|
|||
$this->assertConfigEntry('database', 'password', ($saveDb) ? $assertion : null);
|
||||
$this->assertConfigEntry('database', 'database', ($saveDb) ? $assertion : null);
|
||||
|
||||
$this->assertConfigEntry('config', 'hostname', $assertion);
|
||||
$this->assertConfigEntry('config', 'admin_email', $assertion);
|
||||
$this->assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
|
||||
|
||||
$this->assertConfigEntry('system', 'default_timezone', $assertion, ($default) ? Installer::DEFAULT_TZ : null);
|
||||
$this->assertConfigEntry('system', 'language', $assertion, ($default) ? Installer::DEFAULT_LANG : null);
|
||||
$this->assertConfigEntry('system', 'ssl_policy', $assertion, ($default) ? SSL_POLICY_NONE : null);
|
||||
$this->assertConfigEntry('system', 'urlpath', $assertion);
|
||||
$this->assertConfigEntry('system', 'basepath', $createConfig ? $this->root->url() : $assertion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,6 +302,8 @@ FIN;
|
|||
*/
|
||||
public function testEmpty()
|
||||
{
|
||||
$this->app->shouldReceive('getURLPath')->andReturn('')->atLeast()->once();
|
||||
|
||||
$this->mockConnect(true, 1);
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockExistsTable('user', false, 1);
|
||||
|
@ -400,7 +395,7 @@ CONF;
|
|||
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
|
||||
$this->assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
|
||||
|
||||
$this->assertConfig($data, false, true, false, false);
|
||||
$this->assertConfig($data, true, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,6 +405,8 @@ CONF;
|
|||
*/
|
||||
public function testWithEnvironmentAndSave(array $data)
|
||||
{
|
||||
$this->app->shouldReceive('getURLPath')->andReturn('')->atLeast()->once();
|
||||
|
||||
$this->mockConnect(true, 1);
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockExistsTable('user', false, 1);
|
||||
|
@ -439,7 +436,7 @@ CONF;
|
|||
$txt = $this->dumpExecute($console);
|
||||
|
||||
$this->assertFinished($txt, true);
|
||||
$this->assertConfig($data, true, true, true, false);
|
||||
$this->assertConfig($data, true, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,6 +446,8 @@ CONF;
|
|||
*/
|
||||
public function testWithEnvironmentWithoutSave(array $data)
|
||||
{
|
||||
$this->app->shouldReceive('getURLPath')->andReturn('')->atLeast()->once();
|
||||
|
||||
$this->mockConnect(true, 1);
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockExistsTable('user', false, 1);
|
||||
|
@ -477,7 +476,7 @@ CONF;
|
|||
$txt = $this->dumpExecute($console);
|
||||
|
||||
$this->assertFinished($txt, true);
|
||||
$this->assertConfig($data, true, false, true);
|
||||
$this->assertConfig($data, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,6 +485,8 @@ CONF;
|
|||
*/
|
||||
public function testWithArguments(array $data)
|
||||
{
|
||||
$this->app->shouldReceive('getURLPath')->andReturn('')->atLeast()->once();
|
||||
|
||||
$this->mockConnect(true, 1);
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockExistsTable('user', false, 1);
|
||||
|
@ -518,7 +519,7 @@ CONF;
|
|||
$txt = $this->dumpExecute($console);
|
||||
|
||||
$this->assertFinished($txt, true);
|
||||
$this->assertConfig($data, true, true, true, true);
|
||||
$this->assertConfig($data, true, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -526,6 +527,7 @@ CONF;
|
|||
*/
|
||||
public function testNoDatabaseConnection()
|
||||
{
|
||||
$this->app->shouldReceive('getURLPath')->andReturn('')->atLeast()->once();
|
||||
$this->mockConnect(false, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
|
@ -538,7 +540,7 @@ CONF;
|
|||
$this->assertStuckDB($txt);
|
||||
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
|
||||
|
||||
$this->assertConfig(null, true, false, true, false);
|
||||
$this->assertConfig(null, false, true, false);
|
||||
}
|
||||
|
||||
public function testGetHelp()
|
||||
|
@ -566,12 +568,10 @@ Options
|
|||
-d|--dbdata <database> The name of the mysql/mariadb database (env MYSQL_DATABASE)
|
||||
-U|--dbuser <username> The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
|
||||
-P|--dbpass <password> The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
|
||||
-U|--urlpath <url_path> The URL path of Friendica - f.e. '/friendica' (env FRIENDICA_URL_PATH)
|
||||
-B|--phppath <php_path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
||||
-b|--basepath <base_path> The basepath of Friendica(env FRIENDICA_BASE_PATH)
|
||||
-S|--sslpolicy <ssl_policy> The SSL policy of Friendica (env FRIENDICA_SSL_POLICY)
|
||||
-n|--hostname <hostname> The hostname of Friendica (env FRIENDICA_PHP_HOSTNAME)
|
||||
-t|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||
-u|--urlpath <url_path> The URL path of Friendica - f.e. '/friendica' (env FRIENDICA_URL_PATH)
|
||||
-b|--phppath <php_path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
||||
-A|--admin <mail> The admin email address of Friendica (env FRIENDICA_ADMIN_MAIL)
|
||||
-T|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
||||
|
||||
Environment variables
|
||||
|
@ -580,12 +580,9 @@ Environment variables
|
|||
MYSQL_USERNAME|MYSQL_USER The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
|
||||
MYSQL_PASSWORD The password of the mysql/mariadb database login
|
||||
MYSQL_DATABASE The name of the mysql/mariadb database
|
||||
FRIENDICA_URL_PATH The URL path of Friendica (f.e. '/friendica') - leave empty for auto detection
|
||||
FRIENDICA_PHP_PATH The path of the PHP binary - leave empty for auto detection
|
||||
FRIENDICA_BASE_PATH The basepath of Friendica - leave empty for auto detection
|
||||
FRIENDICA_URL_PATH The URL path of Friendica (f.e. '/friendica')
|
||||
FRIENDICA_PHP_PATH The path of the PHP binary
|
||||
FRIENDICA_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access)
|
||||
FRIENDICA_SSL_POLICY The SSL policy of Friendica (default is NO SSL)
|
||||
FRIENDICA_HOSTNAME The hostname of Friendica - leave empty for auto detection
|
||||
FRIENDICA_TZ The timezone of Friendica
|
||||
FRIENDICA_LANG The langauge of Friendica
|
||||
|
||||
|
@ -606,6 +603,6 @@ HELP;
|
|||
|
||||
$txt = $this->dumpExecute($console);
|
||||
|
||||
$this->assertEquals($txt, $theHelp);
|
||||
$this->assertEquals($theHelp, $txt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</table>
|
||||
|
||||
{{if $phpath}}
|
||||
<input type="hidden" name="phpath" value="{{$phpath}}">
|
||||
<input type="hidden" name="config-php_path" value="{{$php_path}}">
|
||||
{{/if}}
|
||||
|
||||
{{if $passed}}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<form id="install-form" action="{{$baseurl}}/install" method="post">
|
||||
|
||||
<input type="hidden" name="phpath" value="{{$phpath}}" />
|
||||
<input type="hidden" name="config-php_path" value="{{$php_path}}" />
|
||||
<input type="hidden" name="pass" value="3" />
|
||||
|
||||
{{include file="field_input.tpl" field=$dbhost}}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
<form id="install-form" action="{{$baseurl}}/install" method="post">
|
||||
|
||||
<input type="hidden" name="phpath" value="{{$phpath}}" />
|
||||
<input type="hidden" name="dbhost" value="{{$dbhost}}" />
|
||||
<input type="hidden" name="dbuser" value="{{$dbuser}}" />
|
||||
<input type="hidden" name="dbpass" value="{{$dbpass}}" />
|
||||
<input type="hidden" name="dbdata" value="{{$dbdata}}" />
|
||||
<input type="hidden" name="config-php_path" value="{{$php_path}}" />
|
||||
<input type="hidden" name="database-hostname" value="{{$dbhost}}" />
|
||||
<input type="hidden" name="database-username" value="{{$dbuser}}" />
|
||||
<input type="hidden" name="database-password" value="{{$dbpass}}" />
|
||||
<input type="hidden" name="database-database" value="{{$dbdata}}" />
|
||||
<input type="hidden" name="pass" value="4" />
|
||||
|
||||
{{include file="field_input.tpl" field=$adminmail}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user