diff --git a/index.php b/index.php index a56219cf..93c7d684 100644 --- a/index.php +++ b/index.php @@ -183,7 +183,7 @@ public function __construct($baseDir) { return; } - $dataDir = $this->getDataDirectoryLocation(); + $dataDir = $this->getUpdateDirectoryLocation(); if (empty($dataDir) || !is_string($dataDir)) { throw new \Exception('Could not read data directory from config.php.'); } @@ -201,10 +201,7 @@ public function __construct($baseDir) { $buildTime = $OC_Build; } - if ($version === null) { - return; - } - if ($buildTime === null) { + if ($version === null || $buildTime === null) { return; } @@ -305,8 +302,8 @@ public function getConfigOption($key) { * * @return string */ - private function getDataDirectoryLocation() { - return $this->configValues['datadirectory']; + private function getUpdateDirectoryLocation() { + return $this->configValues['updatedirectory'] ?? $this->configValues['datadirectory']; } /** @@ -487,7 +484,7 @@ public function createBackup() { ]; // Create new folder for the backup - $backupFolderLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid').'/backups/nextcloud-'.$this->getConfigOption('version') . '-' . time() . '/'; + $backupFolderLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid').'/backups/nextcloud-'.$this->getConfigOption('version') . '-' . time() . '/'; $this->silentLog('[info] backup folder location: ' . $backupFolderLocation); $state = mkdir($backupFolderLocation, 0750, true); @@ -638,7 +635,8 @@ public function downloadUpdate() { $this->silentLog('[info] downloadUpdate()'); $response = $this->getUpdateServerResponse(); - $storageLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/'; + + $storageLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/'; if (file_exists($storageLocation)) { $this->silentLog('[info] storage location exists'); $this->recursiveDelete($storageLocation); @@ -706,7 +704,7 @@ public function downloadUpdate() { * @throws \Exception */ private function getDownloadedFilePath() { - $storageLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/'; + $storageLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/'; $this->silentLog('[info] storage location: ' . $storageLocation); $filesInStorageLocation = scandir($storageLocation); @@ -926,7 +924,7 @@ public function deleteOldFiles() { throw new \Exception('core/shipped.json is not available'); } - $newShippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json'; + $newShippedAppsFile = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json'; if (!file_exists($newShippedAppsFile)) { throw new \Exception('core/shipped.json is not available in the new release'); } @@ -1084,7 +1082,7 @@ public function moveNewVersionInPlace() { 'ocs/v1.php', 'ocs/v2.php', ]; - $storageLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/'; + $storageLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/'; $this->silentLog('[info] storage location: ' . $storageLocation); $this->moveWithExclusions($storageLocation, $excludedElements); @@ -1100,14 +1098,15 @@ public function moveNewVersionInPlace() { public function finalize() { $this->silentLog('[info] finalize()'); - $storageLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/'; + $storageLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/'; $this->silentLog('[info] storage location: ' . $storageLocation); $this->moveWithExclusions($storageLocation, []); $state = rmdir($storageLocation); if ($state === false) { throw new \Exception('Could not rmdir $storagelocation'); } - $state = unlink($this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/.step'); + + $state = unlink($this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/.step'); if ($state === false) { throw new \Exception('Could not rmdir .step'); } @@ -1126,7 +1125,7 @@ public function finalize() { * @throws \Exception */ private function writeStep($state, $step) { - $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); + $updaterDir = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); if (!file_exists($updaterDir . '/.step')) { if (!file_exists($updaterDir)) { $result = mkdir($updaterDir); @@ -1171,7 +1170,7 @@ public function endStep($step) { public function currentStep() { $this->silentLog('[info] currentStep()'); - $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); + $updaterDir = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); $jsonData = []; if (file_exists($updaterDir. '/.step')) { $state = file_get_contents($updaterDir . '/.step'); @@ -1196,7 +1195,7 @@ public function currentStep() { public function rollbackChanges($step) { $this->silentLog('[info] rollbackChanges("' . $step . '")'); - $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); + $updaterDir = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); if (file_exists($updaterDir . '/.step')) { $this->silentLog('[info] unlink .step'); $state = unlink($updaterDir . '/.step'); @@ -1240,7 +1239,7 @@ public function logException(\Exception $e) { * @throws LogException */ public function log($message) { - $updaterLogPath = $this->getDataDirectoryLocation() . '/updater.log'; + $updaterLogPath = $this->getUpdateDirectoryLocation() . '/updater.log'; $fh = fopen($updaterLogPath, 'a'); if ($fh === false) { @@ -1827,13 +1826,13 @@ public function logVersion() { - +
To login you need to provide the unhashed value of "updater.secret" in your config file.
If you don't know that value, you can access this updater directly via the Nextcloud admin screen or generate your own secret:
-php -r '$password = trim(shell_exec("openssl rand -base64 48"));if(strlen($password) === 64) {$hash = password_hash($password, PASSWORD_DEFAULT) . "\n"; echo "Insert as \"updater.secret\": ".$hash; echo "The plaintext value is: ".$password."\n";}else{echo "Could not execute OpenSSL.\n";};'
+ php -r '$password = trim(shell_exec("openssl rand -base64 48")); if (strlen($password) === 64) {$hash = password_hash($password, PASSWORD_DEFAULT) . "\n"; echo "Insert as \"updater.secret\": ".$hash; echo "The plaintext value is: ".$password."\n";} else {echo "Could not execute OpenSSL.\n";};'