More work on new installer

This commit is contained in:
Duncan Sommerville 2014-11-28 15:30:11 -05:00
parent 0b77222013
commit 8f46b4dca7
8 changed files with 279 additions and 152 deletions

View file

@ -9,33 +9,60 @@ require_once(LIB_PATH . "propel/runtime/lib/Propel.php");
* properly configured and running
*/
function airtimeCheckConfiguration() {
return airtimeCheckDatabase()
&& airtimeCheckDependencies();
}
function airtimeCheckDependencies() {
$deps = array();
$deps["zend"] = file_exists('/usr/share/php/libzend-framework-php');
return $deps;
return airtimeCheckPhpDependencies()
&& airtimeCheckDatabaseConfiguration();
}
/**
* Check that the database exists and is configured correctly
* Check for Airtime's PHP dependencies and return an associative
* array with the results
*
* @return boolean true if the database exists and is configured correctly, false otherwise
* @return array associative array of dependency check results
*/
function airtimeCheckDatabase() {
function airtimeCheckPhpDependencies() {
return array(
"zend" => airtimeCheckMvcDependencies(),
"postgres" => airtimeCheckDatabaseDependencies()
);
}
/**
* Check that the Zend framework libraries are installed
*
* @return boolean true if Zend exists in /usr/share/php
*/
function airtimeCheckMvcDependencies() {
return file_exists('/usr/share/php/libzend-framework-php')
|| file_exists('/usr/share/php/zendframework'); // Debian version
}
/**
* Check that the PHP dependencies for the database exist
*
* @return boolean true if the database dependencies exist
*/
function airtimeCheckDatabaseDependencies() {
if (!isset($extensions)) {
$extensions = get_loaded_extensions();
}
// Check the PHP extension list for the Postgres db extensions
return (in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions));
}
/**
* Check the database configuration by fetching a connection from Propel
*
* @return boolean true if a connection is made to the database
*/
function airtimeCheckDatabaseConfiguration() {
airtimeConfigureDatabase();
if (!file_exists(BUILD_PATH . AIRTIME_CONFIG)) {
return false;
}
$config = parse_ini_file(BUILD_PATH . AIRTIME_CONFIG, true);
try {
Propel::getConnection($config["database"]["dbname"]);
// Try to establish a database connection. If something goes
// wrong, the database is improperly configured
Propel::getConnection();
Propel::close();
} catch (Exception $e) {
return false;
}
@ -43,6 +70,9 @@ function airtimeCheckDatabase() {
return true;
}
/**
* Initialize Propel to configure the Airtime database
*/
function airtimeConfigureDatabase() {
Propel::init(APPLICATION_PATH . "/configs/airtime-conf-production.php");
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}

View file

@ -1,2 +1,18 @@
<?php
?>
<html style="background-color:black;color:white;">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap-3.3.1.min.css">
</head>
<body style="padding: 2em 0; min-width: 400px; width: 30%; text-align: center; margin: 3em auto;">
<img src="css/images/airtime_logo_jp.png" style="margin-bottom: .5em;" /><br/>
<form>
<h2>Database Settings</h2>
<input type="text" placeholder="Username"/>
<input type="password" placeholder="Password"/>
<input type="text" placeholder="Name"/>
<input type="text" placeholder="Host" value="localhost"/>
<input type="submit" />
</form>