예제 #1
0
 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);
     }
 }
예제 #2
0
 public function check(InputInterface $input, OutputInterface $output)
 {
     if (!file_exists($this->target_dir)) {
         throw new \RuntimeException(sprintf('Site not found: %s', $this->site));
     }
     $path = Util::buildTargetPath('libraries/koowa/libraries/koowa.php', $this->target_dir);
     if (!file_exists($path)) {
         throw new \RuntimeException(sprintf('Koowa is not installed on site: %s', $this->site));
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
 public function callHasChildren()
 {
     $filename = $this->getFilename();
     if ($filename[0] == '.') {
         return false;
     }
     $source = $this->key();
     $target = str_replace($this->source, '', $source);
     $target = str_replace('/site', '', $target);
     $target = Util::buildTargetPath($target, $this->target);
     if (is_link($target)) {
         unlink($target);
     }
     if (!is_dir($target)) {
         $this->createLink($source, $target);
         return false;
     }
     return parent::callHasChildren();
 }
예제 #5
0
    protected function configure()
    {
        parent::configure();
        $this->setName('site:create')->setDescription('Create a new Joomla site from scratch')->setHelp(<<<EOF
To create a site with the latest Joomla version, run:

    <info>joomla site:create foobar</info>

The newly installed site will be available at <comment>/var/www/foobar</comment> and <comment>foobar.dev</comment> after that. You can login into your fresh Joomla installation using these credentials: admin/admin.
By default, the web server root is set to <comment>/var/www</comment>. You can pass <comment>–www=/my/server/path</comment> to commands for custom values.

The console can also install the Joomlatools Platform out of the box by adding the <comment>--repo=platform</comment> flag:

    <info>joomla site:create joomlatools-platform --repo=platform</info>

You can choose the Joomla version or the sample data to be installed. A more elaborate example:

    <info>joomla site:create testsite --release=2.5 --sample-data=blog</info>
EOF
)->addOption('release', null, InputOption::VALUE_REQUIRED, "Joomla version. Can be a release number (2, 3.2, ..) or branch name. Run `joomla versions` for a full list.\nUse \"none\" for an empty virtual host.", 'latest')->addOption('sample-data', null, InputOption::VALUE_REQUIRED, 'Sample data to install (default|blog|brochure|learn|testing)')->addOption('symlink', null, InputOption::VALUE_REQUIRED, 'A comma separated list of directories to symlink from the projects directory. Use \'all\' to symlink every folder.')->addOption('repo', null, InputOption::VALUE_REQUIRED, 'Alternative Git repository to clone. To use joomlatools/platform, use --repo=platform.')->addOption('clear-cache', null, InputOption::VALUE_NONE, 'Update the list of available tags and branches from the Joomla repository')->addOption('projects-dir', null, InputOption::VALUE_REQUIRED, 'Directory where your custom projects reside', sprintf('%s/Projects', trim(`echo ~`)))->addOption('http-port', null, InputOption::VALUE_REQUIRED, 'The HTTP port the virtual host should listen to', Util::isJoomlatoolsBox() ? 8080 : 80)->addOption('disable-ssl', null, InputOption::VALUE_NONE, 'Disable SSL for this site')->addOption('ssl-crt', null, InputOption::VALUE_REQUIRED, 'The full path to the signed cerfificate file', '/etc/apache2/ssl/server.crt')->addOption('ssl-key', null, InputOption::VALUE_REQUIRED, 'The full path to the private cerfificate file', '/etc/apache2/ssl/server.key')->addOption('ssl-port', null, InputOption::VALUE_REQUIRED, 'The port on which the server will listen for SSL requests', '443')->addOption('interactive', null, InputOption::VALUE_NONE, 'Prompt for configuration details');
    }
예제 #6
0
 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`;
         }
     }
 }
예제 #7
0
 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`;
         }
     }
 }
    $component = 'com_' . $manifest->{'nooku-component'}->name;
    if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
        $output->writeln("Symlinking `{$component}` into `{$destination}`");
    }
    $dirs = array(Util::buildTargetPath('/libraries/koowa/components', $destination), Util::buildTargetPath('/media/koowa', $destination));
    foreach ($dirs as $dir) {
        if (!is_dir($dir)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating empty directory `{$dir}`");
            }
            mkdir($dir, 0777, true);
        }
    }
    $code_destination = Util::buildTargetPath('/libraries/koowa/components/' . $component, $destination);
    if (!file_exists($code_destination)) {
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->writeln(" * creating link `{$code_destination}` -> {$project}");
        }
        `ln -sf {$project} {$code_destination}`;
    }
    // Special treatment for media files
    $media = $project . '/resources/assets';
    $target = Util::buildTargetPath('/media/koowa/' . $component, $destination);
    if (is_dir($media) && !file_exists($target)) {
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->writeln(" * creating link `{$target}` -> {$media}");
        }
        `ln -sf {$media} {$target}`;
    }
    return true;
});
예제 #9
0
 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);
 }
예제 #10
0
 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));
 }
예제 #11
0
 protected function _removeTemporaryScript()
 {
     $target = Util::isPlatform($this->target_dir) ? $this->target_dir . '/web' : $this->target_dir;
     return unlink($target . '/console-cache.php');
 }
예제 #12
0
 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;
 }
        return false;
    }
    $manifest = json_decode(file_get_contents($project . '/composer.json'));
    if (!isset($manifest->name) || $manifest->name != 'joomlatools/framework') {
        return false;
    }
    // build the folders to symlink into
    $dirs = array(Util::buildTargetPath('/libraries/joomlatools/component', $destination), Util::buildTargetPath('/media/koowa', $destination));
    foreach ($dirs as $dir) {
        if (!is_dir($dir)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating empty directory `{$dir}`");
            }
            mkdir($dir, 0777, true);
        }
    }
    /*
     * Special treatment for media files
     */
    $media = array($project . '/code/libraries/joomlatools/component/koowa/resources/assets' => Util::buildTargetPath('/media/koowa/com_koowa', $destination), $project . '/code/libraries/joomlatools/library/resources/assets' => Util::buildTargetPath('/media/koowa/framework', $destination));
    foreach ($media as $from => $to) {
        if (is_dir($from) && !file_exists($to)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating link `{$to}` -> {$from}");
            }
            `ln -sf {$from} {$to}`;
        }
    }
    // Let the default symlinker handle the rest
    return false;
});