CC-3048: Install_minimal should check much sooner if Airtime is already installed

- fixed by creating new php file airtime-installed-check, which checks whether current version
of airtime exists; this file gets called right after root user check and whether debian
package exists check
- moved some code from airtime-install.php to AirtimeInstall.php as static functions
so that we reduce duplicated code
- both the new file airtime-installed-check.php and airtime-install.php use the new
static functions created above
This commit is contained in:
Yuchen Wang 2011-11-18 14:06:42 -05:00
parent c04e6dcc75
commit db82e51c30
4 changed files with 79 additions and 51 deletions

View file

@ -5,58 +5,19 @@
* @license http://www.gnu.org/licenses/gpl.txt
*
* Checks if a previous version of Airtime is currently installed and 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.
* Performs a new install (new configs, database install) otherwise.
*/
set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
require_once(dirname(__FILE__).'/AirtimeIni.php');
require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
AirtimeInstall::ExitIfNotRoot();
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
function printUsage($opts)
{
$msg = $opts->getUsageMessage();
echo PHP_EOL."Usage: airtime-install [options]";
echo substr($msg, strpos($msg, "\n")).PHP_EOL;
}
try {
$opts = new Zend_Console_Getopt(
array(
'help|h' => 'Displays usage information.',
'overwrite|o' => 'Overwrite any existing config files.',
'preserve|p' => 'Keep any existing config files.',
'no-db|n' => 'Turn off database install.',
'reinstall|r' => 'Force a fresh install of this Airtime Version'
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
print $e->getMessage() .PHP_EOL;
printUsage($opts);
$opts = AirtimeInstall::getOpts();
if ($opts == NULL) {
exit(1);
}
if (isset($opts->h)) {
printUsage($opts);
exit(0);
}
$version = AirtimeInstall::GetVersionInstalled();
// The current version is already installed.
if (isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime $version is already installed.".PHP_EOL;
printUsage($opts);
exit(1);
}
// A previous version exists - if so, upgrade.
if (isset($version) && ($version != false) && ($version < AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime version $version found.".PHP_EOL;
@ -65,11 +26,6 @@ if (isset($version) && ($version != false) && ($version < AIRTIME_VERSION) && !i
exit(0);
}
if($version === false){
echo "A version of Airtime older than 1.7.0 detected, please upgrade to 1.7.0 first.\n";
echo "You will then be able to upgrade to 1.9.0 using this installer.\n";
exit(3);
}
// -------------------------------------------------------------------------
// The only way we get here is if we are doing a new install or a reinstall.
// -------------------------------------------------------------------------