CC-3237: Remove phing dependency of end user database installation
-Done
This commit is contained in:
parent
67ddda4a2d
commit
cb3cb5b48c
|
@ -242,14 +242,21 @@ class AirtimeInstall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CreateDatabaseTables()
|
public static function CreateDatabaseTables($p_dbuser, $p_dbpasswd, $p_dbname, $p_dbhost)
|
||||||
{
|
{
|
||||||
echo " * Creating database tables".PHP_EOL;
|
echo " * Creating database tables".PHP_EOL;
|
||||||
|
|
||||||
// Put Propel sql files in Database
|
// Put Propel sql files in Database
|
||||||
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql";
|
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
|
||||||
$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
|
|
||||||
@exec($command, $output, $results);
|
$dir = AirtimeInstall::CONF_DIR_WWW."/build/sql/";
|
||||||
|
$files = array("schema.sql", "sequences.sql", "views.sql", "triggers.sql", "defaultdata.sql");
|
||||||
|
|
||||||
|
foreach ($files as $f){
|
||||||
|
$command = "export PGPASSWORD=$p_dbpasswd && psql --username $p_dbuser --dbname $p_dbname --host $p_dbhost --file $dir$f 2>/dev/null";
|
||||||
|
@exec($command, $output, $results);
|
||||||
|
}
|
||||||
|
|
||||||
AirtimeInstall::$databaseTablesCreated = true;
|
AirtimeInstall::$databaseTablesCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,15 @@ AirtimeInstall::DbConnect(true);
|
||||||
|
|
||||||
AirtimeInstall::InstallPostgresScriptingLanguage();
|
AirtimeInstall::InstallPostgresScriptingLanguage();
|
||||||
|
|
||||||
|
//Load Database parameters
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$dbuser = $CC_CONFIG['dsn']['username'];
|
||||||
|
$dbpasswd = $CC_CONFIG['dsn']['password'];
|
||||||
|
$dbname = $CC_CONFIG['dsn']['database'];
|
||||||
|
$dbhost = $CC_CONFIG['dsn']['hostspec'];
|
||||||
|
|
||||||
if (isset($argv[1]) && $argv[1] == 'y') {
|
if (isset($argv[1]) && $argv[1] == 'y') {
|
||||||
AirtimeInstall::CreateDatabaseTables();
|
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
|
||||||
} else if ($databaseExisted) {
|
} else if ($databaseExisted) {
|
||||||
//Database already exists. Ask the user how they want to
|
//Database already exists. Ask the user how they want to
|
||||||
//proceed. Warn them that creating the database tables again
|
//proceed. Warn them that creating the database tables again
|
||||||
|
@ -36,12 +43,12 @@ if (isset($argv[1]) && $argv[1] == 'y') {
|
||||||
$userAnswer = trim(fgets(STDIN));
|
$userAnswer = trim(fgets(STDIN));
|
||||||
}
|
}
|
||||||
if (in_array($userAnswer, array("y", "Y"))) {
|
if (in_array($userAnswer, array("y", "Y"))) {
|
||||||
AirtimeInstall::CreateDatabaseTables();
|
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Database was just created, meaning the tables do not
|
//Database was just created, meaning the tables do not
|
||||||
//exist. Let's create them.
|
//exist. Let's create them.
|
||||||
AirtimeInstall::CreateDatabaseTables();
|
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo " * Setting Airtime version".PHP_EOL;
|
echo " * Setting Airtime version".PHP_EOL;
|
||||||
|
|
Loading…
Reference in New Issue