Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the CAN_INSTALL file when occ maintenance:install is complete #27492

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/Command/Maintenance/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->printErrors($output, $errors);
return 1;
}
if ($setupHelper->shouldRemoveCanInstallFile()) {
juliusknorr marked this conversation as resolved.
Show resolved Hide resolved
$output->writeln('<warn>Could not remove CAN_INSTALL from the config folder. Please remove this file manually.</warn>');
}
$output->writeln("Nextcloud was successfully installed");
return 0;
}
Expand Down
8 changes: 3 additions & 5 deletions core/Controller/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()) {
juliusknorr marked this conversation as resolved.
Show resolved Hide resolved
\OC_Template::printGuestPage('', 'installation_incomplete');
}

header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
Expand Down
17 changes: 17 additions & 0 deletions lib/private/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
}
}