2013-09-01 10:40:50 -04:00
|
|
|
<?php
|
2024-05-24 13:43:47 -04:00
|
|
|
|
2013-09-19 13:12:16 -04:00
|
|
|
/**
|
2024-05-24 13:43:47 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-09-19 13:12:16 -04:00
|
|
|
*/
|
2013-09-01 10:40:50 -04:00
|
|
|
namespace OC\Core\Command;
|
|
|
|
|
|
2021-08-18 08:27:03 -04:00
|
|
|
use OCP\Defaults;
|
|
|
|
|
use OCP\IConfig;
|
2024-09-17 16:38:44 -04:00
|
|
|
use OCP\ServerVersion;
|
2021-08-18 08:27:03 -04:00
|
|
|
use OCP\Util;
|
2013-09-01 10:40:50 -04:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2022-12-22 16:03:21 -05:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2013-09-01 10:40:50 -04:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
2015-04-09 05:45:07 -04:00
|
|
|
class Status extends Base {
|
2023-06-12 11:50:14 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private IConfig $config,
|
|
|
|
|
private Defaults $themingDefaults,
|
2024-09-17 16:38:44 -04:00
|
|
|
private ServerVersion $serverVersion,
|
2023-06-12 11:50:14 -04:00
|
|
|
) {
|
2021-08-18 08:27:03 -04:00
|
|
|
parent::__construct('status');
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-02 12:20:04 -04:00
|
|
|
protected function configure() {
|
2015-04-09 05:45:07 -04:00
|
|
|
parent::configure();
|
|
|
|
|
|
2013-09-01 10:40:50 -04:00
|
|
|
$this
|
|
|
|
|
->setDescription('show some status information')
|
2022-12-22 16:03:21 -05:00
|
|
|
->addOption(
|
|
|
|
|
'exit-code',
|
|
|
|
|
'e',
|
|
|
|
|
InputOption::VALUE_NONE,
|
|
|
|
|
'exit with 0 if running in normal mode, 1 when in maintenance mode, 2 when `./occ upgrade` is needed. Does not write any output to STDOUT.'
|
|
|
|
|
);
|
2013-09-01 10:40:50 -04:00
|
|
|
}
|
|
|
|
|
|
2020-06-26 08:54:51 -04:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2022-12-22 16:03:21 -05:00
|
|
|
$maintenanceMode = $this->config->getSystemValueBool('maintenance', false);
|
|
|
|
|
$needUpgrade = Util::needUpgrade();
|
2020-03-26 04:30:18 -04:00
|
|
|
$values = [
|
2021-08-18 08:27:03 -04:00
|
|
|
'installed' => $this->config->getSystemValueBool('installed', false),
|
2024-09-17 16:38:44 -04:00
|
|
|
'version' => implode('.', $this->serverVersion->getVersion()),
|
|
|
|
|
'versionstring' => $this->serverVersion->getVersionString(),
|
2016-09-06 08:11:30 -04:00
|
|
|
'edition' => '',
|
2022-12-22 16:03:21 -05:00
|
|
|
'maintenance' => $maintenanceMode,
|
|
|
|
|
'needsDbUpgrade' => $needUpgrade,
|
2021-08-18 08:27:03 -04:00
|
|
|
'productname' => $this->themingDefaults->getProductName(),
|
|
|
|
|
'extendedSupport' => Util::hasExtendedSupport()
|
2020-03-26 04:30:18 -04:00
|
|
|
];
|
2015-04-09 05:45:07 -04:00
|
|
|
|
2023-01-03 09:43:25 -05:00
|
|
|
if ($input->getOption('verbose') || !$input->getOption('exit-code')) {
|
|
|
|
|
$this->writeArrayInOutputFormat($input, $output, $values);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 06:47:58 -05:00
|
|
|
if ($input->getOption('exit-code')) {
|
|
|
|
|
if ($maintenanceMode === true) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if ($needUpgrade === true) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-26 08:54:51 -04:00
|
|
|
return 0;
|
2013-09-01 10:40:50 -04:00
|
|
|
}
|
|
|
|
|
}
|