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

Prevent a reinstall #14965

Merged
merged 1 commit into from
Apr 11, 2019
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
Empty file added config/CAN_INSTALL
Empty file.
16 changes: 16 additions & 0 deletions core/Controller/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public function run($post) {
$post['dbpass'] = $post['dbpassword'];
}

if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
$this->displaySetupForbidden();
return;
}

if(isset($post['install']) AND $post['install']=='true') {
// We have to launch the installation process :
$e = $this->setupHelper->install($post);
Expand All @@ -79,6 +84,10 @@ public function run($post) {
}
}

private function displaySetupForbidden() {
\OC_Template::printGuestPage('', 'installation_forbidden');
}

public function display($post) {
$defaults = array(
'adminlogin' => '',
Expand All @@ -101,6 +110,13 @@ public function finishSetup() {
unlink($this->autoConfigFile);
}
\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');
}
}

\OC_Util::redirectToDefaultPage();
}

Expand Down
6 changes: 6 additions & 0 deletions core/templates/installation_forbidden.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="error">
<h2><?php p($l->t('Error')) ?></h2>
<p>
<?php p($l->t('It looks like you are trying to reinstall your Nextcloud. However the file CAN_INSTALL is missing from your config directory. Please create the file CAN_INSTALL in your config folder to continue.')) ?>
</p>
</div>
6 changes: 6 additions & 0 deletions core/templates/installation_incomplete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="error">
<h2><?php p($l->t('Error')) ?></h2>
<p>
<?php p($l->t('Could not remove CAN_INSTALL from the config folder. Please remove this file manually.')) ?>
</p>
</div>
7 changes: 7 additions & 0 deletions lib/private/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ public function upgrade() {
$this->emit('\OC\Updater', 'maintenanceEnabled');
}

// Clear CAN_INSTALL file if not on git
if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
$this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
}
}

$installedVersion = $this->config->getSystemValue('version', '0.0.0');
$currentVersion = implode('.', \OCP\Util::getVersion());

Expand Down