public function run() { if (!$this->isCurrentUserInDockerGroup()) { $this->userInteraction->writeTitle('Making docker work without sudo'); $this->processRunner->run('sudo usermod -a -G docker $USER'); } }
/** * {@inheritdoc} */ public function run() { if (!$this->isUsingDnsDockDnsServer()) { $this->userInteraction->writeTitle('Configure routing for direct Docker containers access'); $this->processRunner->run("sudo sed -i -e '1inameserver " . DnsDock::IP . "\\' /etc/resolv.conf"); } }
/** * {@inheritdoc} */ public function run() { $this->userInteraction->writeTitle('Configure routing for direct Docker containers access'); $machineIp = $this->machine->getIp(); $this->configureRouting($machineIp); $this->addPermanentRouting($machineIp); }
/** * {@inheritdoc} */ public function run() { if (!$this->isUsingDnsDockDnsServer()) { $this->userInteraction->writeTitle('Configure routing for direct Docker containers access'); $this->processRunner->run('echo "nameserver ' . DnsDock::IP . '" | sudo tee -a /etc/resolvconf/resolv.conf.d/head'); $this->processRunner->run('sudo resolvconf -u'); } }
/** * {@inheritdoc} */ public function run() { $this->userInteraction->writeTitle('Configure DNS resolution for Docker containers'); $needMachineRestart = $this->configureVirtualMachine(); $this->configureHostMachineResolution(); if ($needMachineRestart) { $this->restartMachine(); } }
/** * @param string $prefix * @param array $lines */ private function pipeLinesWithPrefix($prefix, array $lines) { foreach ($lines as $line) { $line = trim($line); if (!empty($line)) { $this->userInteraction->write($prefix . ' ' . $line); } } }
public function run() { if (!$this->hasDockerOptions()) { $this->userInteraction->writeTitle('Configuring DNS resolution for Docker containers'); $this->processRunner->run('echo \'DOCKER_OPTS="--bip=' . self::IP . '/24 --dns ' . self::IP . '"\' | sudo tee -a /etc/default/docker'); $this->processRunner->run('sudo service docker restart'); } $this->processRunner->run('sudo docker start dnsdock || sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.42.1:53:53/udp tonistiigi/dnsdock'); }
/** * {@inheritdoc} */ public function run() { if ($this->processRunner->run($this->getVersionCommand(), false)->isSuccessful()) { $this->userInteraction->write(sprintf('"%s" is already installed', $this->getName())); } else { $this->userInteraction->write(sprintf('Installing "%s"', $this->getName())); $this->processRunner->run($this->getInstallCommand()); $this->userInteraction->write(sprintf('"%s" successfully installed', $this->getName())); } }
/** * @return callable */ private function getRunningProcessCallback() { return function ($type, $buffer) { $lines = explode("\n", $buffer); $prefix = Process::ERR === $type ? '<error>ERR</error> ' : '<question>OUT</question> '; foreach ($lines as $line) { $line = trim($line); if (!empty($line)) { $this->userInteraction->write($prefix . $line); } } }; }
/** * {@inheritdoc} */ public function execute(ChainContext $context) { try { $this->process->execute($context); } catch (ProcessFailedException $e) { $processOutput = $e->getProcess()->getOutput(); if (strpos($processOutput, 'Agreeing to the Xcode/iOS license requires admin privileges, please re-run') !== false) { $this->userInteraction->writeTitle('You need to agree Xcode license.'); $this->userInteraction->write('Run `xcode-select --install` to fix the problem and run this command again.'); throw $e; } } }
/** * {@inheritdoc} */ public function start(Project $project) { try { $this->doctor->examine(new NullOutput(), true); } catch (CommandFailedException $e) { if (!$this->userInteraction instanceof ConsoleUserInteraction) { throw $e; } $answer = $this->userInteraction->ask(new Question('It looks like there\'s something wrong with your installation. Would you like to run the `doctor` command ? [Yn]', 'y')); if ('y' == strtolower($answer)) { $this->doctor->examine($this->userInteraction->getOutput(), false); } } return $this->projectManager->start($project); }
/** * @return string */ protected function promptForPackageName() { $defaultPhpVersion = $this->guessSsh2PhpPackage(); $question = new Question(sprintf('Which homebrew package do you want to install (default "%s") ? ("n" for nothing)', $defaultPhpVersion), $defaultPhpVersion); $package = $this->userInteraction->ask($question); return $package; }
/** * {@inheritdoc} */ public function run() { $this->userInteraction->writeTitle("Pulling image aacebedo/dnsdock"); $this->userInteraction->write("Check docker machine is running"); if (!$this->machine->isRunning()) { $this->userInteraction->write("Starting machine"); $this->machine->start(); } $this->userInteraction->write("Setting environment variables"); $this->processRunner->run($this->machine->getEnvironmentDeclaration()); $this->userInteraction->write("Pulling image aacebedo/dnsdock, this could take a while when run for the first time"); $this->processRunner->run('docker pull aacebedo/dnsdock:latest-amd64'); }
/** * {@inheritdoc} */ public function run() { $this->userInteraction->writeTitle('Setting up machine environment variables'); $this->saveEnvironmentVariables(); }
/** * {@inheritdoc} */ public function run(InstallContext $context) { $this->userInteraction = $context->getUserInteraction(); $this->processRunner = $context->getProcessRunner(); $boot2docker = new Boot2DockerCli($this->processRunner); if ($boot2docker->isInstalled()) { $this->userInteraction->writeTitle('Boot2Docker seems to be installed, removing it.'); if (!$boot2docker->uninstall()) { $this->userInteraction->writeTitle('Something went wrong while uninstalling Boot2Docker, continuing anyway.'); } else { $this->userInteraction->writeTitle('Successfully uninstalled boot2docker'); } } $dinghy = new DinghyCli($context->getProcessRunner()); if (!$dinghy->isInstalled()) { $this->userInteraction->writeTitle('Installing Dinghy'); $this->installDinghy(); $this->userInteraction->writeTitle('Successfully installed Dinghy'); } else { $this->userInteraction->writeTitle('Dinghy already installed, skipping.'); } $this->changeDinghyDnsResolverNamespace(); $this->userInteraction->writeTitle('Starting up Dinghy'); if (!$dinghy->isRunning()) { $dinghy->start(); $this->userInteraction->writeTitle('Started Dinghy'); } else { $this->userInteraction->writeTitle('Dinghy already started'); } if (!$this->haveDinghyEnvironmentVariables()) { $this->userInteraction->writeTitle('Setting up dinghy environment variables'); $this->setupDinghyEnvironmentVariables(); } }
/** * {@inheritdoc} */ public function stop(Project $project) { $this->userInteraction->writeTitle('Stopping application containers'); $this->processRunner->followsUpWith($this->composeExecutableFinder->find(), ['stop']); }