summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-01-04 09:51:12 +0100
committerGitHub <noreply@github.com>2023-01-04 09:51:12 +0100
commitc8160a61509ef0851585cac6014829c74a888a17 (patch)
treeab75f81ef2310a4eb9e1349c3b802e4e2900d0bc /core/Command
parent348454cb91cd0f7e75e77ae9080237ebab31d66b (diff)
parent2c1a811e274cb417b7ef4c34b8461c0ded3b79ff (diff)
downloadnextcloud-server-c8160a61509ef0851585cac6014829c74a888a17.tar.gz
nextcloud-server-c8160a61509ef0851585cac6014829c74a888a17.zip
Merge pull request #35873 from leegarrett/35830_lgarrett
Implement occ status command via return codes v2 (Fixes: #35704)
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Status.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/core/Command/Status.php b/core/Command/Status.php
index 45ccb28f5c4..c59dac557a8 100644
--- a/core/Command/Status.php
+++ b/core/Command/Status.php
@@ -29,6 +29,7 @@ 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 {
@@ -47,22 +48,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;
}
}