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); exit(1); } if (isset($opts->h)) { printUsage($opts); exit(1); } // 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; require_once("airtime-upgrade.php"); 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. // ------------------------------------------------------------------------- if(is_null($version)) { $newInstall = true; } $db_install = true; if (is_null($opts->r) && isset($opts->n)) { $db_install = false; } $overwrite = false; if (isset($opts->o) || $newInstall == true) { $overwrite = true; } else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) { if (AirtimeIni::IniFilesExist()) { $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) "; $userAnswer = trim(fgets(STDIN)); } if (in_array($userAnswer, array("o", "O"))) { $overwrite = true; } } else { $overwrite = true; } } if ($overwrite) { echo "* Creating INI files".PHP_EOL; AirtimeIni::CreateIniFiles(); } AirtimeInstall::InstallPhpCode(); AirtimeInstall::InstallBinaries(); if ($overwrite) { echo "* Initializing INI files".PHP_EOL; AirtimeIni::UpdateIniFiles(); } // Update the build.properties file to point to the correct directory. AirtimeIni::UpdateIniValue(AirtimeInstall::CONF_DIR_WWW.'/build/build.properties', 'project.home', AirtimeInstall::CONF_DIR_WWW); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL; AirtimeInstall::InstallStorageDirectory(); if ($db_install) { if($newInstall) { // This is called with "system" so that we can pass in a parameter. See the file itself // for why we need to do this. system('php '.__DIR__.'/airtime-db-install.php y'); AirtimeInstall::DbConnect(true); } else { require_once('airtime-db-install.php'); } } AirtimeInstall::CreateSymlinksToUtils(); AirtimeInstall::CreateZendPhpLogFile(); AirtimeInstall::CreateCronFile(); /* FINISHED AIRTIME PHP INSTALLER */