/** * The beef of the installer! * Create database, config file, and admin user. * * Prerequisites: validation of input data. * * @return boolean success */ function doInstall() { $this->updateStatus("Initializing..."); ini_set('display_errors', 1); error_reporting(E_ALL); if (!defined('STATUSNET')) { define('STATUSNET', 1); } require_once INSTALLDIR . '/lib/framework.php'; StatusNet::initDefaults($this->server, $this->path); try { $this->db = $this->setupDatabase(); if (!$this->db) { // database connection failed, do not move on to create config file. return false; } } catch (Exception $e) { // Lower-level DB error! $this->updateStatus("Database error: " . $e->getMessage(), true); return false; } // Make sure we can write to the file twice $oldUmask = umask(00); if (!$this->skipConfig) { $this->updateStatus("Writing config file..."); $res = $this->writeConf(); if (!$res) { $this->updateStatus("Can't write config file.", true); return false; } } if (!empty($this->adminNick)) { // Okay, cross fingers and try to register an initial user if ($this->registerInitialUser()) { $this->updateStatus("An initial user with the administrator role has been created."); } else { $this->updateStatus("Could not create initial StatusNet user (administrator).", true); return false; } } if (!$this->skipConfig) { $this->updateStatus("Setting site profile..."); $res = $this->writeSiteProfile(); if (!$res) { $this->updateStatus("Can't write to config file.", true); return false; } } // Restore original umask umask($oldUmask); // Set permissions back to something decent chmod(INSTALLDIR . '/config.php', 0644); /* TODO https needs to be considered */ $link = "http://" . $this->server . '/' . $this->path; $this->updateStatus("StatusNet has been installed at {$link}"); $this->updateStatus("<strong>DONE!</strong> You can visit your <a href='{$link}'>new StatusNet site</a> (login as '{$this->adminNick}'). If this is your first StatusNet install, you may want to poke around our <a href='http://status.net/wiki/Getting_started'>Getting Started guide</a>."); return true; }
/** * Initialize, or re-initialize, StatusNet global configuration * and plugins. * * If switching site configurations during script execution, be * careful when working with leftover objects -- global settings * affect many things and they may not behave as you expected. * * @param $server optional web server hostname for picking config * @param $path optional URL path for picking config * @param $conffile optional configuration file path * * @throws NoConfigException if config file can't be found */ public static function init($server = null, $path = null, $conffile = null) { StatusNet::initDefaults($server, $path); StatusNet::loadConfigFile($conffile); // Load settings from database; note we need autoload for this Config::loadSettings(); self::initPlugins(); }
/** * Initialize, or re-initialize, StatusNet global configuration * and plugins. * * If switching site configurations during script execution, be * careful when working with leftover objects -- global settings * affect many things and they may not behave as you expected. * * @param $server optional web server hostname for picking config * @param $path optional URL path for picking config * @param $conffile optional configuration file path * * @throws NoConfigException if config file can't be found */ public static function init($server = null, $path = null, $conffile = null) { Router::clear(); StatusNet::initDefaults($server, $path); StatusNet::loadConfigFile($conffile); $sprofile = common_config('site', 'profile'); if (!empty($sprofile)) { StatusNet::loadSiteProfile($sprofile); } // Load settings from database; note we need autoload for this Config::loadSettings(); self::initPlugins(); }