protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); if (is_dir('/etc/apache2/sites-available')) { $site = $input->getArgument('site'); $port = $input->getOption('http-port'); $path = realpath(__DIR__ . '/../../../../../bin/.files/'); $tmp = '/tmp/vhost.tmp'; $template = file_get_contents($path . '/vhost.conf'); $documentroot = Util::isPlatform($this->target_dir) ? $this->target_dir . '/web/' : $this->target_dir; file_put_contents($tmp, sprintf($template, $site, $documentroot, $port)); if (!$input->getOption('disable-ssl')) { $ssl_crt = $input->getOption('ssl-crt'); $ssl_key = $input->getOption('ssl-key'); $ssl_port = $input->getOption('ssl-port'); if (file_exists($ssl_crt) && file_exists($ssl_key)) { $template = "\n\n" . file_get_contents($path . '/vhost.ssl.conf'); file_put_contents($tmp, sprintf($template, $site, $documentroot, $ssl_port, $ssl_crt, $ssl_key), FILE_APPEND); } else { $output->writeln('<comment>SSL was not enabled for the site. One or more certificate files are missing.</comment>'); } } `sudo tee /etc/apache2/sites-available/1-{$site}.conf < {$tmp}`; `sudo a2ensite 1-{$site}.conf`; `sudo /etc/init.d/apache2 restart > /dev/null 2>&1`; @unlink($tmp); } }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $this->app = Bootstrapper::getApplication($this->target_dir); // Load Library language $lang = \JFactory::getLanguage(); // Try the finder_cli file in the current language (without allowing the loading of the file in the default language) $path = Util::isPlatform($this->target_dir) ? JPATH_SITE . '/components/com_finder' : JPATH_SITE; $lang->load('finder_cli', $path, null, false, false) || $lang->load('finder_cli', $path, null, true); // Fallback to the finder_cli file in the default language $this->check($input, $output); $this->purgeFinder($input, $output); }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $this->check($input, $output); $this->versions = new Versions(); if ($input->getOption('repo')) { $this->versions->setRepository($input->getOption('repo')); } if ($input->getOption('refresh')) { $this->versions->refresh(); } if ($input->getOption('clear-cache')) { $this->versions->clearcache($output); } $this->setVersion($input->getOption('release')); if ($this->version != 'none') { $tarball = $this->_getTarball($output); if (!$this->_isValidTarball($tarball)) { if (file_exists($tarball)) { unlink($tarball); } throw new \RuntimeException(sprintf('Downloaded tarball "%s" could not be verified. A common cause is an interrupted download: check your internet connection and try again.', basename($tarball))); } if (!file_exists($this->target_dir)) { `mkdir -p {$this->target_dir}`; } `cd {$this->target_dir}; tar xzf {$tarball} --strip 1`; if ($this->versions->isBranch($this->version)) { unlink($tarball); } $isPlatform = Util::isPlatform($this->target_dir); $directory = $this->target_dir . ($isPlatform ? '/web' : ''); if (file_exists($directory . '/htaccess.txt')) { `cp {$directory}/htaccess.txt {$directory}/.htaccess`; } if ($isPlatform) { `cd {$this->target_dir}; composer install -q`; } } }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $this->check($input, $output); $this->versions = new Versions(); if ($input->getOption('repo')) { $this->versions->setRepository($input->getOption('repo')); } if ($input->getOption('refresh')) { $this->versions->refresh(); } if ($input->getOption('clear-cache')) { $this->versions->clearcache($output); } $this->setVersion($input->getOption('release')); if ($this->version != 'none') { $tarball = $this->_getTarball($output); if (!file_exists($tarball)) { throw new \RuntimeException(sprintf('File %s does not exist', $tarball)); } if (!file_exists($this->target_dir)) { `mkdir -p {$this->target_dir}`; } `cd {$this->target_dir}; tar xzf {$tarball} --strip 1`; if ($this->versions->isBranch($this->version)) { unlink($tarball); } $isPlatform = Util::isPlatform($this->target_dir); $directory = $this->target_dir . ($isPlatform ? '/web' : ''); if (file_exists($directory . '/htaccess.txt')) { `cp {$directory}/htaccess.txt {$directory}/.htaccess`; } if ($isPlatform) { `cd {$this->target_dir}; composer install -q`; } } }
protected function _promptDetails(InputInterface $input, OutputInterface $output) { if (!$this->_skip_database_prompt) { $this->_promptDatabaseDetails($input, $output); } if (Util::isPlatform($this->target_dir)) { $this->_default_values['env'] = $this->_ask($input, $output, 'Environment', array('development', 'staging', 'production'), true); } else { $this->_default_values['sitename'] = $this->_ask($input, $output, 'Site Name', $this->_default_values['sitename'], true); } $this->_default_values['tmp_path'] = $this->_ask($input, $output, 'Temporary path', $this->_default_values['tmp_path'], true); $this->_default_values['log_path'] = $this->_ask($input, $output, 'Log path', $this->_default_values['log_path'], true); $this->_default_values['key'] = $this->_ask($input, $output, 'Secret Key', $this->_default_values['key'], true); }
protected function _enableWebInstaller(InputInterface $input, OutputInterface $output) { if (Util::isPlatform($this->target_dir)) { return; } $version = Util::getJoomlaVersion($this->target_dir); if (version_compare($version, '3.2.0', '<')) { return; } $xml = simplexml_load_file('http://appscdn.joomla.org/webapps/jedapps/webinstaller.xml'); if (!$xml) { $output->writeln('<warning>Failed to install web installer</warning>'); return; } $url = ''; foreach ($xml->update->downloads->children() as $download) { $attributes = $download->attributes(); if ($attributes->type == 'full' && $attributes->format == 'zip') { $url = (string) $download; break; } } if (empty($url)) { return; } $filename = self::$files . '/cache/' . basename($url); if (!file_exists($filename)) { $bytes = file_put_contents($filename, fopen($url, 'r')); if ($bytes === false || $bytes == 0) { return; } } `mkdir -p {$this->target_dir}/plugins/installer`; `cd {$this->target_dir}/plugins/installer/ && unzip -o {$filename}`; $sql = "INSERT INTO `j_extensions` (`name`, `type`, `element`, `folder`, `enabled`, `access`, `manifest_cache`) VALUES ('plg_installer_webinstaller', 'plugin', 'webinstaller', 'installer', 1, 1, '{\"name\":\"plg_installer_webinstaller\",\"type\":\"plugin\",\"version\":\"" . $xml->update->version . "\",\"description\":\"Web Installer\"}');"; $sql = escapeshellarg($sql); $password = empty($this->mysql->password) ? '' : sprintf("-p'%s'", $this->mysql->password); exec(sprintf("mysql --host=%s -u'%s' %s %s -e %s", $this->mysql->host, $this->mysql->user, $password, $this->target_db, $sql)); }
protected function _removeTemporaryScript() { $target = Util::isPlatform($this->target_dir) ? $this->target_dir . '/web' : $this->target_dir; return unlink($target . '/console-cache.php'); }
protected function _getInstallFiles($sample_data = false) { $files = array(); if (Util::isPlatform($this->target_dir)) { $path = $this->target_dir . '/install/mysql/'; $files[] = $path . 'schema.sql'; $files[] = $path . 'data.sql'; } else { $path = $this->target_dir . '/_installation/sql/mysql/'; if (!file_exists($path)) { $path = $this->target_dir . '/installation/sql/mysql/'; } $files[] = $path . 'joomla.sql'; if ($sample_data) { $type = $sample_data == 'default' ? 'data' : $sample_data; $sample_db = $path . 'sample_' . $type . '.sql'; $files[] = $sample_db; } } return $files; }