@@ -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->getSystemValue('maintenance', false); |
|
| 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->getSystemValue('maintenance', false); |
|
| 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 | } |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | protected function execute(InputInterface $input, OutputInterface $output) { |
| 126 | - if ( !$input->isInteractive() ) { |
|
| 126 | + if (!$input->isInteractive()) { |
|
| 127 | 127 | $output->writeln('Invalid TTY.'); |
| 128 | 128 | $output->writeln('If you are trying to execute the command in a Docker '); |
| 129 | 129 | $output->writeln("container, do not forget to execute 'docker exec' with"); |
@@ -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->getSystemValue('maintenance', false); |
|
| 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->getSystemValue('maintenance', false); |
|
| 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 | } |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | protected function execute(InputInterface $input, OutputInterface $output) { |
| 108 | - if ( !$input->isInteractive() ) { |
|
| 108 | + if (!$input->isInteractive()) { |
|
| 109 | 109 | $output->writeln('Invalid TTY.'); |
| 110 | 110 | $output->writeln('If you are trying to execute the command in a Docker '); |
| 111 | 111 | $output->writeln("container, do not forget to execute 'docker exec' with"); |