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

more checks for a new install, reinstalling.
This commit is contained in:
Naomi 2011-05-20 12:25:50 -04:00
parent 5065b1807f
commit 62a54da1e3
2 changed files with 26 additions and 5 deletions

View File

@ -15,6 +15,7 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.
AirtimeInstall::ExitIfNotRoot();
$newInstall = false;
$version = AirtimeInstall::CheckForVersionBeforeInstall();
require_once('Zend/Loader/Autoloader.php');
@ -41,23 +42,31 @@ if (isset($opts->h)) {
exit;
}
//the current version exists.
if(isset($version) && $version != false && $version == AIRTIME_VERSION && !isset($opts->r)) {
echo "Airtime $version is already installed.".PHP_EOL;
exit();
}
//a previous version exists.
if(isset($version) && $version != false && $version < AIRTIME_VERSION) {
echo "Airtime version $version found.".PHP_EOL;
$command = "php airtime-upgrade.php";
system($command);
exit();
}
if(is_null($version)) {
$newInstall = true;
}
$db_install = true;
if (is_null($opts->r) && isset($opts->n)){
if (is_null($opts->r) && isset($opts->n) && !$newInstall){
$db_install = false;
}
$overwrite = false;
if (isset($opts->o)) {
if (isset($opts->o) || $newInstall == true) {
$overwrite = true;
}
else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
@ -94,7 +103,12 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php')
echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
if ($db_install) {
require_once('airtime-db-install.php');
if($newInstall) {
system('php airtime-db-install.php y');
}
else {
require_once('airtime-db-install.php');
}
}
AirtimeInstall::InstallStorageDirectory();

View File

@ -38,7 +38,13 @@ class AirtimeInstall
{
global $CC_DBC, $CC_CONFIG;
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
if(file_exists('/etc/airtime/airtime.conf')) {
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
}
else {
echo "New Airtime Install.".PHP_EOL;
return null;
}
// Database config
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
@ -50,6 +56,7 @@ class AirtimeInstall
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
if (PEAR::isError($CC_DBC)) {
echo "New Airtime Install.".PHP_EOL;
return null;
}
else {
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);