From e90a3269c234f3ea8a9ffd5ecc1866f528c15a34 Mon Sep 17 00:00:00 2001 From: Paul Baranowski Date: Tue, 24 May 2011 21:27:33 -0400 Subject: [PATCH] CC-2281 Install script should check for pre-installed versions and prompt user to upgrade/full installation Hand-merged Naomi's last 3 changes from the branch. --- install/airtime-install.php | 18 ++++++++++-------- install/include/AirtimeInstall.php | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/install/airtime-install.php b/install/airtime-install.php index 677ed1192..7d241197a 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -3,6 +3,10 @@ * @package Airtime * @copyright 2011 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt + * + * Checks if a previous version of Airtime is currently installed, upgrades Airtime if so. + * Performs a new install (new configs, database install) if a version of Airtime is not found + * If the current version is found to be installed the User is presented with the help menu and can choose -r to reinstall. */ set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path()); @@ -16,7 +20,7 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants. AirtimeInstall::ExitIfNotRoot(); $newInstall = false; -$version = AirtimeInstall::CheckForVersionBeforeInstall(); +$version = AirtimeInstall::GetVersionInstalled(); require_once('Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance(); @@ -43,17 +47,15 @@ if (isset($opts->h)) { } //the current version exists. -if(isset($version) && $version != false && $version == AIRTIME_VERSION && !isset($opts->r)) { - +if(isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) { echo "Airtime $version is already installed.".PHP_EOL; + echo $opts->getUsageMessage(); exit(); } //a previous version exists. -if(isset($version) && $version != false && $version < AIRTIME_VERSION) { - +if(isset($version) && ($version != false) && ($version < AIRTIME_VERSION)) { echo "Airtime version $version found.".PHP_EOL; - $command = "php airtime-upgrade.php"; - system($command); + require_once("airtime-upgrade.php"); exit(); } if(is_null($version)) { @@ -61,7 +63,7 @@ if(is_null($version)) { } $db_install = true; -if (is_null($opts->r) && isset($opts->n) && !$newInstall){ +if (is_null($opts->r) && isset($opts->n)){ $db_install = false; } diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index b56eb7aab..176f3f2ba 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -34,7 +34,7 @@ class AirtimeInstall } } - public static function CheckForVersionBeforeInstall() + public static function GetVersionInstalled() { global $CC_DBC, $CC_CONFIG;