aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-04-11 10:19:39 +0200
committerGitHub <noreply@github.com>2019-04-11 10:19:39 +0200
commitef06c3f1d27a2ee3f754f2f6db578c0cc3822c25 (patch)
treeeaec268e248b3ea688af73e7476487d1e7a3905a
parentaac22ba40fa9bed24f6e78386de4ae846660d340 (diff)
parent7e7146db7fdefa7039ad5dd9653500589a1d0c51 (diff)
downloadnextcloud-server-ef06c3f1d27a2ee3f754f2f6db578c0cc3822c25.tar.gz
nextcloud-server-ef06c3f1d27a2ee3f754f2f6db578c0cc3822c25.zip
Merge pull request #14965 from nextcloud/enh/install_file
Prevent a reinstall
-rw-r--r--config/CAN_INSTALL0
-rw-r--r--core/Controller/SetupController.php16
-rw-r--r--core/templates/installation_forbidden.php6
-rw-r--r--core/templates/installation_incomplete.php6
-rw-r--r--lib/private/Updater.php7
5 files changed, 35 insertions, 0 deletions
diff --git a/config/CAN_INSTALL b/config/CAN_INSTALL
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/config/CAN_INSTALL
diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php
index b9d561cb4c9..3dd02fc31dc 100644
--- a/core/Controller/SetupController.php
+++ b/core/Controller/SetupController.php
@@ -62,6 +62,11 @@ class SetupController {
$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);
@@ -79,6 +84,10 @@ class SetupController {
}
}
+ private function displaySetupForbidden() {
+ \OC_Template::printGuestPage('', 'installation_forbidden');
+ }
+
public function display($post) {
$defaults = array(
'adminlogin' => '',
@@ -101,6 +110,13 @@ class SetupController {
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();
}
diff --git a/core/templates/installation_forbidden.php b/core/templates/installation_forbidden.php
new file mode 100644
index 00000000000..743d14b1330
--- /dev/null
+++ b/core/templates/installation_forbidden.php
@@ -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>
diff --git a/core/templates/installation_incomplete.php b/core/templates/installation_incomplete.php
new file mode 100644
index 00000000000..867f637d701
--- /dev/null
+++ b/core/templates/installation_incomplete.php
@@ -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>
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 313cfc82ffa..56bea90ddd7 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -111,6 +111,13 @@ class Updater extends BasicEmitter {
$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());