Move Console namespace one level up
This commit is contained in:
+20
-18
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica;
|
||||
|
||||
/**
|
||||
* Description of Console
|
||||
*
|
||||
@@ -47,24 +49,24 @@ HELP;
|
||||
}
|
||||
|
||||
protected $subConsoles = [
|
||||
'cache' => __NAMESPACE__ . '\Console\Cache',
|
||||
'config' => __NAMESPACE__ . '\Console\Config',
|
||||
'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
|
||||
'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
|
||||
'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
|
||||
'extract' => __NAMESPACE__ . '\Console\Extract',
|
||||
'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
|
||||
'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
|
||||
'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
|
||||
'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
|
||||
'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
|
||||
'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
|
||||
'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
|
||||
'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
|
||||
'typo' => __NAMESPACE__ . '\Console\Typo',
|
||||
'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
|
||||
'serverblock' => __NAMESPACE__ . '\Console\ServerBlock',
|
||||
'storage' => __NAMESPACE__ . '\Console\Storage',
|
||||
'cache' => Friendica\Console\Cache::class,
|
||||
'config' => Friendica\Console\Config::class,
|
||||
'createdoxygen' => Friendica\Console\CreateDoxygen::class,
|
||||
'docbloxerrorchecker' => Friendica\Console\DocBloxErrorChecker::class,
|
||||
'dbstructure' => Friendica\Console\DatabaseStructure::class,
|
||||
'extract' => Friendica\Console\Extract::class,
|
||||
'globalcommunityblock' => Friendica\Console\GlobalCommunityBlock::class,
|
||||
'globalcommunitysilence' => Friendica\Console\GlobalCommunitySilence::class,
|
||||
'archivecontact' => Friendica\Console\ArchiveContact::class,
|
||||
'autoinstall' => Friendica\Console\AutomaticInstallation::class,
|
||||
'maintenance' => Friendica\Console\Maintenance::class,
|
||||
'newpassword' => Friendica\Console\NewPassword::class,
|
||||
'php2po' => Friendica\Console\PhpToPo::class,
|
||||
'po2php' => Friendica\Console\PoToPhp::class,
|
||||
'typo' => Friendica\Console\Typo::class,
|
||||
'postupdate' => Friendica\Console\PostUpdate::class,
|
||||
'serverblock' => Friendica\Console\ServerBlock::class,
|
||||
'storage' => Friendica\Console\Storage::class,
|
||||
];
|
||||
|
||||
protected function doExecute()
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Friendica\Core\Console;
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Strings;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @brief tool to archive a contact on the server
|
||||
*
|
||||
* With this tool you can archive a contact when you know that it isn't existing anymore.
|
||||
* Normally this does happen automatically after a few days.
|
||||
*
|
||||
* License: AGPLv3 or later, same as Friendica
|
||||
*
|
||||
*/
|
||||
class ArchiveContact extends \Asika\SimpleConsole\Console
|
||||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
console archivecontact - archive a contact
|
||||
Usage
|
||||
bin/console archivecontact <profile_url> [-h|--help|-?] [-v]
|
||||
|
||||
Description
|
||||
Archive a contact when you know that it isn't existing anymore. Normally this does happen automatically after a few days.
|
||||
|
||||
Options
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
HELP;
|
||||
return $help;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
$this->out('Options: ' . var_export($this->options, true));
|
||||
}
|
||||
|
||||
if (count($this->args) == 0) {
|
||||
$this->out($this->getHelp());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count($this->args) > 1) {
|
||||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
throw new RuntimeException('Friendica isn\'t properly installed yet.');
|
||||
}
|
||||
|
||||
$nurl = Strings::normaliseLink($this->getArgument(0));
|
||||
if (!DBA::exists('contact', ['nurl' => $nurl, 'archive' => false])) {
|
||||
throw new RuntimeException(L10n::t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
|
||||
}
|
||||
if (DBA::update('contact', ['archive' => true], ['nurl' => $nurl])) {
|
||||
$this->out(L10n::t('The contact entries have been archived'));
|
||||
} else {
|
||||
throw new RuntimeException('The contact archival failed.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Friendica\Core\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Installer;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\BaseURL;
|
||||
use Friendica\Util\Config\ConfigFileLoader;
|
||||
use RuntimeException;
|
||||
|
||||
class AutomaticInstallation extends Console
|
||||
{
|
||||
protected function getHelp()
|
||||
{
|
||||
return <<<HELP
|
||||
Installation - Install Friendica automatically
|
||||
Synopsis
|
||||
bin/console autoinstall [-h|--help|-?] [-v] [-a] [-f]
|
||||
|
||||
Description
|
||||
Installs Friendica with data based on the local.config.php file or environment variables
|
||||
|
||||
Notes
|
||||
Not checking .htaccess/URL-Rewrite during CLI installation.
|
||||
|
||||
Options
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
-a All setup checks are required (except .htaccess)
|
||||
-f|--file <config> prepared config file (e.g. "config/local.config.php" itself) which will override every other config option - except the environment variables)
|
||||
-s|--savedb Save the DB credentials to the file (if environment variables is used)
|
||||
-H|--dbhost <host> The host of the mysql/mariadb database (env MYSQL_HOST)
|
||||
-p|--dbport <port> The port of the mysql/mariadb database (env MYSQL_PORT)
|
||||
-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|--url <url> The full base URL of Friendica - f.e. 'https://friendica.local/sub' (env FRIENDICA_URL)
|
||||
-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)
|
||||
-t|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
||||
|
||||
Environment variables
|
||||
MYSQL_HOST The host of the mysql/mariadb database (mandatory if mysql and environment is used)
|
||||
MYSQL_PORT The port of the mysql/mariadb database
|
||||
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 The full base URL of Friendica - f.e. 'https://friendica.local/sub'
|
||||
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_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access)
|
||||
FRIENDICA_TZ The timezone of Friendica
|
||||
FRIENDICA_LANG The langauge of Friendica
|
||||
|
||||
Examples
|
||||
bin/console autoinstall -f 'input.config.php
|
||||
Installs Friendica with the prepared 'input.config.php' file
|
||||
|
||||
bin/console autoinstall --savedb
|
||||
Installs Friendica with environment variables and saves them to the 'config/local.config.php' file
|
||||
|
||||
bin/console autoinstall -h localhost -p 3365 -U user -P passwort1234 -d friendica
|
||||
Installs Friendica with a local mysql database with credentials
|
||||
HELP;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
// Initialise the app
|
||||
$this->out("Initializing setup...\n");
|
||||
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
$installer = new Installer();
|
||||
|
||||
$configCache = $a->getConfigCache();
|
||||
$installer->setUpCache($configCache, BasePath::create($a->getBasePath(), $_SERVER));
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
||||
// Check Environment
|
||||
$this->out("Checking environment...\n");
|
||||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$this->runBasicChecks($installer, $configCache)) {
|
||||
$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']);
|
||||
|
||||
if (!empty($config_file)) {
|
||||
if ($config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
|
||||
// Copy config file
|
||||
$this->out("Copying config file...\n");
|
||||
if (!copy($a->getBasePath() . DIRECTORY_SEPARATOR . $config_file, $a->getBasePath() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $a->getBasePath() . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
|
||||
}
|
||||
}
|
||||
|
||||
//reload the config cache
|
||||
$loader = new ConfigFileLoader($a->getBasePath(), $a->getMode());
|
||||
$loader->setupCache($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')) : Installer::DEFAULT_HOST);
|
||||
$db_port = $this->getOption(['p', 'dbport'], ($save_db) ? getenv('MYSQL_PORT') : 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);
|
||||
if (!empty($php_path)) {
|
||||
$configCache->set('config', 'php_path', $php_path);
|
||||
} else {
|
||||