1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Victor Dubiniuk <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc. |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Owncloud\Updater\Command; |
23
|
|
|
|
24
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
25
|
|
|
use Symfony\Component\Console\Input\InputOption; |
26
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
27
|
|
|
use Symfony\Component\Process\ProcessUtils; |
28
|
|
|
use Owncloud\Updater\Utils\OccRunner; |
29
|
|
|
|
30
|
|
|
class MaintenanceModeCommand extends Command { |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var OccRunner $occRunner |
34
|
|
|
*/ |
35
|
|
|
protected $occRunner; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Constructor |
39
|
|
|
* |
40
|
|
|
* @param OccRunner $occRunner |
41
|
|
|
*/ |
42
|
|
|
public function __construct(OccRunner $occRunner){ |
43
|
|
|
parent::__construct(); |
44
|
|
|
$this->occRunner = $occRunner; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function configure(){ |
48
|
|
|
$this |
49
|
|
|
->setName('upgrade:maintenanceMode') |
50
|
|
|
->setDescription('Toggle maintenance mode') |
51
|
|
|
->addOption( |
52
|
|
|
'on', null, InputOption::VALUE_NONE, 'enable maintenance mode' |
53
|
|
|
) |
54
|
|
|
->addOption( |
55
|
|
|
'off', null, InputOption::VALUE_NONE, 'disable maintenance mode' |
56
|
|
|
) |
57
|
|
|
; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function execute(InputInterface $input, OutputInterface $output){ |
61
|
|
|
$mode = ''; |
62
|
|
|
if ($input->getOption('on')){ |
63
|
|
|
$mode = '--on'; |
64
|
|
|
} elseif ($input->getOption('off')){ |
65
|
|
|
$mode = '--off'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if ($mode !== ''){ |
69
|
|
|
$mode = ProcessUtils::escapeArgument($mode); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$response = $this->occRunner->run('maintenance:mode ' . $mode); |
73
|
|
|
$output->writeln($response); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|