Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to enable/disable maintenance mode from cli. #8748

Merged
merged 3 commits into from
May 29, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions core/command/maintenance/mmode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
* and 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 Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class MMode extends Command {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just Mode?


protected function configure() {
$this
->setName('maintenance:mmode')
Copy link
Member

Choose a reason for hiding this comment

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

especially here the mmode is kind of strange

->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')) {
\OC_Config::setValue('maintenance', true);
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if the legacy class OC_Config would not be used - but this has to be addressed separately

$output->writeln('Maintenance mode enabled');
} elseif ($input->getOption('off')) {
\OC_Config::setValue('maintenance', false);
$output->writeln('Maintenance mode disabled');
} else {
if (\OC_Config::getValue('maintenance', false)) {
$output->writeln('Maintenance mode is currently enabled');
} else {
$output->writeln('Maintenance mode is currently disabled');
}
}
}
}
1 change: 1 addition & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$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\MMode());
$application->add(new OC\Core\Command\App\Disable());
$application->add(new OC\Core\Command\App\Enable());
$application->add(new OC\Core\Command\App\ListApps());
Expand Down