CC-5802: Upgrade application.ini file
Execute raw sql upgrade file at the end in case errors occured during the upgrade before it gets executed
This commit is contained in:
parent
1009719e1c
commit
f432ea9f75
|
@ -27,19 +27,10 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
$maintenanceFile = '/tmp/maintenance.txt';
|
$maintenanceFile = '/tmp/maintenance.txt';
|
||||||
$file = fopen($maintenanceFile, 'w');
|
$file = fopen($maintenanceFile, 'w');
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
||||||
//Begin upgrade
|
//Begin upgrade
|
||||||
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
|
||||||
$values = parse_ini_file($filename, true);
|
|
||||||
|
|
||||||
$username = $values['database']['dbuser'];
|
|
||||||
$password = $values['database']['dbpass'];
|
|
||||||
$host = $values['database']['host'];
|
|
||||||
$database = $values['database']['dbname'];
|
|
||||||
$dir = __DIR__;
|
|
||||||
|
|
||||||
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_$airtime_upgrade_version/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
|
|
||||||
|
|
||||||
|
//Update disk_usage value in cc_pref
|
||||||
$musicDir = CcMusicDirsQuery::create()
|
$musicDir = CcMusicDirsQuery::create()
|
||||||
->filterByType('stor')
|
->filterByType('stor')
|
||||||
->filterByExists(true)
|
->filterByExists(true)
|
||||||
|
@ -50,14 +41,14 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
$totalSpace = disk_total_space($storPath);
|
$totalSpace = disk_total_space($storPath);
|
||||||
|
|
||||||
Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace);
|
Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace);
|
||||||
|
|
||||||
$iniFile = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."application.ini" : "/usr/share/airtime/application/configs/application.ini";
|
$iniFile = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."application.ini" : "/usr/share/airtime/application/configs/application.ini";
|
||||||
|
|
||||||
//update application.ini
|
//update application.ini
|
||||||
$newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH '/modules'\n".
|
$newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH \"/modules\"\n".
|
||||||
"resources.frontController.plugins.putHandler = 'Zend_Controller_Plugin_PutHandler'\n".
|
"resources.frontController.plugins.putHandler = \"Zend_Controller_Plugin_PutHandler\"\n".
|
||||||
";load everything in the modules directory including models\n".
|
";load everything in the modules directory including models\n".
|
||||||
"resources.modules[] = ''\n";
|
"resources.modules[] = \"\"\n";
|
||||||
|
|
||||||
$currentIniFile = file_get_contents($iniFile);
|
$currentIniFile = file_get_contents($iniFile);
|
||||||
|
|
||||||
|
@ -79,7 +70,8 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
$file = new SplFileObject($iniFile, "w");
|
$file = new SplFileObject($iniFile, "w");
|
||||||
$file->fwrite($beginning."\n".$newLines.$end);
|
$file->fwrite($beginning."\n".$newLines.$end);
|
||||||
|
|
||||||
|
|
||||||
//delete maintenance.txt to give users access back to Airtime
|
//delete maintenance.txt to give users access back to Airtime
|
||||||
unlink($maintenanceFile);
|
unlink($maintenanceFile);
|
||||||
|
|
||||||
|
@ -87,6 +79,19 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
|
|
||||||
$con->commit();
|
$con->commit();
|
||||||
|
|
||||||
|
$airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
||||||
|
$values = parse_ini_file($airtimeConf, true);
|
||||||
|
|
||||||
|
//update system_version in cc_pref and change some columns in cc_files
|
||||||
|
$username = $values['database']['dbuser'];
|
||||||
|
$password = $values['database']['dbpass'];
|
||||||
|
$host = $values['database']['host'];
|
||||||
|
$database = $values['database']['dbname'];
|
||||||
|
$dir = __DIR__;
|
||||||
|
|
||||||
|
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_$airtime_upgrade_version/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
|
||||||
|
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(200)
|
->setHttpResponseCode(200)
|
||||||
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
||||||
|
|
Loading…
Reference in New Issue