@@ -33,58 +33,58 @@ |
||
33 | 33 | |
34 | 34 | class MaintenancePlugin extends ServerPlugin { |
35 | 35 | |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Reference to main server object |
|
41 | - * |
|
42 | - * @var Server |
|
43 | - */ |
|
44 | - private $server; |
|
39 | + /** |
|
40 | + * Reference to main server object |
|
41 | + * |
|
42 | + * @var Server |
|
43 | + */ |
|
44 | + private $server; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param IConfig $config |
|
48 | - */ |
|
49 | - public function __construct(IConfig $config = null) { |
|
50 | - $this->config = $config; |
|
51 | - if (is_null($config)) { |
|
52 | - $this->config = \OC::$server->getConfig(); |
|
53 | - } |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param IConfig $config |
|
48 | + */ |
|
49 | + public function __construct(IConfig $config = null) { |
|
50 | + $this->config = $config; |
|
51 | + if (is_null($config)) { |
|
52 | + $this->config = \OC::$server->getConfig(); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * This initializes the plugin. |
|
59 | - * |
|
60 | - * This function is called by \Sabre\DAV\Server, after |
|
61 | - * addPlugin is called. |
|
62 | - * |
|
63 | - * This method should set up the required event subscriptions. |
|
64 | - * |
|
65 | - * @param \Sabre\DAV\Server $server |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function initialize(\Sabre\DAV\Server $server) { |
|
69 | - $this->server = $server; |
|
70 | - $this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 1); |
|
71 | - } |
|
57 | + /** |
|
58 | + * This initializes the plugin. |
|
59 | + * |
|
60 | + * This function is called by \Sabre\DAV\Server, after |
|
61 | + * addPlugin is called. |
|
62 | + * |
|
63 | + * This method should set up the required event subscriptions. |
|
64 | + * |
|
65 | + * @param \Sabre\DAV\Server $server |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function initialize(\Sabre\DAV\Server $server) { |
|
69 | + $this->server = $server; |
|
70 | + $this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 1); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * This method is called before any HTTP method and returns http status code 503 |
|
75 | - * in case the system is in maintenance mode. |
|
76 | - * |
|
77 | - * @throws ServiceUnavailable |
|
78 | - * @return bool |
|
79 | - */ |
|
80 | - public function checkMaintenanceMode() { |
|
81 | - if ($this->config->getSystemValueBool('maintenance')) { |
|
82 | - throw new ServiceUnavailable('System in maintenance mode.'); |
|
83 | - } |
|
84 | - if (Util::needUpgrade()) { |
|
85 | - throw new ServiceUnavailable('Upgrade needed'); |
|
86 | - } |
|
73 | + /** |
|
74 | + * This method is called before any HTTP method and returns http status code 503 |
|
75 | + * in case the system is in maintenance mode. |
|
76 | + * |
|
77 | + * @throws ServiceUnavailable |
|
78 | + * @return bool |
|
79 | + */ |
|
80 | + public function checkMaintenanceMode() { |
|
81 | + if ($this->config->getSystemValueBool('maintenance')) { |
|
82 | + throw new ServiceUnavailable('System in maintenance mode.'); |
|
83 | + } |
|
84 | + if (Util::needUpgrade()) { |
|
85 | + throw new ServiceUnavailable('Upgrade needed'); |
|
86 | + } |
|
87 | 87 | |
88 | - return true; |
|
89 | - } |
|
88 | + return true; |
|
89 | + } |
|
90 | 90 | } |
@@ -40,147 +40,147 @@ |
||
40 | 40 | |
41 | 41 | class DecryptAll extends Command { |
42 | 42 | |
43 | - /** @var IManager */ |
|
44 | - protected $encryptionManager; |
|
45 | - |
|
46 | - /** @var IAppManager */ |
|
47 | - protected $appManager; |
|
48 | - |
|
49 | - /** @var IConfig */ |
|
50 | - protected $config; |
|
51 | - |
|
52 | - /** @var QuestionHelper */ |
|
53 | - protected $questionHelper; |
|
54 | - |
|
55 | - /** @var bool */ |
|
56 | - protected $wasTrashbinEnabled; |
|
57 | - |
|
58 | - /** @var bool */ |
|
59 | - protected $wasMaintenanceModeEnabled; |
|
60 | - |
|
61 | - /** @var \OC\Encryption\DecryptAll */ |
|
62 | - protected $decryptAll; |
|
63 | - |
|
64 | - /** |
|
65 | - * @param IManager $encryptionManager |
|
66 | - * @param IAppManager $appManager |
|
67 | - * @param IConfig $config |
|
68 | - * @param \OC\Encryption\DecryptAll $decryptAll |
|
69 | - * @param QuestionHelper $questionHelper |
|
70 | - */ |
|
71 | - public function __construct( |
|
72 | - IManager $encryptionManager, |
|
73 | - IAppManager $appManager, |
|
74 | - IConfig $config, |
|
75 | - \OC\Encryption\DecryptAll $decryptAll, |
|
76 | - QuestionHelper $questionHelper |
|
77 | - ) { |
|
78 | - parent::__construct(); |
|
79 | - |
|
80 | - $this->appManager = $appManager; |
|
81 | - $this->encryptionManager = $encryptionManager; |
|
82 | - $this->config = $config; |
|
83 | - $this->decryptAll = $decryptAll; |
|
84 | - $this->questionHelper = $questionHelper; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Set maintenance mode and disable the trashbin app |
|
89 | - */ |
|
90 | - protected function forceMaintenanceAndTrashbin() { |
|
91 | - $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
92 | - $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
93 | - $this->config->setSystemValue('maintenance', true); |
|
94 | - $this->appManager->disableApp('files_trashbin'); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Reset the maintenance mode and re-enable the trashbin app |
|
99 | - */ |
|
100 | - protected function resetMaintenanceAndTrashbin() { |
|
101 | - $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
102 | - if ($this->wasTrashbinEnabled) { |
|
103 | - $this->appManager->enableApp('files_trashbin'); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - protected function configure() { |
|
108 | - parent::configure(); |
|
109 | - |
|
110 | - $this->setName('encryption:decrypt-all'); |
|
111 | - $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
112 | - $this->setHelp( |
|
113 | - 'This will disable server-side encryption and decrypt all files for ' |
|
114 | - . 'all users if it is supported by your encryption module. ' |
|
115 | - . 'Please make sure that no user access his files during this process!' |
|
116 | - ); |
|
117 | - $this->addArgument( |
|
118 | - 'user', |
|
119 | - InputArgument::OPTIONAL, |
|
120 | - 'user for which you want to decrypt all files (optional)', |
|
121 | - '' |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
126 | - if ( !$input->isInteractive() ) { |
|
127 | - $output->writeln('Invalid TTY.'); |
|
128 | - $output->writeln('If you are trying to execute the command in a Docker '); |
|
129 | - $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
130 | - $output->writeln("the '-i' and '-t' options."); |
|
131 | - $output->writeln(''); |
|
132 | - return; |
|
133 | - } |
|
134 | - |
|
135 | - try { |
|
136 | - if ($this->encryptionManager->isEnabled() === true) { |
|
137 | - $output->write('Disable server side encryption... '); |
|
138 | - $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
139 | - $output->writeln('done.'); |
|
140 | - } else { |
|
141 | - $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
142 | - return; |
|
143 | - } |
|
144 | - |
|
145 | - $uid = $input->getArgument('user'); |
|
146 | - if ($uid === '') { |
|
147 | - $message = 'your Nextcloud'; |
|
148 | - } else { |
|
149 | - $message = "$uid's account"; |
|
150 | - } |
|
151 | - |
|
152 | - $output->writeln("\n"); |
|
153 | - $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
154 | - $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
155 | - $output->writeln('Depending on the number and size of your files this can take some time'); |
|
156 | - $output->writeln('Please make sure that no user access his files during this process!'); |
|
157 | - $output->writeln(''); |
|
158 | - $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
159 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
160 | - $this->forceMaintenanceAndTrashbin(); |
|
161 | - $user = $input->getArgument('user'); |
|
162 | - $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
163 | - if ($result === false) { |
|
164 | - $output->writeln(' aborted.'); |
|
165 | - $output->writeln('Server side encryption remains enabled'); |
|
166 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
167 | - } else if ($uid !== '') { |
|
168 | - $output->writeln('Server side encryption remains enabled'); |
|
169 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
170 | - } |
|
171 | - $this->resetMaintenanceAndTrashbin(); |
|
172 | - } else { |
|
173 | - $output->write('Enable server side encryption... '); |
|
174 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
175 | - $output->writeln('done.'); |
|
176 | - $output->writeln('aborted'); |
|
177 | - } |
|
178 | - } catch (\Exception $e) { |
|
179 | - // enable server side encryption again if something went wrong |
|
180 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
181 | - $this->resetMaintenanceAndTrashbin(); |
|
182 | - throw $e; |
|
183 | - } |
|
184 | - |
|
185 | - } |
|
43 | + /** @var IManager */ |
|
44 | + protected $encryptionManager; |
|
45 | + |
|
46 | + /** @var IAppManager */ |
|
47 | + protected $appManager; |
|
48 | + |
|
49 | + /** @var IConfig */ |
|
50 | + protected $config; |
|
51 | + |
|
52 | + /** @var QuestionHelper */ |
|
53 | + protected $questionHelper; |
|
54 | + |
|
55 | + /** @var bool */ |
|
56 | + protected $wasTrashbinEnabled; |
|
57 | + |
|
58 | + /** @var bool */ |
|
59 | + protected $wasMaintenanceModeEnabled; |
|
60 | + |
|
61 | + /** @var \OC\Encryption\DecryptAll */ |
|
62 | + protected $decryptAll; |
|
63 | + |
|
64 | + /** |
|
65 | + * @param IManager $encryptionManager |
|
66 | + * @param IAppManager $appManager |
|
67 | + * @param IConfig $config |
|
68 | + * @param \OC\Encryption\DecryptAll $decryptAll |
|
69 | + * @param QuestionHelper $questionHelper |
|
70 | + */ |
|
71 | + public function __construct( |
|
72 | + IManager $encryptionManager, |
|
73 | + IAppManager $appManager, |
|
74 | + IConfig $config, |
|
75 | + \OC\Encryption\DecryptAll $decryptAll, |
|
76 | + QuestionHelper $questionHelper |
|
77 | + ) { |
|
78 | + parent::__construct(); |
|
79 | + |
|
80 | + $this->appManager = $appManager; |
|
81 | + $this->encryptionManager = $encryptionManager; |
|
82 | + $this->config = $config; |
|
83 | + $this->decryptAll = $decryptAll; |
|
84 | + $this->questionHelper = $questionHelper; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Set maintenance mode and disable the trashbin app |
|
89 | + */ |
|
90 | + protected function forceMaintenanceAndTrashbin() { |
|
91 | + $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
92 | + $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
93 | + $this->config->setSystemValue('maintenance', true); |
|
94 | + $this->appManager->disableApp('files_trashbin'); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Reset the maintenance mode and re-enable the trashbin app |
|
99 | + */ |
|
100 | + protected function resetMaintenanceAndTrashbin() { |
|
101 | + $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
102 | + if ($this->wasTrashbinEnabled) { |
|
103 | + $this->appManager->enableApp('files_trashbin'); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + protected function configure() { |
|
108 | + parent::configure(); |
|
109 | + |
|
110 | + $this->setName('encryption:decrypt-all'); |
|
111 | + $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
112 | + $this->setHelp( |
|
113 | + 'This will disable server-side encryption and decrypt all files for ' |
|
114 | + . 'all users if it is supported by your encryption module. ' |
|
115 | + . 'Please make sure that no user access his files during this process!' |
|
116 | + ); |
|
117 | + $this->addArgument( |
|
118 | + 'user', |
|
119 | + InputArgument::OPTIONAL, |
|
120 | + 'user for which you want to decrypt all files (optional)', |
|
121 | + '' |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
126 | + if ( !$input->isInteractive() ) { |
|
127 | + $output->writeln('Invalid TTY.'); |
|
128 | + $output->writeln('If you are trying to execute the command in a Docker '); |
|
129 | + $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
130 | + $output->writeln("the '-i' and '-t' options."); |
|
131 | + $output->writeln(''); |
|
132 | + return; |
|
133 | + } |
|
134 | + |
|
135 | + try { |
|
136 | + if ($this->encryptionManager->isEnabled() === true) { |
|
137 | + $output->write('Disable server side encryption... '); |
|
138 | + $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
139 | + $output->writeln('done.'); |
|
140 | + } else { |
|
141 | + $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
142 | + return; |
|
143 | + } |
|
144 | + |
|
145 | + $uid = $input->getArgument('user'); |
|
146 | + if ($uid === '') { |
|
147 | + $message = 'your Nextcloud'; |
|
148 | + } else { |
|
149 | + $message = "$uid's account"; |
|
150 | + } |
|
151 | + |
|
152 | + $output->writeln("\n"); |
|
153 | + $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
154 | + $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
155 | + $output->writeln('Depending on the number and size of your files this can take some time'); |
|
156 | + $output->writeln('Please make sure that no user access his files during this process!'); |
|
157 | + $output->writeln(''); |
|
158 | + $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
159 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
160 | + $this->forceMaintenanceAndTrashbin(); |
|
161 | + $user = $input->getArgument('user'); |
|
162 | + $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
163 | + if ($result === false) { |
|
164 | + $output->writeln(' aborted.'); |
|
165 | + $output->writeln('Server side encryption remains enabled'); |
|
166 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
167 | + } else if ($uid !== '') { |
|
168 | + $output->writeln('Server side encryption remains enabled'); |
|
169 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
170 | + } |
|
171 | + $this->resetMaintenanceAndTrashbin(); |
|
172 | + } else { |
|
173 | + $output->write('Enable server side encryption... '); |
|
174 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
175 | + $output->writeln('done.'); |
|
176 | + $output->writeln('aborted'); |
|
177 | + } |
|
178 | + } catch (\Exception $e) { |
|
179 | + // enable server side encryption again if something went wrong |
|
180 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
181 | + $this->resetMaintenanceAndTrashbin(); |
|
182 | + throw $e; |
|
183 | + } |
|
184 | + |
|
185 | + } |
|
186 | 186 | } |
@@ -36,110 +36,110 @@ |
||
36 | 36 | |
37 | 37 | class EncryptAll extends Command { |
38 | 38 | |
39 | - /** @var IManager */ |
|
40 | - protected $encryptionManager; |
|
41 | - |
|
42 | - /** @var IAppManager */ |
|
43 | - protected $appManager; |
|
44 | - |
|
45 | - /** @var IConfig */ |
|
46 | - protected $config; |
|
47 | - |
|
48 | - /** @var QuestionHelper */ |
|
49 | - protected $questionHelper; |
|
50 | - |
|
51 | - /** @var bool */ |
|
52 | - protected $wasTrashbinEnabled; |
|
53 | - |
|
54 | - /** @var bool */ |
|
55 | - protected $wasMaintenanceModeEnabled; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param IManager $encryptionManager |
|
59 | - * @param IAppManager $appManager |
|
60 | - * @param IConfig $config |
|
61 | - * @param QuestionHelper $questionHelper |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - IManager $encryptionManager, |
|
65 | - IAppManager $appManager, |
|
66 | - IConfig $config, |
|
67 | - QuestionHelper $questionHelper |
|
68 | - ) { |
|
69 | - parent::__construct(); |
|
70 | - $this->appManager = $appManager; |
|
71 | - $this->encryptionManager = $encryptionManager; |
|
72 | - $this->config = $config; |
|
73 | - $this->questionHelper = $questionHelper; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Set maintenance mode and disable the trashbin app |
|
78 | - */ |
|
79 | - protected function forceMaintenanceAndTrashbin() { |
|
80 | - $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
81 | - $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
82 | - $this->config->setSystemValue('maintenance', true); |
|
83 | - $this->appManager->disableApp('files_trashbin'); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Reset the maintenance mode and re-enable the trashbin app |
|
88 | - */ |
|
89 | - protected function resetMaintenanceAndTrashbin() { |
|
90 | - $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
91 | - if ($this->wasTrashbinEnabled) { |
|
92 | - $this->appManager->enableApp('files_trashbin'); |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - protected function configure() { |
|
97 | - parent::configure(); |
|
98 | - |
|
99 | - $this->setName('encryption:encrypt-all'); |
|
100 | - $this->setDescription('Encrypt all files for all users'); |
|
101 | - $this->setHelp( |
|
102 | - 'This will encrypt all files for all users. ' |
|
103 | - . 'Please make sure that no user access his files during this process!' |
|
104 | - ); |
|
105 | - } |
|
106 | - |
|
107 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
108 | - if ( !$input->isInteractive() ) { |
|
109 | - $output->writeln('Invalid TTY.'); |
|
110 | - $output->writeln('If you are trying to execute the command in a Docker '); |
|
111 | - $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
112 | - $output->writeln("the '-i' and '-t' options."); |
|
113 | - $output->writeln(''); |
|
114 | - return; |
|
115 | - } |
|
116 | - |
|
117 | - if ($this->encryptionManager->isEnabled() === false) { |
|
118 | - throw new \Exception('Server side encryption is not enabled'); |
|
119 | - } |
|
120 | - |
|
121 | - $output->writeln("\n"); |
|
122 | - $output->writeln('You are about to encrypt all files stored in your Nextcloud installation.'); |
|
123 | - $output->writeln('Depending on the number of available files, and their size, this may take quite some time.'); |
|
124 | - $output->writeln('Please ensure that no user accesses their files during this time!'); |
|
125 | - $output->writeln('Note: The encryption module you use determines which files get encrypted.'); |
|
126 | - $output->writeln(''); |
|
127 | - $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
128 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
129 | - $this->forceMaintenanceAndTrashbin(); |
|
130 | - |
|
131 | - try { |
|
132 | - $defaultModule = $this->encryptionManager->getEncryptionModule(); |
|
133 | - $defaultModule->encryptAll($input, $output); |
|
134 | - } catch (\Exception $ex) { |
|
135 | - $this->resetMaintenanceAndTrashbin(); |
|
136 | - throw $ex; |
|
137 | - } |
|
138 | - |
|
139 | - $this->resetMaintenanceAndTrashbin(); |
|
140 | - } else { |
|
141 | - $output->writeln('aborted'); |
|
142 | - } |
|
143 | - } |
|
39 | + /** @var IManager */ |
|
40 | + protected $encryptionManager; |
|
41 | + |
|
42 | + /** @var IAppManager */ |
|
43 | + protected $appManager; |
|
44 | + |
|
45 | + /** @var IConfig */ |
|
46 | + protected $config; |
|
47 | + |
|
48 | + /** @var QuestionHelper */ |
|
49 | + protected $questionHelper; |
|
50 | + |
|
51 | + /** @var bool */ |
|
52 | + protected $wasTrashbinEnabled; |
|
53 | + |
|
54 | + /** @var bool */ |
|
55 | + protected $wasMaintenanceModeEnabled; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param IManager $encryptionManager |
|
59 | + * @param IAppManager $appManager |
|
60 | + * @param IConfig $config |
|
61 | + * @param QuestionHelper $questionHelper |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + IManager $encryptionManager, |
|
65 | + IAppManager $appManager, |
|
66 | + IConfig $config, |
|
67 | + QuestionHelper $questionHelper |
|
68 | + ) { |
|
69 | + parent::__construct(); |
|
70 | + $this->appManager = $appManager; |
|
71 | + $this->encryptionManager = $encryptionManager; |
|
72 | + $this->config = $config; |
|
73 | + $this->questionHelper = $questionHelper; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Set maintenance mode and disable the trashbin app |
|
78 | + */ |
|
79 | + protected function forceMaintenanceAndTrashbin() { |
|
80 | + $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
81 | + $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
82 | + $this->config->setSystemValue('maintenance', true); |
|
83 | + $this->appManager->disableApp('files_trashbin'); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Reset the maintenance mode and re-enable the trashbin app |
|
88 | + */ |
|
89 | + protected function resetMaintenanceAndTrashbin() { |
|
90 | + $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
91 | + if ($this->wasTrashbinEnabled) { |
|
92 | + $this->appManager->enableApp('files_trashbin'); |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + protected function configure() { |
|
97 | + parent::configure(); |
|
98 | + |
|
99 | + $this->setName('encryption:encrypt-all'); |
|
100 | + $this->setDescription('Encrypt all files for all users'); |
|
101 | + $this->setHelp( |
|
102 | + 'This will encrypt all files for all users. ' |
|
103 | + . 'Please make sure that no user access his files during this process!' |
|
104 | + ); |
|
105 | + } |
|
106 | + |
|
107 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
108 | + if ( !$input->isInteractive() ) { |
|
109 | + $output->writeln('Invalid TTY.'); |
|
110 | + $output->writeln('If you are trying to execute the command in a Docker '); |
|
111 | + $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
112 | + $output->writeln("the '-i' and '-t' options."); |
|
113 | + $output->writeln(''); |
|
114 | + return; |
|
115 | + } |
|
116 | + |
|
117 | + if ($this->encryptionManager->isEnabled() === false) { |
|
118 | + throw new \Exception('Server side encryption is not enabled'); |
|
119 | + } |
|
120 | + |
|
121 | + $output->writeln("\n"); |
|
122 | + $output->writeln('You are about to encrypt all files stored in your Nextcloud installation.'); |
|
123 | + $output->writeln('Depending on the number of available files, and their size, this may take quite some time.'); |
|
124 | + $output->writeln('Please ensure that no user accesses their files during this time!'); |
|
125 | + $output->writeln('Note: The encryption module you use determines which files get encrypted.'); |
|
126 | + $output->writeln(''); |
|
127 | + $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
128 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
129 | + $this->forceMaintenanceAndTrashbin(); |
|
130 | + |
|
131 | + try { |
|
132 | + $defaultModule = $this->encryptionManager->getEncryptionModule(); |
|
133 | + $defaultModule->encryptAll($input, $output); |
|
134 | + } catch (\Exception $ex) { |
|
135 | + $this->resetMaintenanceAndTrashbin(); |
|
136 | + throw $ex; |
|
137 | + } |
|
138 | + |
|
139 | + $this->resetMaintenanceAndTrashbin(); |
|
140 | + } else { |
|
141 | + $output->writeln('aborted'); |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | 145 | } |
@@ -32,54 +32,54 @@ |
||
32 | 32 | |
33 | 33 | class Mode extends Command { |
34 | 34 | |
35 | - /** @var IConfig */ |
|
36 | - protected $config; |
|
35 | + /** @var IConfig */ |
|
36 | + protected $config; |
|
37 | 37 | |
38 | - public function __construct(IConfig $config) { |
|
39 | - $this->config = $config; |
|
40 | - parent::__construct(); |
|
41 | - } |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + $this->config = $config; |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - $this |
|
45 | - ->setName('maintenance:mode') |
|
46 | - ->setDescription('set maintenance mode') |
|
47 | - ->addOption( |
|
48 | - 'on', |
|
49 | - null, |
|
50 | - InputOption::VALUE_NONE, |
|
51 | - 'enable maintenance mode' |
|
52 | - ) |
|
53 | - ->addOption( |
|
54 | - 'off', |
|
55 | - null, |
|
56 | - InputOption::VALUE_NONE, |
|
57 | - 'disable maintenance mode' |
|
58 | - ); |
|
59 | - } |
|
43 | + protected function configure() { |
|
44 | + $this |
|
45 | + ->setName('maintenance:mode') |
|
46 | + ->setDescription('set maintenance mode') |
|
47 | + ->addOption( |
|
48 | + 'on', |
|
49 | + null, |
|
50 | + InputOption::VALUE_NONE, |
|
51 | + 'enable maintenance mode' |
|
52 | + ) |
|
53 | + ->addOption( |
|
54 | + 'off', |
|
55 | + null, |
|
56 | + InputOption::VALUE_NONE, |
|
57 | + 'disable maintenance mode' |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
62 | - $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
63 | - if ($input->getOption('on')) { |
|
64 | - if ($maintenanceMode === false) { |
|
65 | - $this->config->setSystemValue('maintenance', true); |
|
66 | - $output->writeln('Maintenance mode enabled'); |
|
67 | - } else { |
|
68 | - $output->writeln('Maintenance mode already enabled'); |
|
69 | - } |
|
70 | - } elseif ($input->getOption('off')) { |
|
71 | - if ($maintenanceMode === true) { |
|
72 | - $this->config->setSystemValue('maintenance', false); |
|
73 | - $output->writeln('Maintenance mode disabled'); |
|
74 | - } else { |
|
75 | - $output->writeln('Maintenance mode already disabled'); |
|
76 | - } |
|
77 | - } else { |
|
78 | - if ($maintenanceMode) { |
|
79 | - $output->writeln('Maintenance mode is currently enabled'); |
|
80 | - } else { |
|
81 | - $output->writeln('Maintenance mode is currently disabled'); |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
61 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
62 | + $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
63 | + if ($input->getOption('on')) { |
|
64 | + if ($maintenanceMode === false) { |
|
65 | + $this->config->setSystemValue('maintenance', true); |
|
66 | + $output->writeln('Maintenance mode enabled'); |
|
67 | + } else { |
|
68 | + $output->writeln('Maintenance mode already enabled'); |
|
69 | + } |
|
70 | + } elseif ($input->getOption('off')) { |
|
71 | + if ($maintenanceMode === true) { |
|
72 | + $this->config->setSystemValue('maintenance', false); |
|
73 | + $output->writeln('Maintenance mode disabled'); |
|
74 | + } else { |
|
75 | + $output->writeln('Maintenance mode already disabled'); |
|
76 | + } |
|
77 | + } else { |
|
78 | + if ($maintenanceMode) { |
|
79 | + $output->writeln('Maintenance mode is currently enabled'); |
|
80 | + } else { |
|
81 | + $output->writeln('Maintenance mode is currently disabled'); |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -38,119 +38,119 @@ |
||
38 | 38 | use Symfony\Component\EventDispatcher\GenericEvent; |
39 | 39 | |
40 | 40 | class Repair extends Command { |
41 | - /** @var \OC\Repair $repair */ |
|
42 | - protected $repair; |
|
43 | - /** @var IConfig */ |
|
44 | - protected $config; |
|
45 | - /** @var EventDispatcherInterface */ |
|
46 | - private $dispatcher; |
|
47 | - /** @var ProgressBar */ |
|
48 | - private $progress; |
|
49 | - /** @var OutputInterface */ |
|
50 | - private $output; |
|
51 | - /** @var IAppManager */ |
|
52 | - private $appManager; |
|
41 | + /** @var \OC\Repair $repair */ |
|
42 | + protected $repair; |
|
43 | + /** @var IConfig */ |
|
44 | + protected $config; |
|
45 | + /** @var EventDispatcherInterface */ |
|
46 | + private $dispatcher; |
|
47 | + /** @var ProgressBar */ |
|
48 | + private $progress; |
|
49 | + /** @var OutputInterface */ |
|
50 | + private $output; |
|
51 | + /** @var IAppManager */ |
|
52 | + private $appManager; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param \OC\Repair $repair |
|
56 | - * @param IConfig $config |
|
57 | - * @param EventDispatcherInterface $dispatcher |
|
58 | - * @param IAppManager $appManager |
|
59 | - */ |
|
60 | - public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
61 | - $this->repair = $repair; |
|
62 | - $this->config = $config; |
|
63 | - $this->dispatcher = $dispatcher; |
|
64 | - $this->appManager = $appManager; |
|
65 | - parent::__construct(); |
|
66 | - } |
|
54 | + /** |
|
55 | + * @param \OC\Repair $repair |
|
56 | + * @param IConfig $config |
|
57 | + * @param EventDispatcherInterface $dispatcher |
|
58 | + * @param IAppManager $appManager |
|
59 | + */ |
|
60 | + public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
61 | + $this->repair = $repair; |
|
62 | + $this->config = $config; |
|
63 | + $this->dispatcher = $dispatcher; |
|
64 | + $this->appManager = $appManager; |
|
65 | + parent::__construct(); |
|
66 | + } |
|
67 | 67 | |
68 | - protected function configure() { |
|
69 | - $this |
|
70 | - ->setName('maintenance:repair') |
|
71 | - ->setDescription('repair this installation') |
|
72 | - ->addOption( |
|
73 | - 'include-expensive', |
|
74 | - null, |
|
75 | - InputOption::VALUE_NONE, |
|
76 | - 'Use this option when you want to include resource and load expensive tasks'); |
|
77 | - } |
|
68 | + protected function configure() { |
|
69 | + $this |
|
70 | + ->setName('maintenance:repair') |
|
71 | + ->setDescription('repair this installation') |
|
72 | + ->addOption( |
|
73 | + 'include-expensive', |
|
74 | + null, |
|
75 | + InputOption::VALUE_NONE, |
|
76 | + 'Use this option when you want to include resource and load expensive tasks'); |
|
77 | + } |
|
78 | 78 | |
79 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
80 | - $repairSteps = $this->repair::getRepairSteps(); |
|
79 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
80 | + $repairSteps = $this->repair::getRepairSteps(); |
|
81 | 81 | |
82 | - if ($input->getOption('include-expensive')) { |
|
83 | - $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps()); |
|
84 | - } |
|
82 | + if ($input->getOption('include-expensive')) { |
|
83 | + $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps()); |
|
84 | + } |
|
85 | 85 | |
86 | - foreach ($repairSteps as $step) { |
|
87 | - $this->repair->addStep($step); |
|
88 | - } |
|
86 | + foreach ($repairSteps as $step) { |
|
87 | + $this->repair->addStep($step); |
|
88 | + } |
|
89 | 89 | |
90 | - $apps = $this->appManager->getInstalledApps(); |
|
91 | - foreach ($apps as $app) { |
|
92 | - if (!$this->appManager->isEnabledForUser($app)) { |
|
93 | - continue; |
|
94 | - } |
|
95 | - $info = \OC_App::getAppInfo($app); |
|
96 | - if (!is_array($info)) { |
|
97 | - continue; |
|
98 | - } |
|
99 | - $steps = $info['repair-steps']['post-migration']; |
|
100 | - foreach ($steps as $step) { |
|
101 | - try { |
|
102 | - $this->repair->addStep($step); |
|
103 | - } catch (Exception $ex) { |
|
104 | - $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
90 | + $apps = $this->appManager->getInstalledApps(); |
|
91 | + foreach ($apps as $app) { |
|
92 | + if (!$this->appManager->isEnabledForUser($app)) { |
|
93 | + continue; |
|
94 | + } |
|
95 | + $info = \OC_App::getAppInfo($app); |
|
96 | + if (!is_array($info)) { |
|
97 | + continue; |
|
98 | + } |
|
99 | + $steps = $info['repair-steps']['post-migration']; |
|
100 | + foreach ($steps as $step) { |
|
101 | + try { |
|
102 | + $this->repair->addStep($step); |
|
103 | + } catch (Exception $ex) { |
|
104 | + $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
110 | - $this->config->setSystemValue('maintenance', true); |
|
109 | + $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
110 | + $this->config->setSystemValue('maintenance', true); |
|
111 | 111 | |
112 | - $this->progress = new ProgressBar($output); |
|
113 | - $this->output = $output; |
|
114 | - $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
115 | - $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
116 | - $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
117 | - $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
118 | - $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
119 | - $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
120 | - $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
112 | + $this->progress = new ProgressBar($output); |
|
113 | + $this->output = $output; |
|
114 | + $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
115 | + $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
116 | + $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
117 | + $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
118 | + $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
119 | + $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
120 | + $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
121 | 121 | |
122 | - $this->repair->run(); |
|
122 | + $this->repair->run(); |
|
123 | 123 | |
124 | - $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
125 | - } |
|
124 | + $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
125 | + } |
|
126 | 126 | |
127 | - public function handleRepairFeedBack($event) { |
|
128 | - if (!$event instanceof GenericEvent) { |
|
129 | - return; |
|
130 | - } |
|
131 | - switch ($event->getSubject()) { |
|
132 | - case '\OC\Repair::startProgress': |
|
133 | - $this->progress->start($event->getArgument(0)); |
|
134 | - break; |
|
135 | - case '\OC\Repair::advance': |
|
136 | - $this->progress->advance($event->getArgument(0)); |
|
137 | - break; |
|
138 | - case '\OC\Repair::finishProgress': |
|
139 | - $this->progress->finish(); |
|
140 | - $this->output->writeln(''); |
|
141 | - break; |
|
142 | - case '\OC\Repair::step': |
|
143 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
144 | - break; |
|
145 | - case '\OC\Repair::info': |
|
146 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
147 | - break; |
|
148 | - case '\OC\Repair::warning': |
|
149 | - $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
150 | - break; |
|
151 | - case '\OC\Repair::error': |
|
152 | - $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
153 | - break; |
|
154 | - } |
|
155 | - } |
|
127 | + public function handleRepairFeedBack($event) { |
|
128 | + if (!$event instanceof GenericEvent) { |
|
129 | + return; |
|
130 | + } |
|
131 | + switch ($event->getSubject()) { |
|
132 | + case '\OC\Repair::startProgress': |
|
133 | + $this->progress->start($event->getArgument(0)); |
|
134 | + break; |
|
135 | + case '\OC\Repair::advance': |
|
136 | + $this->progress->advance($event->getArgument(0)); |
|
137 | + break; |
|
138 | + case '\OC\Repair::finishProgress': |
|
139 | + $this->progress->finish(); |
|
140 | + $this->output->writeln(''); |
|
141 | + break; |
|
142 | + case '\OC\Repair::step': |
|
143 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
144 | + break; |
|
145 | + case '\OC\Repair::info': |
|
146 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
147 | + break; |
|
148 | + case '\OC\Repair::warning': |
|
149 | + $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
150 | + break; |
|
151 | + case '\OC\Repair::error': |
|
152 | + $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
153 | + break; |
|
154 | + } |
|
155 | + } |
|
156 | 156 | } |
@@ -48,251 +48,251 @@ |
||
48 | 48 | |
49 | 49 | class Upgrade extends Command { |
50 | 50 | |
51 | - const ERROR_SUCCESS = 0; |
|
52 | - const ERROR_NOT_INSTALLED = 1; |
|
53 | - const ERROR_MAINTENANCE_MODE = 2; |
|
54 | - const ERROR_UP_TO_DATE = 0; |
|
55 | - const ERROR_INVALID_ARGUMENTS = 4; |
|
56 | - const ERROR_FAILURE = 5; |
|
51 | + const ERROR_SUCCESS = 0; |
|
52 | + const ERROR_NOT_INSTALLED = 1; |
|
53 | + const ERROR_MAINTENANCE_MODE = 2; |
|
54 | + const ERROR_UP_TO_DATE = 0; |
|
55 | + const ERROR_INVALID_ARGUMENTS = 4; |
|
56 | + const ERROR_FAILURE = 5; |
|
57 | 57 | |
58 | - /** @var IConfig */ |
|
59 | - private $config; |
|
58 | + /** @var IConfig */ |
|
59 | + private $config; |
|
60 | 60 | |
61 | - /** @var ILogger */ |
|
62 | - private $logger; |
|
61 | + /** @var ILogger */ |
|
62 | + private $logger; |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param IConfig $config |
|
66 | - * @param ILogger $logger |
|
67 | - * @param Installer $installer |
|
68 | - */ |
|
69 | - public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
70 | - parent::__construct(); |
|
71 | - $this->config = $config; |
|
72 | - $this->logger = $logger; |
|
73 | - $this->installer = $installer; |
|
74 | - } |
|
64 | + /** |
|
65 | + * @param IConfig $config |
|
66 | + * @param ILogger $logger |
|
67 | + * @param Installer $installer |
|
68 | + */ |
|
69 | + public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
70 | + parent::__construct(); |
|
71 | + $this->config = $config; |
|
72 | + $this->logger = $logger; |
|
73 | + $this->installer = $installer; |
|
74 | + } |
|
75 | 75 | |
76 | - protected function configure() { |
|
77 | - $this |
|
78 | - ->setName('upgrade') |
|
79 | - ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
80 | - } |
|
76 | + protected function configure() { |
|
77 | + $this |
|
78 | + ->setName('upgrade') |
|
79 | + ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Execute the upgrade command |
|
84 | - * |
|
85 | - * @param InputInterface $input input interface |
|
86 | - * @param OutputInterface $output output interface |
|
87 | - */ |
|
88 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
82 | + /** |
|
83 | + * Execute the upgrade command |
|
84 | + * |
|
85 | + * @param InputInterface $input input interface |
|
86 | + * @param OutputInterface $output output interface |
|
87 | + */ |
|
88 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
89 | 89 | |
90 | - if(Util::needUpgrade()) { |
|
91 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
92 | - // Prepend each line with a little timestamp |
|
93 | - $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
94 | - $output->setFormatter($timestampFormatter); |
|
95 | - } |
|
90 | + if(Util::needUpgrade()) { |
|
91 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
92 | + // Prepend each line with a little timestamp |
|
93 | + $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
94 | + $output->setFormatter($timestampFormatter); |
|
95 | + } |
|
96 | 96 | |
97 | - $self = $this; |
|
98 | - $updater = new Updater( |
|
99 | - $this->config, |
|
100 | - \OC::$server->getIntegrityCodeChecker(), |
|
101 | - $this->logger, |
|
102 | - $this->installer |
|
103 | - ); |
|
97 | + $self = $this; |
|
98 | + $updater = new Updater( |
|
99 | + $this->config, |
|
100 | + \OC::$server->getIntegrityCodeChecker(), |
|
101 | + $this->logger, |
|
102 | + $this->installer |
|
103 | + ); |
|
104 | 104 | |
105 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
106 | - $progress = new ProgressBar($output); |
|
107 | - $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
108 | - $listener = function($event) use ($progress, $output) { |
|
109 | - if ($event instanceof GenericEvent) { |
|
110 | - $message = $event->getSubject(); |
|
111 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
112 | - $output->writeln(' Checking table ' . $message); |
|
113 | - } else { |
|
114 | - if (strlen($message) > 60) { |
|
115 | - $message = substr($message, 0, 57) . '...'; |
|
116 | - } |
|
117 | - $progress->setMessage($message); |
|
118 | - if ($event[0] === 1) { |
|
119 | - $output->writeln(''); |
|
120 | - $progress->start($event[1]); |
|
121 | - } |
|
122 | - $progress->setProgress($event[0]); |
|
123 | - if ($event[0] === $event[1]) { |
|
124 | - $progress->setMessage('Done'); |
|
125 | - $progress->finish(); |
|
126 | - $output->writeln(''); |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
130 | - }; |
|
131 | - $repairListener = function($event) use ($progress, $output) { |
|
132 | - if (!$event instanceof GenericEvent) { |
|
133 | - return; |
|
134 | - } |
|
135 | - switch ($event->getSubject()) { |
|
136 | - case '\OC\Repair::startProgress': |
|
137 | - $progress->setMessage('Starting ...'); |
|
138 | - $output->writeln($event->getArgument(1)); |
|
139 | - $output->writeln(''); |
|
140 | - $progress->start($event->getArgument(0)); |
|
141 | - break; |
|
142 | - case '\OC\Repair::advance': |
|
143 | - $desc = $event->getArgument(1); |
|
144 | - if (!empty($desc)) { |
|
145 | - $progress->setMessage($desc); |
|
146 | - } |
|
147 | - $progress->advance($event->getArgument(0)); |
|
105 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
106 | + $progress = new ProgressBar($output); |
|
107 | + $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
108 | + $listener = function($event) use ($progress, $output) { |
|
109 | + if ($event instanceof GenericEvent) { |
|
110 | + $message = $event->getSubject(); |
|
111 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
112 | + $output->writeln(' Checking table ' . $message); |
|
113 | + } else { |
|
114 | + if (strlen($message) > 60) { |
|
115 | + $message = substr($message, 0, 57) . '...'; |
|
116 | + } |
|
117 | + $progress->setMessage($message); |
|
118 | + if ($event[0] === 1) { |
|
119 | + $output->writeln(''); |
|
120 | + $progress->start($event[1]); |
|
121 | + } |
|
122 | + $progress->setProgress($event[0]); |
|
123 | + if ($event[0] === $event[1]) { |
|
124 | + $progress->setMessage('Done'); |
|
125 | + $progress->finish(); |
|
126 | + $output->writeln(''); |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | + }; |
|
131 | + $repairListener = function($event) use ($progress, $output) { |
|
132 | + if (!$event instanceof GenericEvent) { |
|
133 | + return; |
|
134 | + } |
|
135 | + switch ($event->getSubject()) { |
|
136 | + case '\OC\Repair::startProgress': |
|
137 | + $progress->setMessage('Starting ...'); |
|
138 | + $output->writeln($event->getArgument(1)); |
|
139 | + $output->writeln(''); |
|
140 | + $progress->start($event->getArgument(0)); |
|
141 | + break; |
|
142 | + case '\OC\Repair::advance': |
|
143 | + $desc = $event->getArgument(1); |
|
144 | + if (!empty($desc)) { |
|
145 | + $progress->setMessage($desc); |
|
146 | + } |
|
147 | + $progress->advance($event->getArgument(0)); |
|
148 | 148 | |
149 | - break; |
|
150 | - case '\OC\Repair::finishProgress': |
|
151 | - $progress->setMessage('Done'); |
|
152 | - $progress->finish(); |
|
153 | - $output->writeln(''); |
|
154 | - break; |
|
155 | - case '\OC\Repair::step': |
|
156 | - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
157 | - $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
158 | - } |
|
159 | - break; |
|
160 | - case '\OC\Repair::info': |
|
161 | - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
162 | - $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
163 | - } |
|
164 | - break; |
|
165 | - case '\OC\Repair::warning': |
|
166 | - $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
167 | - break; |
|
168 | - case '\OC\Repair::error': |
|
169 | - $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
170 | - break; |
|
171 | - } |
|
172 | - }; |
|
149 | + break; |
|
150 | + case '\OC\Repair::finishProgress': |
|
151 | + $progress->setMessage('Done'); |
|
152 | + $progress->finish(); |
|
153 | + $output->writeln(''); |
|
154 | + break; |
|
155 | + case '\OC\Repair::step': |
|
156 | + if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
157 | + $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
158 | + } |
|
159 | + break; |
|
160 | + case '\OC\Repair::info': |
|
161 | + if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
162 | + $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
163 | + } |
|
164 | + break; |
|
165 | + case '\OC\Repair::warning': |
|
166 | + $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
167 | + break; |
|
168 | + case '\OC\Repair::error': |
|
169 | + $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
170 | + break; |
|
171 | + } |
|
172 | + }; |
|
173 | 173 | |
174 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
175 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
176 | - $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
177 | - $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
178 | - $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
179 | - $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
180 | - $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
181 | - $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
182 | - $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
174 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
175 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
176 | + $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
177 | + $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
178 | + $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
179 | + $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
180 | + $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
181 | + $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
182 | + $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
183 | 183 | |
184 | 184 | |
185 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) { |
|
186 | - $output->writeln('<info>Turned on maintenance mode</info>'); |
|
187 | - }); |
|
188 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) { |
|
189 | - $output->writeln('<info>Turned off maintenance mode</info>'); |
|
190 | - }); |
|
191 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) { |
|
192 | - $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
193 | - }); |
|
194 | - $updater->listen('\OC\Updater', 'updateEnd', |
|
195 | - function ($success) use($output, $self) { |
|
196 | - if ($success) { |
|
197 | - $message = "<info>Update successful</info>"; |
|
198 | - } else { |
|
199 | - $message = "<error>Update failed</error>"; |
|
200 | - } |
|
201 | - $output->writeln($message); |
|
202 | - }); |
|
203 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) { |
|
204 | - $output->writeln('<info>Updating database schema</info>'); |
|
205 | - }); |
|
206 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { |
|
207 | - $output->writeln('<info>Updated database</info>'); |
|
208 | - }); |
|
209 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) { |
|
210 | - $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
211 | - }); |
|
212 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) { |
|
213 | - $output->writeln('<info>Checked database schema update</info>'); |
|
214 | - }); |
|
215 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) { |
|
216 | - $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
217 | - }); |
|
218 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) { |
|
219 | - $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
220 | - }); |
|
221 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) { |
|
222 | - $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
223 | - }); |
|
224 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) { |
|
225 | - $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
226 | - }); |
|
227 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
228 | - $output->writeln('<info>Checking updates of apps</info>'); |
|
229 | - }); |
|
230 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
231 | - $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
232 | - }); |
|
233 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
234 | - $output->writeln('<info>Checked database schema update for apps</info>'); |
|
235 | - }); |
|
236 | - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
237 | - $output->writeln("<info>Updating <$app> ...</info>"); |
|
238 | - }); |
|
239 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
240 | - $output->writeln("<info>Updated <$app> to $version</info>"); |
|
241 | - }); |
|
242 | - $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { |
|
243 | - $output->writeln("<error>$message</error>"); |
|
244 | - }); |
|
245 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
246 | - $output->writeln("<info>Set log level to debug</info>"); |
|
247 | - }); |
|
248 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
249 | - $output->writeln("<info>Reset log level</info>"); |
|
250 | - }); |
|
251 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) { |
|
252 | - $output->writeln("<info>Starting code integrity check...</info>"); |
|
253 | - }); |
|
254 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) { |
|
255 | - $output->writeln("<info>Finished code integrity check</info>"); |
|
256 | - }); |
|
185 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) { |
|
186 | + $output->writeln('<info>Turned on maintenance mode</info>'); |
|
187 | + }); |
|
188 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) { |
|
189 | + $output->writeln('<info>Turned off maintenance mode</info>'); |
|
190 | + }); |
|
191 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) { |
|
192 | + $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
193 | + }); |
|
194 | + $updater->listen('\OC\Updater', 'updateEnd', |
|
195 | + function ($success) use($output, $self) { |
|
196 | + if ($success) { |
|
197 | + $message = "<info>Update successful</info>"; |
|
198 | + } else { |
|
199 | + $message = "<error>Update failed</error>"; |
|
200 | + } |
|
201 | + $output->writeln($message); |
|
202 | + }); |
|
203 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) { |
|
204 | + $output->writeln('<info>Updating database schema</info>'); |
|
205 | + }); |
|
206 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { |
|
207 | + $output->writeln('<info>Updated database</info>'); |
|
208 | + }); |
|
209 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) { |
|
210 | + $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
211 | + }); |
|
212 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) { |
|
213 | + $output->writeln('<info>Checked database schema update</info>'); |
|
214 | + }); |
|
215 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) { |
|
216 | + $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
217 | + }); |
|
218 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) { |
|
219 | + $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
220 | + }); |
|
221 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) { |
|
222 | + $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
223 | + }); |
|
224 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) { |
|
225 | + $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
226 | + }); |
|
227 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
228 | + $output->writeln('<info>Checking updates of apps</info>'); |
|
229 | + }); |
|
230 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
231 | + $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
232 | + }); |
|
233 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
234 | + $output->writeln('<info>Checked database schema update for apps</info>'); |
|
235 | + }); |
|
236 | + $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
237 | + $output->writeln("<info>Updating <$app> ...</info>"); |
|
238 | + }); |
|
239 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
240 | + $output->writeln("<info>Updated <$app> to $version</info>"); |
|
241 | + }); |
|
242 | + $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { |
|
243 | + $output->writeln("<error>$message</error>"); |
|
244 | + }); |
|
245 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
246 | + $output->writeln("<info>Set log level to debug</info>"); |
|
247 | + }); |
|
248 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
249 | + $output->writeln("<info>Reset log level</info>"); |
|
250 | + }); |
|
251 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) { |
|
252 | + $output->writeln("<info>Starting code integrity check...</info>"); |
|
253 | + }); |
|
254 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) { |
|
255 | + $output->writeln("<info>Finished code integrity check</info>"); |
|
256 | + }); |
|
257 | 257 | |
258 | - $success = $updater->upgrade(); |
|
258 | + $success = $updater->upgrade(); |
|
259 | 259 | |
260 | - $this->postUpgradeCheck($input, $output); |
|
260 | + $this->postUpgradeCheck($input, $output); |
|
261 | 261 | |
262 | - if(!$success) { |
|
263 | - return self::ERROR_FAILURE; |
|
264 | - } |
|
262 | + if(!$success) { |
|
263 | + return self::ERROR_FAILURE; |
|
264 | + } |
|
265 | 265 | |
266 | - return self::ERROR_SUCCESS; |
|
267 | - } else if($this->config->getSystemValueBool('maintenance')) { |
|
268 | - //Possible scenario: Nextcloud core is updated but an app failed |
|
269 | - $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
270 | - $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
271 | - . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
272 | - . 'upgrade procedure, remove the "maintenance mode" from ' |
|
273 | - . 'config.php and call this script again.</comment>' |
|
274 | - , true); |
|
275 | - return self::ERROR_MAINTENANCE_MODE; |
|
276 | - } else { |
|
277 | - $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
278 | - return self::ERROR_UP_TO_DATE; |
|
279 | - } |
|
280 | - } |
|
266 | + return self::ERROR_SUCCESS; |
|
267 | + } else if($this->config->getSystemValueBool('maintenance')) { |
|
268 | + //Possible scenario: Nextcloud core is updated but an app failed |
|
269 | + $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
270 | + $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
271 | + . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
272 | + . 'upgrade procedure, remove the "maintenance mode" from ' |
|
273 | + . 'config.php and call this script again.</comment>' |
|
274 | + , true); |
|
275 | + return self::ERROR_MAINTENANCE_MODE; |
|
276 | + } else { |
|
277 | + $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
278 | + return self::ERROR_UP_TO_DATE; |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | - /** |
|
283 | - * Perform a post upgrade check (specific to the command line tool) |
|
284 | - * |
|
285 | - * @param InputInterface $input input interface |
|
286 | - * @param OutputInterface $output output interface |
|
287 | - */ |
|
288 | - protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
289 | - $trustedDomains = $this->config->getSystemValue('trusted_domains', array()); |
|
290 | - if (empty($trustedDomains)) { |
|
291 | - $output->write( |
|
292 | - '<warning>The setting "trusted_domains" could not be ' . |
|
293 | - 'set automatically by the upgrade script, ' . |
|
294 | - 'please set it manually</warning>' |
|
295 | - ); |
|
296 | - } |
|
297 | - } |
|
282 | + /** |
|
283 | + * Perform a post upgrade check (specific to the command line tool) |
|
284 | + * |
|
285 | + * @param InputInterface $input input interface |
|
286 | + * @param OutputInterface $output output interface |
|
287 | + */ |
|
288 | + protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
289 | + $trustedDomains = $this->config->getSystemValue('trusted_domains', array()); |
|
290 | + if (empty($trustedDomains)) { |
|
291 | + $output->write( |
|
292 | + '<warning>The setting "trusted_domains" could not be ' . |
|
293 | + 'set automatically by the upgrade script, ' . |
|
294 | + 'please set it manually</warning>' |
|
295 | + ); |
|
296 | + } |
|
297 | + } |
|
298 | 298 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function execute(InputInterface $input, OutputInterface $output) { |
89 | 89 | |
90 | - if(Util::needUpgrade()) { |
|
90 | + if (Util::needUpgrade()) { |
|
91 | 91 | if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
92 | 92 | // Prepend each line with a little timestamp |
93 | 93 | $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | if ($event instanceof GenericEvent) { |
110 | 110 | $message = $event->getSubject(); |
111 | 111 | if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
112 | - $output->writeln(' Checking table ' . $message); |
|
112 | + $output->writeln(' Checking table '.$message); |
|
113 | 113 | } else { |
114 | 114 | if (strlen($message) > 60) { |
115 | - $message = substr($message, 0, 57) . '...'; |
|
115 | + $message = substr($message, 0, 57).'...'; |
|
116 | 116 | } |
117 | 117 | $progress->setMessage($message); |
118 | 118 | if ($event[0] === 1) { |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | $output->writeln(''); |
154 | 154 | break; |
155 | 155 | case '\OC\Repair::step': |
156 | - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
157 | - $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
156 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
157 | + $output->writeln('<info>Repair step: '.$event->getArgument(0).'</info>'); |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | case '\OC\Repair::info': |
161 | - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
162 | - $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
161 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
162 | + $output->writeln('<info>Repair info: '.$event->getArgument(0).'</info>'); |
|
163 | 163 | } |
164 | 164 | break; |
165 | 165 | case '\OC\Repair::warning': |
166 | - $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
166 | + $output->writeln('<error>Repair warning: '.$event->getArgument(0).'</error>'); |
|
167 | 167 | break; |
168 | 168 | case '\OC\Repair::error': |
169 | - $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
169 | + $output->writeln('<error>Repair error: '.$event->getArgument(0).'</error>'); |
|
170 | 170 | break; |
171 | 171 | } |
172 | 172 | }; |
@@ -182,17 +182,17 @@ discard block |
||
182 | 182 | $dispatcher->addListener('\OC\Repair::error', $repairListener); |
183 | 183 | |
184 | 184 | |
185 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) { |
|
185 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function() use($output) { |
|
186 | 186 | $output->writeln('<info>Turned on maintenance mode</info>'); |
187 | 187 | }); |
188 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) { |
|
188 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function() use($output) { |
|
189 | 189 | $output->writeln('<info>Turned off maintenance mode</info>'); |
190 | 190 | }); |
191 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) { |
|
191 | + $updater->listen('\OC\Updater', 'maintenanceActive', function() use($output) { |
|
192 | 192 | $output->writeln('<info>Maintenance mode is kept active</info>'); |
193 | 193 | }); |
194 | 194 | $updater->listen('\OC\Updater', 'updateEnd', |
195 | - function ($success) use($output, $self) { |
|
195 | + function($success) use($output, $self) { |
|
196 | 196 | if ($success) { |
197 | 197 | $message = "<info>Update successful</info>"; |
198 | 198 | } else { |
@@ -200,58 +200,58 @@ discard block |
||
200 | 200 | } |
201 | 201 | $output->writeln($message); |
202 | 202 | }); |
203 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) { |
|
203 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use($output) { |
|
204 | 204 | $output->writeln('<info>Updating database schema</info>'); |
205 | 205 | }); |
206 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { |
|
206 | + $updater->listen('\OC\Updater', 'dbUpgrade', function() use($output) { |
|
207 | 207 | $output->writeln('<info>Updated database</info>'); |
208 | 208 | }); |
209 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) { |
|
209 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($output) { |
|
210 | 210 | $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
211 | 211 | }); |
212 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) { |
|
212 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use($output) { |
|
213 | 213 | $output->writeln('<info>Checked database schema update</info>'); |
214 | 214 | }); |
215 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) { |
|
216 | - $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
215 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use($output) { |
|
216 | + $output->writeln('<comment>Disabled incompatible app: '.$app.'</comment>'); |
|
217 | 217 | }); |
218 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) { |
|
219 | - $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
218 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use($output) { |
|
219 | + $output->writeln('<info>Checking for update of app '.$app.' in appstore</info>'); |
|
220 | 220 | }); |
221 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) { |
|
222 | - $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
221 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use($output) { |
|
222 | + $output->writeln('<info>Update app '.$app.' from appstore</info>'); |
|
223 | 223 | }); |
224 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) { |
|
225 | - $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
224 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use($output) { |
|
225 | + $output->writeln('<info>Checked for update of app "'.$app.'" in appstore </info>'); |
|
226 | 226 | }); |
227 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
227 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($output) { |
|
228 | 228 | $output->writeln('<info>Checking updates of apps</info>'); |
229 | 229 | }); |
230 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
230 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($output) { |
|
231 | 231 | $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
232 | 232 | }); |
233 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
233 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($output) { |
|
234 | 234 | $output->writeln('<info>Checked database schema update for apps</info>'); |
235 | 235 | }); |
236 | - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
236 | + $updater->listen('\OC\Updater', 'appUpgradeStarted', function($app, $version) use ($output) { |
|
237 | 237 | $output->writeln("<info>Updating <$app> ...</info>"); |
238 | 238 | }); |
239 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
239 | + $updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($output) { |
|
240 | 240 | $output->writeln("<info>Updated <$app> to $version</info>"); |
241 | 241 | }); |
242 | - $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { |
|
242 | + $updater->listen('\OC\Updater', 'failure', function($message) use($output, $self) { |
|
243 | 243 | $output->writeln("<error>$message</error>"); |
244 | 244 | }); |
245 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
245 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use($output) { |
|
246 | 246 | $output->writeln("<info>Set log level to debug</info>"); |
247 | 247 | }); |
248 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) { |
|
248 | + $updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($output) { |
|
249 | 249 | $output->writeln("<info>Reset log level</info>"); |
250 | 250 | }); |
251 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) { |
|
251 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($output) { |
|
252 | 252 | $output->writeln("<info>Starting code integrity check...</info>"); |
253 | 253 | }); |
254 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) { |
|
254 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($output) { |
|
255 | 255 | $output->writeln("<info>Finished code integrity check</info>"); |
256 | 256 | }); |
257 | 257 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | |
260 | 260 | $this->postUpgradeCheck($input, $output); |
261 | 261 | |
262 | - if(!$success) { |
|
262 | + if (!$success) { |
|
263 | 263 | return self::ERROR_FAILURE; |
264 | 264 | } |
265 | 265 | |
266 | 266 | return self::ERROR_SUCCESS; |
267 | - } else if($this->config->getSystemValueBool('maintenance')) { |
|
267 | + } else if ($this->config->getSystemValueBool('maintenance')) { |
|
268 | 268 | //Possible scenario: Nextcloud core is updated but an app failed |
269 | 269 | $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
270 | 270 | $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | $trustedDomains = $this->config->getSystemValue('trusted_domains', array()); |
290 | 290 | if (empty($trustedDomains)) { |
291 | 291 | $output->write( |
292 | - '<warning>The setting "trusted_domains" could not be ' . |
|
293 | - 'set automatically by the upgrade script, ' . |
|
292 | + '<warning>The setting "trusted_domains" could not be '. |
|
293 | + 'set automatically by the upgrade script, '. |
|
294 | 294 | 'please set it manually</warning>' |
295 | 295 | ); |
296 | 296 | } |