CC-2281 Install script should check for pre-installed versions and prompt user to upgrade/full installation

if a user has an older version installed and they choose to do a fresh install the option to preserve their config files is not allowed.
This commit is contained in:
Naomi 2011-05-19 15:05:33 -04:00
parent 697d5e0b77
commit 5e02a46a24
2 changed files with 15 additions and 8 deletions

View File

@ -16,9 +16,10 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.
AirtimeInstall::ExitIfNotRoot(); AirtimeInstall::ExitIfNotRoot();
$version = AirtimeInstall::CheckForVersionBeforeInstall(); $version = AirtimeInstall::CheckForVersionBeforeInstall();
$turnOffPreserve = false;
echo "Airtime version $version found.".PHP_EOL; //echo "Airtime version $version found.".PHP_EOL;
echo "Airtime version ".AIRTIME_VERSION." found.".PHP_EOL; //echo "Airtime version ".AIRTIME_VERSION." found.".PHP_EOL;
require_once('Zend/Loader/Autoloader.php'); require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader = Zend_Loader_Autoloader::getInstance();
@ -51,6 +52,9 @@ if(isset($version) && $version != false && $version < AIRTIME_VERSION) {
system($command); system($command);
exit(); exit();
} }
else if (in_array($userAnswer, array("i", "I"))) {
$turnOffPreserve = true;
}
} }
try { try {
@ -81,7 +85,7 @@ if (isset($opts->o)) {
$overwrite = true; $overwrite = true;
} }
else if (!isset($opts->p) && !isset($opts->o)) { else if (!isset($opts->p) && !isset($opts->o)) {
if (AirtimeIni::IniFilesExist()) { if (AirtimeIni::IniFilesExist() && !$turnOffPreserve) {
$userAnswer = "x"; $userAnswer = "x";
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) { while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) "; echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) ";

View File

@ -38,13 +38,16 @@ class AirtimeInstall
{ {
global $CC_DBC, $CC_CONFIG; global $CC_DBC, $CC_CONFIG;
try{ $values = parse_ini_file('/etc/airtime/airtime.conf', true);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
}
catch(Exception $e){
} // Database config
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
if (PEAR::isError($CC_DBC)) { if (PEAR::isError($CC_DBC)) {
echo "New Airtime Install.".PHP_EOL; echo "New Airtime Install.".PHP_EOL;
} }