more verbose, better checks for installforemail

This commit is contained in:
Evan Prodromou 2011-04-28 15:30:59 -07:00
parent ddead1e611
commit 83819737d7
2 changed files with 26 additions and 3 deletions

View File

@ -53,7 +53,8 @@ class DomainStatusNetworkInstaller extends Installer
protected $rootpass = null; protected $rootpass = null;
protected $nickname = null; protected $nickname = null;
protected $sn = null; protected $sn = null;
protected $verbose = false;
public $verbose = false;
function __construct($domain) function __construct($domain)
{ {
@ -94,10 +95,18 @@ class DomainStatusNetworkInstaller extends Installer
$this->path = null; $this->path = null;
$this->fancy = true; $this->fancy = true;
$datanick = $this->databaseize($this->nickname);
$this->host = $config['DBHOSTNAME']; $this->host = $config['DBHOSTNAME'];
$this->database = $this->nickname.$config['DBBASE']; $this->database = $datanick.$config['DBBASE'];
$this->dbtype = 'mysql'; // XXX: support others... someday $this->dbtype = 'mysql'; // XXX: support others... someday
$this->username = $this->nickname.$config['USERBASE']; $this->username = $datanick.$config['USERBASE'];
// Max size for MySQL
if (strlen($this->username) > 16) {
$this->username = sprintf('%s%08x', substr($this->username, 0, 8), crc32($this->username));
}
$pwgen = $config['PWDGEN']; $pwgen = $config['PWDGEN'];
@ -136,10 +145,14 @@ class DomainStatusNetworkInstaller extends Installer
function setupDatabase() function setupDatabase()
{ {
$this->updateStatus('Creating database...');
$this->createDatabase(); $this->createDatabase();
parent::setupDatabase(); parent::setupDatabase();
$this->updateStatus('Creating file directories...');
$this->createDirectories(); $this->createDirectories();
$this->updateStatus('Saving status network...');
$this->saveStatusNetwork(); $this->saveStatusNetwork();
$this->updateStatus('Checking schema for plugins...');
$this->checkSchema(); $this->checkSchema();
} }
@ -157,6 +170,7 @@ class DomainStatusNetworkInstaller extends Installer
$sn->dbuser = $this->username; $sn->dbuser = $this->username;
$sn->dbpass = $this->password; $sn->dbpass = $this->password;
$sn->dbname = $this->database; $sn->dbname = $this->database;
$sn->sitename = $this->sitename;
$result = $sn->insert(); $result = $sn->insert();
@ -273,4 +287,10 @@ class DomainStatusNetworkInstaller extends Installer
$html); $html);
return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8'); return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8');
} }
function databaseize($nickname)
{
$nickname = str_replace('-', '_', $nickname);
return $nickname;
}
} }

View File

@ -37,6 +37,9 @@ $sn = DomainStatusNetworkPlugin::siteForDomain($domain);
if (empty($sn)) { if (empty($sn)) {
$installer = new DomainStatusNetworkInstaller($domain); $installer = new DomainStatusNetworkInstaller($domain);
$installer->verbose = have_option('v', 'verbose');
// Do the thing // Do the thing
$installer->main(); $installer->main();