summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2014-05-29 03:45:49 +0200
committerAndreas Fischer <bantu@owncloud.com>2014-05-29 03:45:49 +0200
commit678a6b98ff7925c9934fa7349600ff9fe39e8ecd (patch)
tree426125dcbfbaea16ab0d3cf04d388b2d36af54c4
parent3ef9570d02d6a83082355e1f485a863a1bc4b431 (diff)
parent43759f1f468fac8de4a8db0b8d94d004f6fb3745 (diff)
downloadnextcloud-server-678a6b98ff7925c9934fa7349600ff9fe39e8ecd.tar.gz
nextcloud-server-678a6b98ff7925c9934fa7349600ff9fe39e8ecd.zip
Merge pull request #8748 from owncloud/cli_maintenance_mode
Add ability to enable/disable maintenance mode from cli. * owncloud/cli_maintenance_mode: Use OC\Config instead of OC_Config Changed class name to mode Add ability to enable/disable maintenance mode from cli.
-rw-r--r--core/command/maintenance/mode.php61
-rw-r--r--core/register_command.php1
2 files changed, 62 insertions, 0 deletions
diff --git a/core/command/maintenance/mode.php b/core/command/maintenance/mode.php
new file mode 100644
index 00000000000..f26a11384a8
--- /dev/null
+++ b/core/command/maintenance/mode.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> and
+ * Copyright (c) 2014 Stephen Colebrook <scolebrook@mac.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Core\Command\Maintenance;
+
+use OC\Config;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class Mode extends Command {
+
+ protected $config;
+
+ public function __construct(Config $config) {
+ $this->config = $config;
+ parent::__construct();
+ }
+
+ protected function configure() {
+ $this
+ ->setName('maintenance:mode')
+ ->setDescription('set maintenance mode')
+ ->addOption(
+ 'on',
+ null,
+ InputOption::VALUE_NONE,
+ 'enable maintenance mode'
+ )
+ ->addOption(
+ 'off',
+ null,
+ InputOption::VALUE_NONE,
+ 'disable maintenance mode'
+ );
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ if ($input->getOption('on')) {
+ $this->config->setValue('maintenance', true);
+ $output->writeln('Maintenance mode enabled');
+ } elseif ($input->getOption('off')) {
+ $this->config->setValue('maintenance', false);
+ $output->writeln('Maintenance mode disabled');
+ } else {
+ if ($this->config->getValue('maintenance', false)) {
+ $output->writeln('Maintenance mode is currently enabled');
+ } else {
+ $output->writeln('Maintenance mode is currently disabled');
+ }
+ }
+ }
+}
diff --git a/core/register_command.php b/core/register_command.php
index dfb5134eff9..e9de76c1444 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -12,6 +12,7 @@ $application->add(new OC\Core\Command\Db\GenerateChangeScript());
$application->add(new OC\Core\Command\Db\ConvertType(OC_Config::getObject(), new \OC\DB\ConnectionFactory()));
$application->add(new OC\Core\Command\Upgrade());
$application->add(new OC\Core\Command\Maintenance\SingleUser());
+$application->add(new OC\Core\Command\Maintenance\Mode(OC_Config::getObject()));
$application->add(new OC\Core\Command\App\Disable());
$application->add(new OC\Core\Command\App\Enable());
$application->add(new OC\Core\Command\App\ListApps());