Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions core/Command/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\IConfig;
use OCP\Util;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Status extends Base {
Expand All @@ -47,22 +48,40 @@ protected function configure() {

$this
->setDescription('show some status information')
;
->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.'
);
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$maintenanceMode = $this->config->getSystemValueBool('maintenance', false);
$needUpgrade = Util::needUpgrade();
$values = [
'installed' => $this->config->getSystemValueBool('installed', false),
'version' => implode('.', Util::getVersion()),
'versionstring' => OC_Util::getVersionString(),
'edition' => '',
'maintenance' => $this->config->getSystemValueBool('maintenance', false),
'needsDbUpgrade' => Util::needUpgrade(),
'maintenance' => $maintenanceMode,
'needsDbUpgrade' => $needUpgrade,
'productname' => $this->themingDefaults->getProductName(),
'extendedSupport' => Util::hasExtendedSupport()
];

$this->writeArrayInOutputFormat($input, $output, $values);
if ($input->getOption('verbose') || !$input->getOption('exit-code')) {
$this->writeArrayInOutputFormat($input, $output, $values);
}
Comment on lines +73 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I oversee something? Previously it was outputted independent of the verbose setting, but this changed now. I'd consider it a behavioral change which is not OK for a backport.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but default is !exit-code so the old behaviour persists


if ($input->getOption('exit-code')) {
if ($maintenanceMode === true) {
return 1;
}
if ($needUpgrade === true) {
return 2;
}
}
return 0;
}
}
3 changes: 2 additions & 1 deletion lib/private/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ private function writeMaintenanceModeInfo(
InputInterface $input, ConsoleOutputInterface $output
) {
if ($input->getArgument('command') !== '_completion'
&& $input->getArgument('command') !== 'maintenance:mode') {
&& $input->getArgument('command') !== 'maintenance:mode'
&& $input->getArgument('command') !== 'status') {
$errOutput = $output->getErrorOutput();
$errOutput->writeln(
'<comment>Nextcloud is in maintenance mode, hence the database isn\'t accessible.' . PHP_EOL .
Expand Down