From 61df7c1a4486a452656c8cc4f4ec54a63b9045fc Mon Sep 17 00:00:00 2001 From: drigato Date: Fri, 25 Apr 2014 14:20:04 -0400 Subject: [PATCH 1/2] Moved some comments around --- airtime_mvc/application/controllers/UpgradeController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index 78a4126e8..b7d89170e 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -42,9 +42,9 @@ class UpgradeController extends Zend_Controller_Action Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace); + //update application.ini $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". @@ -79,10 +79,10 @@ class UpgradeController extends Zend_Controller_Action $con->commit(); + //update system_version in cc_pref and change some columns in cc_files $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']; From 66000a2847fd8a1051aedc8d4677adfff9d7c8d2 Mon Sep 17 00:00:00 2001 From: drigato Date: Fri, 25 Apr 2014 14:53:58 -0400 Subject: [PATCH 2/2] CC-5802: Upgrade application.ini file Changed where we insert new application.ini file lines --- .../controllers/UpgradeController.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index b7d89170e..f5a7d4549 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -52,18 +52,20 @@ class UpgradeController extends Zend_Controller_Action $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 + /* We want to add the new lines after a specific line. So we must find read the file + * into an array, find the key to which our desired line belongs, and use the key + * to split the file in two halves, $beginning and $end. + * The $newLines will go inbetween $beginning and $end */ $lines = explode("\n", $currentIniFile); - $beginning = implode("\n", array_slice($lines, 0,1)); - - //check that first line is '[production]' - if ($beginning != '[production]') { - throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Invalid format'); + + $key = array_search("resources.layout.layoutPath = APPLICATION_PATH \"/layouts/scripts/\"", $lines); + if (!$key) { + throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini'); } - $end = implode("\n", array_slice($lines, 1)); + + $beginning = implode("\n", array_slice($lines, 0, $key)); + $end = implode("\n", array_slice($lines, $key)); if (!is_writeable($iniFile)) { throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Permission denied.');