X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Finstall_cli.php;h=e4f8f600b1681a6136c469d55e4ae376c8103440;hb=364b8e308babfaeb64e5ba45e4df9aa881ac9d97;hp=61fbe18ef641fcaa9bd54ce8542f5e8d3b0d3e20;hpb=338aa4bf1d36e11a354c67796509c6d1fec2aac2;p=quix0rs-gnu-social.git
diff --git a/scripts/install_cli.php b/scripts/install_cli.php
index 61fbe18ef6..e4f8f600b1 100755
--- a/scripts/install_cli.php
+++ b/scripts/install_cli.php
@@ -1,36 +1,37 @@
#!/usr/bin/env php
.
+
/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2010, StatusNet, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- * @category Installation
- * @package Installation
+ * CLI Installer
*
- * @author Brion Vibber
- * @license GNU Affero General Public License http://www.gnu.org/licenses/
- * @version 0.9.x
- * @link http://status.net
+ * @package Installation
+ * @author Brion Vibber
+ * @author Mikael Nordfeldth
+ * @author Diogo Cordeiro
+ * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (php_sapi_name() !== 'cli') {
exit(1);
}
-define('INSTALLDIR', dirname(dirname(__FILE__)));
+define('INSTALLDIR', dirname(__DIR__));
+define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib');
require_once INSTALLDIR . '/lib/installer.php';
@@ -42,16 +43,16 @@ class CliInstaller extends Installer
/**
* Go for it!
- * @return boolean success
+ * @return bool success
*/
- function main()
+ public function main(): bool
{
- if (!$this->checkPrereqs()) {
- return false;
- }
if ($this->prepare()) {
+ if (!$this->checkPrereqs()) {
+ return false;
+ }
return $this->handle();
- } else {
+ } else {
$this->showHelp();
return false;
}
@@ -59,22 +60,23 @@ class CliInstaller extends Installer
/**
* Get our input parameters...
- * @return boolean success
+ * @return bool success
*/
- function prepare()
+ public function prepare(): bool
{
$shortoptions = 'qvh';
- $longoptions = array('quiet', 'verbose', 'help', 'skip-config');
- $map = array(
- '-s' => 'server',
- '--server' => 'server',
- '-p' => 'path',
- '--path' => 'path',
+ $longoptions = ['quiet', 'verbose', 'help', 'skip-config'];
+ $map = [
+ '-s' => 'server',
+ '--server' => 'server',
+ '-p' => 'path',
+ '--path' => 'path',
'--sitename' => 'sitename',
- '--fancy' => 'fancy',
+ '--fancy' => 'fancy',
+ '--ssl' => 'ssl',
- '--dbtype' => 'dbtype',
- '--host' => 'host',
+ '--dbtype' => 'dbtype',
+ '--host' => 'host',
'--database' => 'database',
'--username' => 'username',
'--password' => 'password',
@@ -82,8 +84,9 @@ class CliInstaller extends Installer
'--admin-nick' => 'adminNick',
'--admin-pass' => 'adminPass',
'--admin-email' => 'adminEmail',
- '--admin-updates' => 'adminUpdates'
- );
+
+ '--site-profile' => 'siteProfile'
+ ];
foreach ($map as $arg => $target) {
if (substr($arg, 0, 2) == '--') {
$longoptions[] = substr($arg, 2) . '=';
@@ -102,24 +105,24 @@ class CliInstaller extends Installer
// defaults
$this->dbtype = 'mysql';
- $this->adminUpdates = true;
$this->verbose = true;
+ // ssl is defaulted in lib/installer.php
foreach ($options as $option) {
$arg = $option[0];
if (isset($map[$arg])) {
$var = $map[$arg];
$this->$var = $option[1];
- if ($var == 'adminUpdates' || $arg == '--fancy') {
+ if ($arg == '--fancy') {
$this->$var = ($option[1] != 'false') && ($option[1] != 'no');
}
- } else if ($arg == '--skip-config') {
+ } elseif ($arg == '--skip-config') {
$this->skipConfig = true;
- } else if ($arg == 'q' || $arg == '--quiet') {
+ } elseif ($arg == 'q' || $arg == '--quiet') {
$this->verbose = false;
- } else if ($arg == 'v' || $arg == '--verbose') {
+ } elseif ($arg == 'v' || $arg == '--verbose') {
$this->verbose = true;
- } else if ($arg == 'h' || $arg == '--help') {
+ } elseif ($arg == 'h' || $arg == '--help') {
// will go back to show help
return false;
}
@@ -143,20 +146,22 @@ class CliInstaller extends Installer
return !$fail;
}
- function handle()
+ public function handle()
{
return $this->doInstall();
}
- function showHelp()
+ public function showHelp()
{
echo << Use as server name (required)
-p --path= Use as path name
--sitename User-friendly site name (required)
--fancy Whether to use fancy URLs (default no)
+ --ssl Server SSL enabled (default never),
+ [never | always]
--dbtype 'mysql' (default) or 'pgsql'
--host Database hostname (required)
@@ -170,6 +175,8 @@ install_cli.php - StatusNet command-line installer
--admin-updates 'yes' (default) or 'no', whether to subscribe
admin to update@status.net (default yes)
+ --site-profile site profile ['public', 'private' (default), 'community', 'singleuser']
+
--skip-config Don't write a config.php -- use with caution,
requires a global configuration file.
@@ -182,7 +189,11 @@ install_cli.php - StatusNet command-line installer
END_HELP;
}
- function warning($message, $submessage='')
+ /**
+ * @param string $message
+ * @param string $submessage
+ */
+ public function warning(string $message, string $submessage = '')
{
print $this->html2text($message) . "\n";
if ($submessage != '') {
@@ -191,7 +202,11 @@ END_HELP;
print "\n";
}
- function updateStatus($status, $error=false)
+ /**
+ * @param string $status
+ * @param bool $error
+ */
+ public function updateStatus(string $status, bool $error = false)
{
if ($this->verbose || $error) {
if ($error) {
@@ -202,13 +217,19 @@ END_HELP;
}
}
- private function html2text($html)
+ /**
+ * @param string $html
+ * @return string
+ */
+ private function html2text(string $html): string
{
// break out any links for text legibility
- $breakout = preg_replace('/+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
- '\2 <\1>',
- $html);
- return html_entity_decode(strip_tags($breakout));
+ $breakout = preg_replace(
+ '/+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
+ '\2 <\1>',
+ $html
+ );
+ return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8');
}
}