Permalink
Browse files

Fixes for code review #84

  • Loading branch information...
dpsommer committed Jan 15, 2015
1 parent b144a92 commit 791466b02362557a6af2a05c05b2d432b9b4f9e4
Showing with 347 additions and 304 deletions.
  1. +9 −0 airtime_mvc/application/Bootstrap.php
  2. +0 −3 airtime_mvc/application/configs/conf.php
  3. +12 −22 airtime_mvc/application/controllers/UpgradeController.php
  4. +6 −0 airtime_mvc/application/models/Cache.php
  5. +3 −3 airtime_mvc/application/models/Systemstatus.php
  6. +27 −0 airtime_mvc/application/upgrade/Upgrades.php
  7. +4 −4 airtime_mvc/build/airtime-setup/forms/database-settings.php
  8. +0 −4 airtime_mvc/build/airtime-setup/forms/finish-settings.php
  9. +5 −5 airtime_mvc/build/airtime-setup/forms/rabbitmq-settings.php
  10. +212 −212 airtime_mvc/build/airtime.example.conf
  11. +10 −1 airtime_mvc/public/setup/media-setup.php
  12. +2 −2 dev_tools/toggle-pypo-debug.sh
  13. +1 −10 install
  14. +0 −3 installer/lib/requirements-debian-wheezy.apt
  15. +0 −3 installer/lib/requirements-ubuntu-saucy.apt
  16. +0 −3 installer/lib/requirements-ubuntu-trusty.apt
  17. 0 python_apps/media-monitor/install/{airtime-media-monitor.conf → airtime-media-monitor.conf.template}
  18. +1 −1 python_apps/media-monitor/media-monitor2/media/saas/airtimeinstance.py
  19. +14 −1 python_apps/media-monitor/setup.py
  20. 0 python_apps/pypo/install/{airtime-liquidsoap.conf → airtime-liquidsoap.conf.template}
  21. 0 python_apps/pypo/install/{airtime-playout.conf → airtime-playout.conf.template}
  22. +4 −4 python_apps/pypo/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py
  23. +1 −1 python_apps/pypo/pypo/pyponotify.py
  24. +7 −7 python_apps/pypo/pypo/recorder.py
  25. +15 −1 python_apps/pypo/setup.py
  26. +14 −14 uninstall
@@ -21,6 +21,7 @@
require_once "Auth.php";
require_once __DIR__ . '/forms/helpers/ValidationTypes.php';
require_once __DIR__ . '/controllers/plugins/RabbitMqPlugin.php';
require_once __DIR__ . '/upgrade/Upgrades.php';
require_once (APPLICATION_PATH . "logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
@@ -76,6 +77,14 @@ private function _initTranslationGlobals($view) {
$view->headScript()->appendScript("var USER_MANUAL_URL = '" . USER_MANUAL_URL . "';");
$view->headScript()->appendScript("var COMPANY_NAME = '" . COMPANY_NAME . "';");
}
protected function _initUpgrade() {
Logging::info("Checking if upgrade is needed...");
if (AIRTIME_CODE_VERSION > Application_Model_Preference::GetAirtimeVersion()) {
$upgradeManager = new UpgradeManager();
$upgradeManager->runUpgrades(array(new AirtimeUpgrader252()), (__DIR__ . "/controllers"));
}
}
protected function _initHeadLink()
{
@@ -38,9 +38,6 @@ public static function loadConfig() {
$CC_CONFIG['cache_ahead_hours'] = $values['general']['cache_ahead_hours'];
$CC_CONFIG['monit_user'] = $values['monit']['monit_user'];
$CC_CONFIG['monit_password'] = $values['monit']['monit_password'];
// Database config
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
@@ -20,35 +20,25 @@ public function indexAction()
array_push($upgraders, new AirtimeUpgrader254());
*/
$didWePerformAnUpgrade = false;
try
{
for ($i = 0; $i < count($upgraders); $i++)
{
$upgrader = $upgraders[$i];
if ($upgrader->checkIfUpgradeSupported())
{
// pass __DIR__ to the upgrades, since __DIR__ returns parent dir of file, not executor
$upgrader->upgrade(__DIR__); //This will throw an exception if the upgrade fails.
$didWePerformAnUpgrade = true;
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK<br>");
$i = 0; //Start over, in case the upgrade handlers are not in ascending order.
}
}
try {
$upgradeManager = new UpgradeManager();
$didWePerformAnUpgrade = $upgradeManager->runUpgrades($upgraders, __DIR__);
if (!$didWePerformAnUpgrade)
{
if (!$didWePerformAnUpgrade) {
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".<br>");
} else {
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".<br>");
->setHttpResponseCode(200)
->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK<br>");
}
}
catch (Exception $e)
{
$this->getResponse()
->setHttpResponseCode(400)
->appendBody($e->getMessage());
->setHttpResponseCode(400)
->appendBody($e->getMessage());
}
}
@@ -28,4 +28,10 @@ public function fetch($key, $isUserValue, $userId = null) {
//$cacheKey = self::createCacheKey($key, $isUserValue, $userId);
return false; //apc_fetch($cacheKey);
}
public static function clear() {
// Disabled on SaaS
// apc_clear_cache('user');
// apc_clear_cache();
}
}
@@ -6,15 +6,15 @@ class Application_Model_Systemstatus
public static function GetMonitStatus($p_ip)
{
$CC_CONFIG = Config::getConfig();
$monit_user = $CC_CONFIG['monit_user'];
$monit_password = $CC_CONFIG['monit_password'];
// $monit_user = $CC_CONFIG['monit_user'];
// $monit_password = $CC_CONFIG['monit_password'];
$url = "http://$p_ip:2812/_status?format=xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$monit_user:$monit_password");
// curl_setopt($ch, CURLOPT_USERPWD, "$monit_user:$monit_password");
//wait a max of 3 seconds before aborting connection attempt
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
$result = curl_exec($ch);
@@ -1,5 +1,32 @@
<?php
class UpgradeManager {
/**
* Run a given set of upgrades
*
* @param array $upgraders the upgrades to perform
* @param string $dir the directory containing the upgrade sql
* @return boolean whether or not an upgrade was performed
*/
public function runUpgrades($upgraders, $dir) {
$upgradePerformed;
for($i = 0; $i < count($upgraders); $i++) {
$upgrader = $upgraders[$i];
if ($upgrader->checkIfUpgradeSupported()) {
// pass the given directory to the upgrades, since __DIR__ returns parent dir of file, not executor
$upgrader->upgrade($dir); // This will throw an exception if the upgrade fails.
$upgradePerformed = true;
$i = 0; // Start over, in case the upgrade handlers are not in ascending order.
}
}
return $upgradePerformed;
}
}
abstract class AirtimeUpgrader
{
/** Versions that this upgrader class can upgrade from (an array of version strings). */
@@ -16,25 +16,25 @@
<div class="form-group">
<label class="control-label" for="dbUser">Username</label>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username"
value=<?php echo (isset($db) ? $db["dbuser"] : "airtime"); ?>/>
value="<?php echo (isset($db) ? $db["dbuser"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbPass">Password</label>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password"
value=<?php echo (isset($db) ? $db["dbpass"] : "airtime"); ?>/>
value="<?php echo (isset($db) ? $db["dbpass"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbName">Name</label>
<input required class="form-control" type="text" name="dbName" id="dbName" placeholder="Name"
value=<?php echo (isset($db) ? $db["dbname"] : "airtime"); ?>/>
value="<?php echo (isset($db) ? $db["dbname"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbHost">Host</label>
<input required class="form-control" type="text" name="dbHost" id="dbHost" placeholder="Host"
value=<?php echo (isset($db) ? $db["host"] : "localhost"); ?>/>
value="<?php echo (isset($db) ? $db["host"] : "localhost"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="dbErr" id="dbErr" aria-describedby="helpBlock"/>
@@ -1,8 +1,4 @@
<?php
$tempConfigPath = "/etc/airtime/airtime.conf.tmp";
if (file_exists($tempConfigPath)) {
rename($tempConfigPath, "/etc/airtime/airtime.conf.bak");
}
?>
<form action="#" role="form" id="finishSettingsForm">
@@ -25,13 +25,13 @@
<div class="form-group">
<label class="control-label" for="rmqUser">Username</label>
<input required class="form-control" type="text" name="rmqUser" id="rmqUser" placeholder="Username"
value=<?php echo (isset($rmq) ? $rmq["user"] : "airtime"); ?>/>
value="<?php echo (isset($rmq) ? $rmq["user"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPass">Password</label>
<input class="form-control" type="password" name="rmqPass" id="rmqPass" placeholder="Password"
value=<?php echo (isset($rmq) ? $rmq["password"] : "airtime"); ?>/>
value="<?php echo (isset($rmq) ? $rmq["password"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="rmqHelpBlock" class="help-block">
You probably want to change this!
@@ -40,19 +40,19 @@
<div class="form-group">
<label class="control-label" for="rmqHost">Host</label>
<input required class="form-control" type="text" name="rmqHost" id="rmqHost" placeholder="Host"
value=<?php echo (isset($rmq) ? $rmq["host"] : "127.0.0.1"); ?>/>
value="<?php echo (isset($rmq) ? $rmq["host"] : "127.0.0.1"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPort">Port</label>
<input required class="form-control" type="text" name="rmqPort" id="rmqPort" placeholder="Port"
value=<?php echo (isset($rmq) ? $rmq["port"] : "5672"); ?>/>
value="<?php echo (isset($rmq) ? $rmq["port"] : "5672"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqVHost">Virtual Host</label>
<input required class="form-control" type="text" name="rmqVHost" id="rmqVHost" placeholder="VHost"
value=<?php echo (isset($rmq) ? $rmq["vhost"] : "/airtime"); ?>/>
value="<?php echo (isset($rmq) ? $rmq["vhost"] : "/airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="rmqErr" id="rmqErr" aria-describedby="helpBlock"/>
Oops, something went wrong.

0 comments on commit 791466b

Please sign in to comment.