private function _freshInstall() { $defaultModules = Kohana::config('config.modules'); Kohana::config_set('core.modules', $defaultModules); // Get the doctrine overlord $manager = Doctrine_Manager::getInstance(); $conn = $manager->getCurrentConnection(); try { // See if we can connect to the DB $conn->connect(); } catch (Doctrine_Connection_Exception $e) { // We could connect earlier, hmmm.... try { Doctrine::createDatabases(); } catch (Exception $e) { // We cant resolve this issue without the user message::set('Unable to establish a connection to ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>'); return FALSE; } } // See if the DB has any tables in it $tables = $conn->import->listTables(); if (!empty($tables)) { // Yup, there are tables in our soon to be fresh install db, remove them try { $dsn = $conn->getOption('dsn'); $dsn = $manager->parsePdoDsn($dsn); $tmpConn = $conn->getTmpConnection($dsn); $conn->close(); $tmpConn->export->dropDatabase($dsn['dbname']); $tmpConn->export->createDatabase($dsn['dbname']); $manager->closeConnection($tmpConn); $conn->connect(); } catch (Exception $e) { // We cant resolve this issue without the user message::set('Unable to recreate database ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>'); return FALSE; } } $driver = $this->session->get('installer.tel_driver', 'none'); kohana::log('debug', 'Installer running for driver ' . $driver); $packages = $this->session->get('installer.default_packages', array()); $packages = arr::merge($this->minimumPackages, $packages, array($driver)); try { $transaction = Package_Transaction::beginTransaction(); foreach ($packages as $package) { try { $identifier = Package_Catalog::getFirstAvaliablePackage($package); $transaction->install($identifier); } catch (Exception $e) { kohana::log('error', 'Error during initial install package selection: ' . $e->getMessage()); } } $transaction->commit(); Session::instance()->set('Bluebox_installer.created', Bluebox_Tenant::$created); return TRUE; } catch (Exception $e) { message::set('Installer Error!' . '<div class="error_details">' . $e->getMessage() . '</div>'); return FALSE; } }