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
|
|
|
|
2013-10-25 16:39:00 +02:00
|
|
|
//Enforce a minimum PHP version
|
|
|
|
if (!AirtimeInstall::checkPHPVersion())
|
|
|
|
{
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-10-31 17:17:40 +01:00
|
|
|
echo "******************************** Upgrade Begin *********************************".PHP_EOL;
|
2011-03-09 19:23:05 +01:00
|
|
|
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-05-16 19:18:51 +02:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2014-04-25 18:19:18 +02:00
|
|
|
// Stop media-monitor and disable it -- Airtime 2.5.3+
|
|
|
|
@exec("service media-monitor stop-with-monit");
|
|
|
|
@exec("rm /etc/init.d/airtime-media-monitor");
|
|
|
|
|
2014-04-23 18:21:39 +02:00
|
|
|
|
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.2.0") < 0) {
|
2013-04-18 22:09:09 +02:00
|
|
|
echo "Unsupported Airtime version. You must upgrade from at least Airtime 2.2.0.".PHP_EOL;
|
|
|
|
exit(1);
|
2013-01-14 22:16:14 +01:00
|
|
|
}
|
2012-12-03 17:06:56 +01:00
|
|
|
if (strcmp($version, "2.2.1") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.2.1/airtime-upgrade.php");
|
|
|
|
pause();
|
2013-01-15 18:31:41 +01:00
|
|
|
}
|
|
|
|
if (strcmp($version, "2.3.0") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.3.0/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2013-03-05 23:00:52 +01:00
|
|
|
if (strcmp($version, "2.3.1") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.3.1/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2013-04-26 19:43:40 +02:00
|
|
|
if (strcmp($version, "2.4.0") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.4.0/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2013-08-28 18:14:27 +02:00
|
|
|
if (strcmp($version, "2.4.1") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.4.1/airtime-upgrade.php");
|
|
|
|
pause();
|
2013-08-28 18:13:24 +02:00
|
|
|
}
|
2013-08-31 22:50:40 +02:00
|
|
|
if (strcmp($version, "2.5.0") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.0/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2013-12-10 16:55:39 +01:00
|
|
|
if (strcmp($version, "2.5.1") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.1/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2014-04-07 17:58:58 +02:00
|
|
|
if (strcmp($version, "2.5.3") < 0) {
|
|
|
|
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.3/airtime-upgrade.php");
|
|
|
|
pause();
|
|
|
|
}
|
2011-10-31 17:17:40 +01:00
|
|
|
echo "******************************* Upgrade Complete *******************************".PHP_EOL;
|