Completed
Pull Request — master (#348)
by Victor
04:50
created

StartCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 46
ccs 0
cts 17
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 12 3
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\InputArgument;
25
use Symfony\Component\Console\Input\InputInterface;
26
use Symfony\Component\Console\Input\InputOption;
27
use Symfony\Component\Console\Output\OutputInterface;
28
use Symfony\Component\Console\Input\ArrayInput;
29
30
class StartCommand extends Command {
31
32
	protected $stack = [
33
		[ 'command' => 'upgrade:info'],
34
		[ 'command' => 'upgrade:checkSystem'],
35
		[ 'command' => 'upgrade:detect', '--exit-if-none' => '1'],
36
		//[ 'command' => 'upgrade:maintenanceMode', '--on' => '1'],
37
		[ 'command' => 'upgrade:backupDb'],
38
		[ 'command' => 'upgrade:backupData'],
39
		[ 'command' => 'upgrade:checkpoint', '--create' => '1'],
40
		[ 'command' => 'upgrade:preUpgradeRepair'],
41
		[ 'command' => 'upgrade:dbUpgrade', 'simulation' => 'true'],
42
		[ 'command' => 'upgrade:dbUpgrade'],
43
		[ 'command' => 'upgrade:disableNotShippedApps'],
44
		[ 'command' => 'upgrade:executeCoreUpgradeScripts'],
45
		[ 'command' => 'upgrade:upgradeShippedApps'],
46
		[ 'command' => 'upgrade:enableNotShippedApps'],
47
		[ 'command' => 'upgrade:cleanCache'],
48
		[ 'command' => 'upgrade:postUpgradeRepair'],
49
		[ 'command' => 'upgrade:restartWebServer'],
50
		[ 'command' => 'upgrade:updateConfig'],
51
		//[ 'command' => 'upgrade:maintenanceMode', '--off' => '1'],
52
		[ 'command' => 'upgrade:postUpgradeCleanup'],
53
	];
54
55
	protected function configure(){
56
		$this
57
				->setName('upgrade:start')
58
				->setDescription('automated process')
59
		;
60
	}
61
62
	protected function execute(InputInterface $input, OutputInterface $output){
63
		$app = $this->getApplication();
64
		foreach ($this->stack as $command){
65
			$input = new ArrayInput($command);
66
			$returnCode = $app->doRun($input, $output);
67
			if ($returnCode != 0){
68
				// Something went wrong
69
				break;
70
			}
71
		}
72
		$output->writeln('Done');
73
	}
74
75
}
76