aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Status.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Status.php')
-rw-r--r--core/Command/Status.php38
1 files changed, 27 insertions, 11 deletions
diff --git a/core/Command/Status.php b/core/Command/Status.php
index 45ccb28f5c4..57b831c7eaa 100644
--- a/core/Command/Status.php
+++ b/core/Command/Status.php
@@ -29,17 +29,15 @@ use OCP\Defaults;
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 {
- private IConfig $config;
- private Defaults $themingDefaults;
-
- public function __construct(IConfig $config, Defaults $themingDefaults) {
+ public function __construct(
+ private IConfig $config,
+ private Defaults $themingDefaults,
+ ) {
parent::__construct('status');
-
- $this->config = $config;
- $this->themingDefaults = $themingDefaults;
}
protected function configure() {
@@ -47,22 +45,40 @@ class Status extends Base {
$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);
+ }
+
+ if ($input->getOption('exit-code')) {
+ if ($maintenanceMode === true) {
+ return 1;
+ }
+ if ($needUpgrade === true) {
+ return 2;
+ }
+ }
return 0;
}
}