Merge branch 'cc-5709-airtime-analyzer' into cc-5709-airtime-analyzer-saas
Conflicts: airtime_mvc/locale/cs_CZ/LC_MESSAGES/airtime.po airtime_mvc/locale/de_AT/LC_MESSAGES/airtime.po airtime_mvc/locale/de_DE/LC_MESSAGES/airtime.po airtime_mvc/locale/el_GR/LC_MESSAGES/airtime.po airtime_mvc/locale/en_CA/LC_MESSAGES/airtime.po airtime_mvc/locale/en_GB/LC_MESSAGES/airtime.po airtime_mvc/locale/en_US/LC_MESSAGES/airtime.po airtime_mvc/locale/es_ES/LC_MESSAGES/airtime.po airtime_mvc/locale/fr_FR/LC_MESSAGES/airtime.po airtime_mvc/locale/hr_HR/LC_MESSAGES/airtime.po airtime_mvc/locale/hu_HU/LC_MESSAGES/airtime.po airtime_mvc/locale/it_IT/LC_MESSAGES/airtime.po airtime_mvc/locale/ko_KR/LC_MESSAGES/airtime.po airtime_mvc/locale/nl_NL/LC_MESSAGES/airtime.po airtime_mvc/locale/pl_PL/LC_MESSAGES/airtime.po airtime_mvc/locale/pt_BR/LC_MESSAGES/airtime.po airtime_mvc/locale/ru_RU/LC_MESSAGES/airtime.po airtime_mvc/locale/sr_RS/LC_MESSAGES/airtime.po airtime_mvc/locale/sr_RS@latin/LC_MESSAGES/airtime.po airtime_mvc/locale/template/airtime.po airtime_mvc/locale/zh_CN/LC_MESSAGES/airtime.po
This commit is contained in:
commit
446eca057c
20 changed files with 257 additions and 71 deletions
|
@ -18,4 +18,9 @@ class IndexController extends Zend_Controller_Action
|
|||
$this->_helper->layout->setLayout('layout');
|
||||
}
|
||||
|
||||
public function maintenanceAction()
|
||||
{
|
||||
$this->getResponse()->setHttpResponseCode(503);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,14 @@ class UpgradeController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
//Disable Airtime UI
|
||||
//create a temporary maintenance notification file
|
||||
//when this file is on the server, zend framework redirects all
|
||||
//requests to the maintenance page and sets a 503 response code
|
||||
$maintenanceFile = '/tmp/maintenance.txt';
|
||||
$file = fopen($maintenanceFile, 'w');
|
||||
fclose($file);
|
||||
|
||||
//Begin upgrade
|
||||
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
||||
$values = parse_ini_file($filename, true);
|
||||
|
@ -69,6 +77,46 @@ class UpgradeController extends Zend_Controller_Action
|
|||
$file = new SplFileObject($iniFile, "w");
|
||||
$file->fwrite($beginning."\n".$newLines.$end);
|
||||
|
||||
$iniFile = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."application.ini" : "/usr/share/airtime/application/configs/application.ini";
|
||||
|
||||
//update application.ini
|
||||
$newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH '/modules'\n".
|
||||
"resources.frontController.plugins.putHandler = 'Zend_Controller_Plugin_PutHandler'\n".
|
||||
";load everything in the modules directory including models\n".
|
||||
"resources.modules[] = ''\n";
|
||||
|
||||
$currentIniFile = file_get_contents($iniFile);
|
||||
|
||||
/* We want to add the new lines immediately after the first line, '[production]'
|
||||
* We read the first line into $beginning, and the rest of the file into $end.
|
||||
* Then overwrite the current application.ini file with $beginning, $newLines, and $end
|
||||
*/
|
||||
$lines = explode("\n", $currentIniFile);
|
||||
$beginning = implode("\n", array_slice($lines, 0,1));
|
||||
|
||||
//check that first line is '[production]'
|
||||
if ($beginning != '[production]') {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
||||
return;
|
||||
}
|
||||
$end = implode("\n", array_slice($lines, 1));
|
||||
|
||||
if (!is_writeable($iniFile)) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
||||
return;
|
||||
}
|
||||
$file = new SplFileObject($iniFile, "w");
|
||||
$file->fwrite($beginning."\n".$newLines.$end);
|
||||
|
||||
//delete maintenance.txt to give users access back to Airtime
|
||||
unlink($maintenanceFile);
|
||||
|
||||
//TODO: clear out the cache
|
||||
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
||||
|
@ -104,12 +152,12 @@ class UpgradeController extends Zend_Controller_Action
|
|||
->findOne();
|
||||
$airtime_version = $pref->getValStr();
|
||||
|
||||
if ($airtime_version != '2.5.2') {
|
||||
if ($airtime_version != '2.5.2' || $airtime_version != '2.5.1') {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody("Upgrade to Airtime 2.5.3 FAILED. You must be using Airtime 2.5.2 to upgrade.");
|
||||
->appendBody("Upgrade to Airtime 2.5.3 FAILED. You must be using Airtime 2.5.1 or 2.5.2 to upgrade.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
15
airtime_mvc/application/controllers/plugins/Maintenance.php
Normal file
15
airtime_mvc/application/controllers/plugins/Maintenance.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
class Zend_Controller_Plugin_Maintenance extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
protected $maintenanceFile = '/tmp/maintenance.txt';
|
||||
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request) {
|
||||
if (file_exists($this->maintenanceFile)) {
|
||||
$request->setModuleName('default')
|
||||
->setControllerName('index')
|
||||
->setActionName('maintenance')
|
||||
->setDispatched(true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue