Skip to content

Commit d860057

Browse files
authored
Merge pull request #15112 from nextcloud/backport/14965/stable15
[stable15] Prevent a reinstall
2 parents 5ff7e3d + 441e9fe commit d860057

5 files changed

Lines changed: 35 additions & 0 deletions

File tree

config/CAN_INSTALL

Whitespace-only changes.

core/Controller/SetupController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function run($post) {
6262
$post['dbpass'] = $post['dbpassword'];
6363
}
6464

65+
if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
66+
$this->displaySetupForbidden();
67+
return;
68+
}
69+
6570
if(isset($post['install']) AND $post['install']=='true') {
6671
// We have to launch the installation process :
6772
$e = $this->setupHelper->install($post);
@@ -79,6 +84,10 @@ public function run($post) {
7984
}
8085
}
8186

87+
private function displaySetupForbidden() {
88+
\OC_Template::printGuestPage('', 'installation_forbidden');
89+
}
90+
8291
public function display($post) {
8392
$defaults = array(
8493
'adminlogin' => '',
@@ -103,6 +112,13 @@ public function finishSetup() {
103112
unlink($this->autoConfigFile);
104113
}
105114
\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
115+
116+
if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
117+
if (!unlink(\OC::$configDir.'/CAN_INSTALL')) {
118+
\OC_Template::printGuestPage('', 'installation_incomplete');
119+
}
120+
}
121+
106122
\OC_Util::redirectToDefaultPage();
107123
}
108124

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="error">
2+
<h2><?php p($l->t('Error')) ?></h2>
3+
<p>
4+
<?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.')) ?>
5+
</p>
6+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="error">
2+
<h2><?php p($l->t('Error')) ?></h2>
3+
<p>
4+
<?php p($l->t('Could not remove CAN_INSTALL from the config folder. Please remove this file manually.')) ?>
5+
</p>
6+
</div>

lib/private/Updater.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ public function upgrade() {
111111
$this->emit('\OC\Updater', 'maintenanceEnabled');
112112
}
113113

114+
// Clear CAN_INSTALL file if not on git
115+
if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
116+
if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
117+
$this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
118+
}
119+
}
120+
114121
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
115122
$currentVersion = implode('.', \OCP\Util::getVersion());
116123

0 commit comments

Comments
 (0)