private function importDumpFile(Project $project, $xml_svn, $extraction_path) { $attrs = $xml_svn->attributes(); if (!isset($attrs['dump-file'])) { return true; } $rootpath_arg = escapeshellarg($project->getSVNRootPath()); $dumpfile_arg = escapeshellarg("{$extraction_path}/{$attrs["dump-file"]}"); $commandline = "svnadmin load {$rootpath_arg} <{$dumpfile_arg} 2>&1"; $this->logger->info($commandline); try { $cmd = new System_Command(); $command_output = $cmd->exec($commandline); foreach ($command_output as $line) { $this->logger->debug("svnadmin: {$line}"); } $this->logger->debug("svnadmin returned with status 0"); } catch (System_Command_CommandException $e) { foreach ($e->output as $line) { $this->logger->error("svnadmin: {$line}"); } $this->logger->error("svnadmin returned with status {$e->return_value}"); throw new SVNXMLImporterException("failed to svnadmin load {$dumpfile_arg} in {$rootpath_arg}:" . " exited with status {$e->return_value}"); } }
/** * @return int */ public function getDiskUsage(PFUser $user) { $size = 0; foreach (glob($this->getPath($user, '*')) as $file) { $size += (int) implode('', $this->system->exec('stat -c %s ' . escapeshellarg($file))); } return $size; }
public function createFromBundle(GitRepository $repository, GitRepositoryCreator $creator, $bundle_path) { $this->initRepository($repository, $creator); $bundle_path_arg = escapeshellarg($bundle_path); $repository_full_path_arg = escapeshellarg($repository->getFullPath()); $this->system_command->exec("sudo -u gitolite /usr/share/tuleap/plugins/git/bin/gl-clone-bundle.sh {$bundle_path_arg} {$repository_full_path_arg}"); $this->git_system_event_manager->queueRepositoryUpdate($repository); }
private function getGitoliteVersion() { $command = new System_Command(); $output = $command->exec("ssh gitolite@gl-adm info"); $match = array(); preg_match('/running gitolite.* (2|3)./', implode(' ', $output), $match); if (isset($match[1])) { return $match[1]; } return null; }
public function createFromBundle(GitRepository $repository, GitRepositoryCreator $creator, $bundle_path) { if (!$creator->isNameValid($repository->getName())) { throw new Exception($GLOBALS['Language']->getText('plugin_git', 'actions_input_format_error', array($creator->getAllowedCharsInNamePattern(), GitDao::REPO_NAME_MAX_LENGTH))); } $this->assertRepositoryNameNotAlreadyUsed($repository); $id = $this->dao->save($repository); $repository->setId($id); $bundle_path_arg = escapeshellarg($bundle_path); $repository_full_path_arg = escapeshellarg($repository->getFullPath()); $this->system_command->exec("sudo -u gitolite /usr/share/tuleap/plugins/git/bin/gl-clone-bundle.sh {$bundle_path_arg} {$repository_full_path_arg}"); $this->git_system_event_manager->queueRepositoryUpdate($repository); }
private function importRepository(Project $project, PFUser $creator, SimpleXMLElement $repository_xmlnode, $extraction_path) { $repository_info = $repository_xmlnode->attributes(); $this->logger->debug("Importing {$repository_info['name']} using {$repository_info['bundle-path']}"); $description = isset($repository_info['description']) ? (string) $repository_info['description'] : GitRepository::DEFAULT_DESCRIPTION; $repository = $this->repository_factory->buildRepository($project, $repository_info['name'], $creator, $this->gitolite_backend, $description); $absolute_bundle_path = $extraction_path . '/' . $repository_info['bundle-path']; $extraction_path_arg = escapeshellarg($extraction_path); $this->system_command->exec("chmod 755 {$extraction_path_arg}"); $this->repository_manager->createFromBundle($repository, $this->gitolite_backend, $absolute_bundle_path); $this->importPermissions($project, $repository_xmlnode->children(), $repository); $this->system_event_manager->queueProjectsConfigurationUpdate(array($project->getGroupId())); }
private function import_dumpfile(Project $project, $xml_svn, $extraction_path) { $attrs = $xml_svn->attributes(); if (!isset($attrs['dump-file'])) { return true; } $rootpath_arg = escapeshellarg($project->getSVNRootPath()); $dumpfile_arg = escapeshellarg("{$extraction_path}/{$attrs["dump-file"]}"); $commandline = "svnadmin load {$rootpath_arg} <{$dumpfile_arg} 2>&1"; $this->logger->info($commandline); try { $cmd = new System_Command(); $command_output = $cmd->exec($commandline); $return_status = 0; } catch (System_Command_CommandException $e) { $command_output = $e->output; $return_status = $e->return_value; } foreach ($command_output as $line) { $this->logger->debug($line); } $this->logger->debug("Exited with status {$return_status}"); return 0 === $return_status; }
/** * * Extract repository * * @param String $backup_path * @param String $restore_path * */ private function extractRepository($backup_path) { $this->logger->debug('[Gitolite][Restore] sudo gitolite restore'); $base = realpath(ForgeConfig::get('codendi_bin_prefix')); $system_command = new System_Command(); $command = "sudo -u gitolite {$base}/restore-tar-repository.php " . escapeshellarg($backup_path) . ' /'; try { $system_command->exec($command); } catch (System_Command_CommandException $exception) { $this->logger->error('[Gitolite][Restore] Unable to extract repository from backup: [' . $backup_path . '] error message : ' . $exception->getMessage()); return false; } $this->logger->info('[Gitolite][Restore] Repository extracted from backup: ' . $backup_path); return true; }
public function runUpdateScript(Project $project) { $system_execution = new System_Command(); $system_execution->exec($this->getCommandToExecute($project)); }
/** * @param Project $project * @throws System_Command_CommandException */ public function migrateProjectTo123(Project $project) { $system_execution = new System_Command(); $system_execution->exec($this->getCommandToExecute($project)); }
private function execute($cmd) { return $this->command->exec(self::FORGEUPGRADE_PATH . ' --config=' . escapeshellarg($this->filePath) . ' ' . escapeshellarg($cmd)); }