Merge pull request #15448 from owncloud/occ-check-server-env-master
Adding check command to validate server environment
This commit is contained in:
commit
84ae9532c8
13
console.php
13
console.php
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
define('OC_CONSOLE', 1);
|
define('OC_CONSOLE', 1);
|
||||||
|
|
||||||
|
@ -71,6 +72,18 @@ try {
|
||||||
} else {
|
} else {
|
||||||
echo "ownCloud is not installed - only a limited number of commands are available" . PHP_EOL;
|
echo "ownCloud is not installed - only a limited number of commands are available" . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
$input = new ArgvInput();
|
||||||
|
if ($input->getFirstArgument() !== 'check') {
|
||||||
|
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
|
||||||
|
if (!empty($errors)) {
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
echo $error['error'] . "\n";
|
||||||
|
echo $error['hint'] . "\n\n";
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$application->run();
|
$application->run();
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
echo "An unhandled exception has been thrown:" . PHP_EOL;
|
echo "An unhandled exception has been thrown:" . PHP_EOL;
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OC\Core\Command;
|
||||||
|
|
||||||
|
use OCP\IConfig;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class Check extends Command {
|
||||||
|
/**
|
||||||
|
* @var IConfig
|
||||||
|
*/
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
public function __construct(IConfig $config) {
|
||||||
|
parent::__construct();
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure() {
|
||||||
|
$this
|
||||||
|
->setName('check')
|
||||||
|
->setDescription('check dependencies of the server environment')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||||
|
$errors = \OC_Util::checkServer($this->config);
|
||||||
|
if (!empty($errors)) {
|
||||||
|
$errors = array_map( function($items) {
|
||||||
|
return (string)$items['error'];
|
||||||
|
}, $errors);
|
||||||
|
echo json_encode($errors);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
/** @var $application Symfony\Component\Console\Application */
|
/** @var $application Symfony\Component\Console\Application */
|
||||||
$application->add(new OC\Core\Command\Status);
|
$application->add(new OC\Core\Command\Status);
|
||||||
|
$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
|
||||||
$application->add(new OC\Core\Command\App\CheckCode());
|
$application->add(new OC\Core\Command\App\CheckCode());
|
||||||
$application->add(new OC\Core\Command\L10n\CreateJs());
|
$application->add(new OC\Core\Command\L10n\CreateJs());
|
||||||
|
|
||||||
|
|
51
lib/base.php
51
lib/base.php
|
@ -588,35 +588,36 @@ class OC {
|
||||||
ini_set('session.cookie_secure', true);
|
ini_set('session.cookie_secure', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = OC_Util::checkServer(\OC::$server->getConfig());
|
if (!defined('OC_CONSOLE')) {
|
||||||
if (count($errors) > 0) {
|
$errors = OC_Util::checkServer(\OC::$server->getConfig());
|
||||||
if (self::$CLI) {
|
if (count($errors) > 0) {
|
||||||
// Convert l10n string into regular string for usage in database
|
if (self::$CLI) {
|
||||||
$staticErrors = [];
|
// Convert l10n string into regular string for usage in database
|
||||||
foreach ($errors as $error) {
|
$staticErrors = [];
|
||||||
echo $error['error'] . "\n";
|
foreach ($errors as $error) {
|
||||||
echo $error['hint'] . "\n\n";
|
echo $error['error'] . "\n";
|
||||||
$staticErrors[] = [
|
echo $error['hint'] . "\n\n";
|
||||||
'error' => (string) $error['error'],
|
$staticErrors[] = [
|
||||||
'hint' => (string) $error['hint'],
|
'error' => (string)$error['error'],
|
||||||
];
|
'hint' => (string)$error['hint'],
|
||||||
}
|
];
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors));
|
\OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors));
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo('Writing to database failed');
|
echo('Writing to database failed');
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
||||||
|
OC_Template::printGuestPage('', 'error', array('errors' => $errors));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
exit(1);
|
} elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) {
|
||||||
} else {
|
|
||||||
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
|
||||||
OC_Template::printGuestPage('', 'error', array('errors' => $errors));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} elseif(self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) {
|
|
||||||
\OC::$server->getConfig()->deleteAppValue('core', 'cronErrors');
|
\OC::$server->getConfig()->deleteAppValue('core', 'cronErrors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to set the session lifetime
|
//try to set the session lifetime
|
||||||
$sessionLifeTime = self::getSessionLifeTime();
|
$sessionLifeTime = self::getSessionLifeTime();
|
||||||
@ini_set('gc_maxlifetime', (string)$sessionLifeTime);
|
@ini_set('gc_maxlifetime', (string)$sessionLifeTime);
|
||||||
|
|
Loading…
Reference in New Issue