From 5e02a46a24d110c8dbd1b89d371b55e5d4770348 Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 19 May 2011 15:05:33 -0400 Subject: [PATCH] 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. --- install/airtime-install.php | 10 +++++++--- install/include/AirtimeInstall.php | 13 ++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/install/airtime-install.php b/install/airtime-install.php index 6f4a51557..037f520e4 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -16,9 +16,10 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants. AirtimeInstall::ExitIfNotRoot(); $version = AirtimeInstall::CheckForVersionBeforeInstall(); +$turnOffPreserve = false; -echo "Airtime version $version found.".PHP_EOL; -echo "Airtime version ".AIRTIME_VERSION." found.".PHP_EOL; +//echo "Airtime version $version found.".PHP_EOL; +//echo "Airtime version ".AIRTIME_VERSION." found.".PHP_EOL; require_once('Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance(); @@ -51,6 +52,9 @@ if(isset($version) && $version != false && $version < AIRTIME_VERSION) { system($command); exit(); } + else if (in_array($userAnswer, array("i", "I"))) { + $turnOffPreserve = true; + } } try { @@ -81,7 +85,7 @@ if (isset($opts->o)) { $overwrite = true; } else if (!isset($opts->p) && !isset($opts->o)) { - if (AirtimeIni::IniFilesExist()) { + if (AirtimeIni::IniFilesExist() && !$turnOffPreserve) { $userAnswer = "x"; 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) "; diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index b515ddf9f..668cf74ca 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -38,13 +38,16 @@ class AirtimeInstall { global $CC_DBC, $CC_CONFIG; - try{ - $CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE); - } - catch(Exception $e){ + $values = parse_ini_file('/etc/airtime/airtime.conf', true); - } + // 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)) { echo "New Airtime Install.".PHP_EOL; }