Bugfixings
- moved testargs.php to util directory - Switch Environment check before config at automatic install - checkPHP() is now finding the PHP binary too - Bugfixing checkPHP() & required returned wrong status - removing not used $_POST['phpath'] in web installer
This commit is contained in:
parent
f0382ab919
commit
cf39c9df81
5 changed files with 77 additions and 36 deletions
|
@ -78,6 +78,20 @@ HELP;
|
|||
|
||||
$installer = new Installer();
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// Check Environment
|
||||
$this->out("Checking environment...\n");
|
||||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$this->runBasicChecks($installer)) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// if a config file is set,
|
||||
$config_file = $this->getOption(['f', 'file']);
|
||||
|
||||
|
@ -111,6 +125,10 @@ HELP;
|
|||
$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)) {
|
||||
$php_path = $installer->getPHPPath();
|
||||
}
|
||||
|
||||
$installer->createConfig(
|
||||
$php_path,
|
||||
$url_path,
|
||||
|
@ -127,18 +145,6 @@ HELP;
|
|||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// Check basic setup
|
||||
$this->out("Checking basic setup...\n");
|
||||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$this->runBasicChecks($installer)) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// Check database connection
|
||||
$this->out("Checking database...\n");
|
||||
|
||||
|
@ -178,37 +184,38 @@ HELP;
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Installer $install the Installer instance
|
||||
* @param Installer $installer the Installer instance
|
||||
*
|
||||
* @return bool true if checks were successfully, otherwise false
|
||||
*/
|
||||
private function runBasicChecks(Installer $install)
|
||||
private function runBasicChecks(Installer $installer)
|
||||
{
|
||||
$checked = true;
|
||||
|
||||
$install->resetChecks();
|
||||
if (!$install->checkFunctions()) {
|
||||
$installer->resetChecks();
|
||||
if (!$installer->checkFunctions()) {
|
||||
$checked = false;
|
||||
}
|
||||
if (!$install->checkImagick()) {
|
||||
if (!$installer->checkImagick()) {
|
||||
$checked = false;
|
||||
}
|
||||
if (!$install->checkLocalIni()) {
|
||||
if (!$installer->checkLocalIni()) {
|
||||
$checked = false;
|
||||
}
|
||||
if (!$install->checkSmarty3()) {
|
||||
if (!$installer->checkSmarty3()) {
|
||||
$checked = false;
|
||||
}
|
||||
if ($install->checkKeys()) {
|
||||
if (!$installer->checkKeys()) {
|
||||
$checked = false;
|
||||
}
|
||||
|
||||
$php_path = null;
|
||||
if (!empty(Config::get('config', 'php_path'))) {
|
||||
if (!$install->checkPHP(Config::get('config', 'php_path'), true)) {
|
||||
throw new RuntimeException(" ERROR: The php_path is not valid in the config.\n");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException(" ERROR: The php_path is not set in the config.\n");
|
||||
$php_path = Config::get('config', 'php_path');
|
||||
}
|
||||
|
||||
if (!$installer->checkPHP($php_path, true)) {
|
||||
$checked = false;
|
||||
}
|
||||
|
||||
$this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n");
|
||||
|
|
|
@ -26,6 +26,11 @@ class Installer
|
|||
*/
|
||||
private $checks;
|
||||
|
||||
/**
|
||||
* @var string The path to the PHP binary
|
||||
*/
|
||||
private $phppath = null;
|
||||
|
||||
/**
|
||||
* Returns all checks made
|
||||
*
|
||||
|
@ -36,6 +41,22 @@ class Installer
|
|||
return $this->checks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PHP path
|
||||
*
|
||||
* @return string the PHP Path
|
||||
*/
|
||||
public function getPHPPath()
|
||||
{
|
||||
// if not set, determine the PHP path
|
||||
if (!isset($this->phppath)) {
|
||||
$this->checkPHP();
|
||||
$this->resetChecks();
|
||||
}
|
||||
|
||||
return $this->phppath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all checks
|
||||
*/
|
||||
|
@ -197,11 +218,17 @@ class Installer
|
|||
*/
|
||||
public function checkPHP($phppath = null, $required = false)
|
||||
{
|
||||
$passed = $passed2 = $passed3 = false;
|
||||
if (isset($phppath)) {
|
||||
$passed = file_exists($phppath);
|
||||
} else {
|
||||
$phppath = trim(shell_exec('which php'));
|
||||
$passed = false;
|
||||
$passed2 = false;
|
||||
$passed3 = false;
|
||||
|
||||
if (!isset($phppath)) {
|
||||
$phppath = 'php';
|
||||
}
|
||||
|
||||
$passed = file_exists($phppath);
|
||||
if (!$passed) {
|
||||
$phppath = trim(shell_exec('which ' . $phppath));
|
||||
$passed = strlen($phppath);
|
||||
}
|
||||
|
||||
|
@ -232,12 +259,12 @@ class Installer
|
|||
$this->addCheck(L10n::t('PHP cli binary'), $passed2, true, $help);
|
||||
} else {
|
||||
// return if it was required
|
||||
return $required;
|
||||
return !$required;
|
||||
}
|
||||
|
||||
if ($passed2) {
|
||||
$str = autoname(8);
|
||||
$cmd = "$phppath testargs.php $str";
|
||||
$cmd = "$phppath util/testargs.php $str";
|
||||
$result = trim(shell_exec($cmd));
|
||||
$passed3 = $result == $str;
|
||||
$help = "";
|
||||
|
@ -557,7 +584,7 @@ class Installer
|
|||
}
|
||||
|
||||
if (DBA::connected()) {
|
||||
if (DBA::count('user') > 0) {
|
||||
if (DBStructure::existsTable('user')) {
|
||||
$this->addCheck(L10n::t('Database already in use.'), false, true, '');
|
||||
|
||||
return false;
|
||||
|
|
|
@ -87,7 +87,6 @@ class Install extends BaseModule
|
|||
$dbuser = notags(trim(defaults($_POST, 'dbuser', '')));
|
||||
$dbpass = notags(trim(defaults($_POST, 'dbpass', '')));
|
||||
$dbdata = notags(trim(defaults($_POST, 'dbdata', '')));
|
||||
$phpath = notags(trim(defaults($_POST, 'phpath', '')));
|
||||
$timezone = notags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ)));
|
||||
$language = notags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG)));
|
||||
$adminmail = notags(trim(defaults($_POST, 'adminmail', '')));
|
||||
|
@ -95,8 +94,11 @@ class Install extends BaseModule
|
|||
// If we cannot connect to the database, return to the Database config wizard
|
||||
if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) {
|
||||
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())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
|||
|
||||
|
||||
Creating config file...
|
||||
|
||||
Complete!
|
||||
CFG;
|
||||
}
|
||||
|
||||
|
@ -56,20 +58,23 @@ CFG;
|
|||
|
||||
|
||||
Copying config file...
|
||||
|
||||
Complete!
|
||||
CFG;
|
||||
}
|
||||
|
||||
$finished = <<<FIN
|
||||
Initializing setup...{$cfg}
|
||||
Initializing setup...
|
||||
|
||||
Complete!
|
||||
|
||||
|
||||
Checking basic setup...
|
||||
Checking environment...
|
||||
|
||||
NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.
|
||||
|
||||
Complete!
|
||||
{$cfg}
|
||||
|
||||
|
||||
Checking database...
|
||||
|
|
Loading…
Reference in a new issue