2011-02-28 19:27:12 +01:00
|
|
|
<?php
|
2011-03-09 19:23:05 +01:00
|
|
|
/**
|
|
|
|
* @package Airtime
|
|
|
|
* @subpackage StorageServer
|
|
|
|
* @copyright 2010 Sourcefabric O.P.S.
|
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt
|
|
|
|
*/
|
2012-09-07 06:16:38 +02:00
|
|
|
if (posix_geteuid() != 0) {
|
2011-05-18 22:48:45 +02:00
|
|
|
echo "Must be root user.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-04-02 05:39:15 +02:00
|
|
|
require_once(__DIR__.'/airtime-constants.php');
|
|
|
|
require_once(__DIR__.'/AirtimeIni.php');
|
|
|
|
require_once(__DIR__.'/AirtimeInstall.php');
|
2012-09-07 06:16:38 +02:00
|
|
|
require_once 'propel/runtime/lib/Propel.php';
|
2012-04-20 21:06:20 +02:00
|
|
|
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/db-conf.php");
|
2012-09-07 06:16:38 +02:00
|
|
|
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
2012-04-02 05:39:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
function pause()
|
|
|
|
{
|
2011-11-23 22:49:03 +01:00
|
|
|
/* Type "sudo -s" to change to root user then type "export AIRTIME_INSTALL_DEBUG=1" and then
|
|
|
|
* start airtime-install to enable this feature. Is used to pause between upgrade scripts
|
|
|
|
* to examine the state of the system and see if everything is as expected. */
|
2012-09-07 06:16:38 +02:00
|
|
|
if (getenv("AIRTIME_INSTALL_DEBUG") === "1") {
|
2011-11-23 19:59:10 +01:00
|
|
|
echo "Press Enter to Continue".PHP_EOL;
|
|
|
|
fgets(STDIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-02 05:39:15 +02:00
|
|
|
AirtimeInstall::DbConnect(true);
|
|
|
|
$con = Propel::getConnection();
|
2011-05-18 22:48:45 +02:00
|
|
|
|
2011-08-02 12:56:39 +02:00
|
|
|
$version = AirtimeInstall::GetVersionInstalled();
|
2011-04-12 18:43:25 +02:00
|
|
|
|
2011-10-31 17:17:40 +01:00
|
|
|
echo "******************************** Upgrade Begin *********************************".PHP_EOL;
|
2011-03-09 19:23:05 +01:00
|
|
|
|
2012-05-16 19:18:51 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$user = $CC_CONFIG['dsn']['username'];
|
|
|
|
$password = $CC_CONFIG['dsn']['password'];
|
|
|
|
$host = $CC_CONFIG['dsn']['hostspec'];
|
|
|
|
$database = $CC_CONFIG['dsn']['database'];
|
|
|
|
$airtime_version = AIRTIME_VERSION;
|
|
|
|
|
|
|
|
$target_dir = trim(getenv("HOME"));
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strlen($target_dir) == 0) {
|
2012-05-16 19:18:51 +02:00
|
|
|
$target_dir = "/tmp";
|
|
|
|
}
|
|
|
|
|
|
|
|
$target_file = "/airtime_$airtime_version.sql";
|
|
|
|
$target_path = $target_dir.$target_file;
|
|
|
|
echo "* Backing up current database to $target_path".PHP_EOL;
|
|
|
|
exec("export PGPASSWORD=$password && pg_dump -h $host -U $user -f $target_path $database", $arr, $return_code);
|
2012-09-07 06:16:38 +02:00
|
|
|
if ($return_code == 0) {
|
2012-05-16 19:18:51 +02:00
|
|
|
echo " * Success".PHP_EOL;
|
|
|
|
} else {
|
|
|
|
echo " * Failed".PHP_EOL;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-06-02 17:09:49 +02:00
|
|
|
//convert strings like 1.9.0-devel to 1.9.0
|
|
|
|
$version = substr($version, 0, 5);
|
|
|
|
|
2011-09-14 22:15:59 +02:00
|
|
|
$SCRIPTPATH = __DIR__;
|
|
|
|
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.0.0") < 0) {
|
|
|
|
echo "Unsupported Airtime version. You must upgrade from at least Airtime 2.0.0.".PHP_EOL;
|
2012-05-03 22:34:54 +02:00
|
|
|
exit(1);
|
2011-06-01 23:19:28 +02:00
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.0.1") < 0) {
|
2012-02-12 06:42:02 +01:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.1/airtime-upgrade.php");
|
2012-02-11 17:56:19 +01:00
|
|
|
pause();
|
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.0.2") < 0) {
|
2012-02-24 22:30:12 +01:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.2/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.0.3") < 0) {
|
2012-04-03 01:04:16 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.3/airtime-upgrade.php");
|
2012-04-02 23:28:58 +02:00
|
|
|
pause();
|
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.1.0") < 0) {
|
2012-04-13 01:08:55 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.0/airtime-upgrade.php");
|
2012-06-13 17:35:14 +02:00
|
|
|
pause();
|
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.1.1") < 0) {
|
2012-06-13 17:35:14 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.1/airtime-upgrade.php");
|
|
|
|
pause();
|
2012-04-13 01:08:55 +02:00
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.1.2") < 0) {
|
2012-06-18 05:38:36 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.2/airtime-upgrade.php");
|
|
|
|
pause();
|
2012-07-03 22:43:10 +02:00
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.1.3") < 0) {
|
2012-07-03 22:43:10 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.3/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2012-09-07 06:16:38 +02:00
|
|
|
if (strcmp($version, "2.2.0") < 0) {
|
2012-08-20 22:06:11 +02:00
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.2.0/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2011-10-31 17:17:40 +01:00
|
|
|
echo "******************************* Upgrade Complete *******************************".PHP_EOL;
|