diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index c445f2c2f46b7..d53cd867b0663 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -107,6 +107,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->printErrors($output, $errors); return 1; } + if ($setupHelper->shouldRemoveCanInstallFile()) { + $output->writeln('Could not remove CAN_INSTALL from the config folder. Please remove this file manually.'); + } $output->writeln("Nextcloud was successfully installed"); return 0; } diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php index ab8b1973bf2b8..cdab39edf8438 100644 --- a/core/Controller/SetupController.php +++ b/core/Controller/SetupController.php @@ -59,7 +59,7 @@ public function run(array $post): void { $post['dbpass'] = $post['dbpassword']; } - if (!is_file(\OC::$configDir.'/CAN_INSTALL')) { + if (!$this->setupHelper->canInstallFileExists()) { $this->displaySetupForbidden(); return; } @@ -107,10 +107,8 @@ private function finishSetup() { } \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); - if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { - if (!unlink(\OC::$configDir.'/CAN_INSTALL')) { - \OC_Template::printGuestPage('', 'installation_incomplete'); - } + if ($this->setupHelper->shouldRemoveCanInstallFile()) { + \OC_Template::printGuestPage('', 'installation_incomplete'); } header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended')); diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 7b08fb2f66fd2..e84a5e4987aae 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -419,6 +419,9 @@ public function install($options) { //and we are done $config->setSystemValue('installed', true); + if (self::shouldRemoveCanInstallFile()) { + unlink(\OC::$configDir.'/CAN_INSTALL'); + } $bootstrapCoordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class); $bootstrapCoordinator->runInitialRegistration(); @@ -596,4 +599,18 @@ private function getVendorData(): array { 'channel' => (string)$OC_Channel, ]; } + + /** + * @return bool + */ + public function shouldRemoveCanInstallFile() { + return \OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL'); + } + + /** + * @return bool + */ + public function canInstallFileExists() { + return is_file(\OC::$configDir.'/CAN_INSTALL'); + } }