protected function execute(InputInterface $input, OutputInterface $output)
 {
     $args = [];
     if ($input->getOption('on')) {
         $args = ['--on' => ''];
     } elseif ($input->getOption('off')) {
         $args = ['--off' => ''];
     }
     $response = $this->occRunner->run('maintenance:mode', $args);
     $output->writeln($response);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $mode = '';
     if ($input->getOption('on')) {
         $mode = '--on';
     } elseif ($input->getOption('off')) {
         $mode = '--off';
     }
     if ($mode !== '') {
         $mode = ProcessUtils::escapeArgument($mode);
     }
     $response = $this->occRunner->run('maintenance:mode ' . $mode);
     $output->writeln($response);
 }
Example #3
0
 public function getAppPath($appId)
 {
     try {
         $response = $this->occRunner->run('app:getpath ' . ProcessUtils::escapeArgument($appId));
     } catch (\Exception $e) {
         return '';
     }
     return trim($response);
 }
Example #4
0
 public function getAppPath($appId)
 {
     try {
         $response = $this->occRunner->run('app:getpath', ['app-id' => $appId]);
     } catch (\Exception $e) {
         return '';
     }
     return trim($response);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $locator = $this->container['utils.locator'];
     $fsHelper = $this->container['utils.filesystemhelper'];
     $registry = $this->container['utils.registry'];
     $fetcher = $this->container['utils.fetcher'];
     $installedVersion = implode('.', $locator->getInstalledVersion());
     $registry->set('installedVersion', $installedVersion);
     $feed = $registry->get('feed');
     if ($feed) {
         $path = $fetcher->getBaseDownloadPath($feed);
         $fullExtractionPath = $locator->getExtractionBaseDir() . '/' . $feed->getVersion();
         if (file_exists($fullExtractionPath)) {
             $fsHelper->removeIfExists($fullExtractionPath);
         }
         try {
             $fsHelper->mkdir($fullExtractionPath, true);
         } catch (\Exception $e) {
             $output->writeln('Unable create directory ' . $fullExtractionPath);
             throw $e;
         }
         $output->writeln('Extracting source into ' . $fullExtractionPath);
         if (preg_match('|\\.tar\\.bz2$|', $path)) {
             $extractor = new BzipExtractor($path, $fullExtractionPath);
         } else {
             $extractor = new ZipExtractor($path, $fullExtractionPath);
         }
         try {
             $extractor->extract();
         } catch (\Exception $e) {
             $output->writeln('Extraction has been failed');
             $fsHelper->removeIfExists($locator->getExtractionBaseDir());
             throw $e;
         }
         $tmpDir = $locator->getExtractionBaseDir() . '/' . $installedVersion;
         $fsHelper->removeIfExists($tmpDir);
         $fsHelper->mkdir($tmpDir);
         $fsHelper->mkdir($tmpDir . '/config');
         $oldSourcesDir = $locator->getOwncloudRootPath();
         $newSourcesDir = $fullExtractionPath . '/owncloud';
         foreach ($locator->getRootDirContent() as $dir) {
             $this->getApplication()->getLogger()->debug('Moving ' . $dir);
             $fsHelper->tripleMove($oldSourcesDir, $newSourcesDir, $tmpDir, $dir);
         }
         try {
             $plain = $this->occRunner->run('upgrade');
             $output->writeln($plain);
         } catch (ProcessFailedException $e) {
             if ($e->getProcess()->getExitCode() != 3) {
                 throw $e;
             }
         }
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $locator = $this->container['utils.locator'];
     /** @var FilesystemHelper $fsHelper */
     $fsHelper = $this->container['utils.filesystemhelper'];
     $registry = $this->container['utils.registry'];
     $fetcher = $this->container['utils.fetcher'];
     /** @var Checkpoint $checkpoint */
     $checkpoint = $this->container['utils.checkpoint'];
     $installedVersion = implode('.', $locator->getInstalledVersion());
     $registry->set('installedVersion', $installedVersion);
     $feed = $registry->get('feed');
     if ($feed) {
         $path = $fetcher->getBaseDownloadPath($feed);
         $fullExtractionPath = $locator->getExtractionBaseDir() . '/' . $feed->getVersion();
         if (file_exists($fullExtractionPath)) {
             $fsHelper->removeIfExists($fullExtractionPath);
         }
         try {
             $fsHelper->mkdir($fullExtractionPath, true);
         } catch (\Exception $e) {
             $output->writeln('Unable create directory ' . $fullExtractionPath);
             throw $e;
         }
         $output->writeln('Extracting source into ' . $fullExtractionPath);
         $extractor = new ZipExtractor($path, $fullExtractionPath, $output);
         try {
             $extractor->extract();
         } catch (\Exception $e) {
             $output->writeln('Extraction has been failed');
             $fsHelper->removeIfExists($locator->getExtractionBaseDir());
             throw $e;
         }
         $tmpDir = $locator->getExtractionBaseDir() . '/' . $installedVersion;
         $fsHelper->removeIfExists($tmpDir);
         $fsHelper->mkdir($tmpDir);
         $oldSourcesDir = $locator->getOwncloudRootPath();
         $newSourcesDir = $fullExtractionPath . '/owncloud';
         foreach ($locator->getRootDirContent() as $dir) {
             $this->getApplication()->getLogger()->debug('Replacing ' . $dir);
             $fsHelper->tripleMove($oldSourcesDir, $newSourcesDir, $tmpDir, $dir);
         }
         $fsHelper->copyr($tmpDir . '/config/config.php', $oldSourcesDir . '/config/config.php');
         //Remove old apps
         $appDirectories = $fsHelper->scandirFiltered($oldSourcesDir . '/apps');
         foreach ($appDirectories as $appDirectory) {
             $fsHelper->rmdirr($oldSourcesDir . '/apps/' . $appDirectory);
         }
         //Put new shipped apps
         $newAppsDir = $fullExtractionPath . '/owncloud/apps';
         $newAppsList = $fsHelper->scandirFiltered($newAppsDir);
         foreach ($newAppsList as $appId) {
             $output->writeln('Copying the application ' . $appId);
             $fsHelper->copyr($newAppsDir . '/' . $appId, $locator->getOwnCloudRootPath() . '/apps/' . $appId, false);
         }
         try {
             $plain = $this->occRunner->run('upgrade');
             $output->writeln($plain);
         } catch (ProcessFailedException $e) {
             $lastCheckpointId = $checkpoint->getLastCheckpointId();
             if ($lastCheckpointId) {
                 $lastCheckpointPath = $checkpoint->getCheckpointPath($lastCheckpointId);
                 $fsHelper->copyr($lastCheckpointPath . '/apps', $oldSourcesDir . '/apps', false);
             }
             if ($e->getProcess()->getExitCode() != 3) {
                 throw $e;
             }
         }
     }
 }
 /**
  * Export OC config as JSON and parse it into the cache
  * @throws ProcessFailedException
  * @throws \UnexpectedValueException
  */
 private function load()
 {
     $this->cache = $this->occRunner->runJson('config:list', ['--private' => '']);
     $this->isLoaded = true;
 }