Exemple #1
0
 /**
  * Run user update
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 protected function userUpdate(InputInterface $input, OutputInterface $output)
 {
     // GIT pulls and other stuff
     // ##################
     // SSH Git repo update
     // ##################
     $reposDirectory = $this->getApplication()->getConfigValue('config', 'ssh_conf_path', '/opt/conf/ssh');
     if (is_dir($reposDirectory) && is_dir($reposDirectory . '/.git')) {
         // SSH Git repo exists, update now
         $originalCwd = getcwd();
         \CliTools\Utility\PhpUtility::chdir($reposDirectory);
         try {
             // Update git repository
             $this->outputBlock($output, 'Running git update of ' . $reposDirectory);
             $command = new CommandBuilder('git', 'pull');
             $command->executeInteractive();
             $command = new \CliTools\Shell\CommandBuilder\SelfCommandBuilder();
             $command->addArgument('user:rebuildsshconfig');
             $command->executeInteractive();
         } catch (\RuntimeException $e) {
             $msg = 'Running git update of ' . $reposDirectory . '... FAILED';
             $output->writeln('<error>' . $msg . '</error>');
         }
         \CliTools\Utility\PhpUtility::chdir($originalCwd);
     }
 }
Exemple #2
0
 /**
  * Stop last docker containers from previous run
  *
  * @param string $path Path
  */
 protected function stopContainersFromPrevRun($path)
 {
     $currentPath = getcwd();
     try {
         $this->output->writeln('<p>Trying to stop last running docker container in "' . $path . '"</p>');
         // Jump into last docker dir
         \CliTools\Utility\PhpUtility::chdir($path);
         // Stop docker containers
         $command = new CommandBuilder(null, 'stop');
         $this->executeDockerCompose($command);
         // Jump back
         \CliTools\Utility\PhpUtility::chdir($currentPath);
     } catch (\Exception $e) {
     }
 }
Exemple #3
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $paramList = $this->getFullParameterList();
     $path = UnixUtility::findFileInDirectortyTree('Makefile');
     if (!empty($path)) {
         $path = dirname($path);
         $this->output->writeln('<comment>Found Makefile directory: ' . $path . '</comment>');
         // Switch to directory of docker-compose.yml
         PhpUtility::chdir($path);
         $command = new CommandBuilder('make');
         if (!empty($paramList)) {
             $command->setArgumentList($paramList);
         }
         $command->executeInteractive();
     } else {
         $this->output->writeln('<error>No Makefile found in tree</error>');
         return 1;
     }
     return 0;
 }
Exemple #4
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $composerCmd = $this->getApplication()->getConfigValue('bin', 'composer');
     $paramList = $this->getFullParameterList();
     $composerJsonPath = UnixUtility::findFileInDirectortyTree('composer.json');
     if (!empty($composerJsonPath)) {
         $path = dirname($composerJsonPath);
         $this->output->writeln('<comment>Found composer.json directory: ' . $path . '</comment>');
         // Switch to directory of docker-compose.yml
         PhpUtility::chdir($path);
         $command = new CommandBuilder();
         $command->parse($composerCmd);
         if (!empty($paramList)) {
             $command->setArgumentList($paramList);
         }
         $command->executeInteractive();
     } else {
         $this->output->writeln('<error>No composer.json found in tree</error>');
         return 1;
     }
     return 0;
 }
Exemple #5
0
 /**
  * Execute docker compose run
  *
  * @param  string          $containerName Container name
  * @param  CommandBuilderInterface  $command       Command
  *
  * @return int|null|void
  */
 protected function executeDockerComposeRun($containerName, CommandBuilderInterface $command)
 {
     // Search updir for docker-compose.yml
     $path = $this->getDockerPath();
     if (!empty($path)) {
         // Switch to directory of docker-compose.yml
         PhpUtility::chdir($path);
         $this->output->writeln('<info>Executing "' . $command->getCommand() . '" in docker container "' . $containerName . '" ...</info>');
         $dockerCommand = new CommandBuilder('docker-compose', 'run --rm %s', array($containerName));
         $dockerCommand->append($command, false);
         $dockerCommand->executeInteractive();
     } else {
         $this->output->writeln('<p-error>No docker-compose.yml found in tree</p-error>');
         return 1;
     }
     return 0;
 }
Exemple #6
0
 /**
  * Build and startup docker instance
  *
  * @param string $path Path
  */
 protected function startDockerInstance($path)
 {
     $this->setTerminalTitle('Start docker');
     $this->output->writeln('<comment>Building docker containers "' . $path . '"</comment>');
     PhpUtility::chdir($path);
     $command = new SelfCommandBuilder();
     $command->addArgument('docker:up');
     $command->executeInteractive();
 }