/** * @param InputInterface $input * @param OutputInterface $output * @throws \RuntimeException * @return int|void */ protected function execute(InputInterface $input, OutputInterface $output) { $opener = ''; if (OperatingSystem::isMacOs()) { $opener = 'open'; } elseif (OperatingSystem::isWindows()) { $opener = 'start'; } else { // Linux if (exec('which xde-open')) { $opener = 'xdg-open'; } elseif (exec('which gnome-open')) { $opener = 'gnome-open'; } elseif (exec('which kde-open')) { $opener = 'kde-open'; } } if (empty($opener)) { throw new \RuntimeException('No opener command like xde-open, gnome-open, kde-open was found.'); } $this->detectContao($output); if ($this->initContao($output)) { $store = $this->getHelperSet()->get('parameter')->askStore($input, $output, 'store', true); if ($store->getId() == \Mage_Core_Model_App::ADMIN_STORE_ID) { $adminFrontName = (string) \Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName'); $url = rtrim($store->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_WEB), '/') . '/' . $adminFrontName; } else { $url = $store->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_LINK) . '?___store=' . $store->getCode(); } $output->writeln('Opening URL <comment>' . $url . '</comment> in browser'); exec(escapeshellcmd($opener . ' ' . $url)); } }
/** * Display a warning if a running imi-conrun as root user * * @param ConsoleEvent $event * @return void */ public function checkRunningAsRootUser(Event $event) { if ($this->_isSkipRootCheck()) { return; } $config = $event->getApplication()->getConfig(); if (!$config['application']['check-root-user']) { return; } $output = $event->getOutput(); if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) { if (function_exists('posix_getuid')) { if (posix_getuid() === 0) { $output->writeln(''); $output->writeln(self::WARNING_ROOT_USER); $output->writeln(''); } } } }