$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']);
$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,
$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");
}
/**
- * @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");
*/
private $checks;
+ /**
+ * @var string The path to the PHP binary
+ */
+ private $phppath = null;
+
/**
* Returns all checks made
*
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
*/
*/
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);
}
$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 = "";
}
if (DBA::connected()) {
- if (DBA::count('user') > 0) {
+ if (DBStructure::existsTable('user')) {
$this->addCheck(L10n::t('Database already in use.'), false, true, '');
return false;
$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', '')));
// 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;
}
+++ /dev/null
-<?php
-
-/**
- *
- * File: testargs.php
- *
- * Purpose:
- * During installation we need to check if register_argc_argv is
- * enabled for the command line PHP processor, because otherwise
- * deliveries will fail. So we will do a shell exec of php and
- * execute this file with a command line argument, and see if it
- * echoes the argument back to us. Otherwise notify the person
- * that their installation doesn't meet the system requirements.
- *
- */
-
-
-if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
- echo $_SERVER["argv"][1];
-} else {
- echo '';
-}
Creating config file...
+
+ Complete!
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...
--- /dev/null
+<?php
+
+/**
+ *
+ * File: testargs.php
+ *
+ * Purpose:
+ * During installation we need to check if register_argc_argv is
+ * enabled for the command line PHP processor, because otherwise
+ * deliveries will fail. So we will do a shell exec of php and
+ * execute this file with a command line argument, and see if it
+ * echoes the argument back to us. Otherwise notify the person
+ * that their installation doesn't meet the system requirements.
+ *
+ */
+
+
+if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
+ echo $_SERVER["argv"][1];
+} else {
+ echo '';
+}