/** * The beef of the installer! * Create database, config file, and admin user. * * Prerequisites: validation of input data. * * @return boolean success */ function doInstall() { global $config; $this->updateStatus("Initializing..."); ini_set('display_errors', 1); error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE); if (!defined('GNUSOCIAL')) { define('GNUSOCIAL', true); } if (!defined('STATUSNET')) { define('STATUSNET', true); } require_once INSTALLDIR . '/lib/framework.php'; GNUsocial::initDefaults($this->server, $this->path); if ($this->siteProfile == "singleuser") { // Until we use ['site']['profile']==='singleuser' everywhere $config['singleuser']['enabled'] = true; } 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 user account.", 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); $scheme = $this->ssl === 'always' ? 'https' : 'http'; $link = "{$scheme}://{$this->server}/{$this->path}"; $this->updateStatus("GNU social has been installed at {$link}"); $this->updateStatus('<strong>DONE!</strong> You can visit your <a href="' . htmlspecialchars($link) . '">new GNU social site</a> (log in as "' . htmlspecialchars($this->adminNick) . '"). If this is your first GNU social install, make your experience the best possible by visiting our resource site to join the <a href="https://gnu.io/social/resources/">mailing list or IRC.</a>. <a href="' . htmlspecialchars($link) . '/doc/faq/">FAQ is found here</a>.'); return true; }