Merge branch 'saas-installer-albert' into saas-dev

This commit is contained in:
Albert Santoni 2015-06-10 15:03:11 -04:00
commit c18e728583
336 changed files with 5144 additions and 10180 deletions

View file

@ -1,19 +1,19 @@
<?php
require_once __DIR__."/configs/conf.php";
require_once CONFIG_PATH . "conf.php";
$CC_CONFIG = Config::getConfig();
require_once __DIR__."/configs/ACL.php";
if (!@include_once('propel/propel1/runtime/lib/Propel.php'))
{
die('Error: Propel not found. Did you install Airtime\'s third-party dependencies with composer? (Check the README.)');
}
require_once CONFIG_PATH . "ACL.php";
Propel::init(__DIR__."/configs/airtime-conf-production.php");
// Since we initialize the database during the configuration check,
// check the $configRun global to avoid reinitializing unnecessarily
if (!isset($configRun) || !$configRun) {
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}
//Composer's autoloader
require_once 'autoload.php';
require_once __DIR__."/configs/constants.php";
require_once CONFIG_PATH . "constants.php";
require_once 'Preference.php';
require_once 'Locale.php';
require_once "DateHelper.php";
@ -34,8 +34,9 @@ require_once __DIR__.'/controllers/plugins/Maintenance.php';
require_once __DIR__.'/controllers/plugins/ConversionTracking.php';
require_once __DIR__.'/modules/rest/controllers/ShowImageController.php';
require_once __DIR__.'/modules/rest/controllers/MediaController.php';
require_once __DIR__.'/upgrade/Upgrades.php';
require_once (APPLICATION_PATH."/logging/Logging.php");
require_once (APPLICATION_PATH . "/logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
// We need to manually route because we can't load Zend without the database being initialized first.
@ -46,7 +47,7 @@ if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"
}
Config::setAirtimeVersion();
require_once __DIR__."/configs/navigation.php";
require_once (CONFIG_PATH . 'navigation.php');
Zend_Validate::setDefaultNamespaces("Zend");
@ -120,6 +121,14 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendScript("var USER_MANUAL_URL = '" . USER_MANUAL_URL . "';");
$view->headScript()->appendScript("var COMPANY_NAME = '" . COMPANY_NAME . "';");
}
protected function _initUpgrade() {
/* We need to wrap this here so that we aren't checking when we're running the unit test suite
*/
if (getenv("AIRTIME_UNIT_TEST") != 1) {
UpgradeManager::checkIfUpgradeIsNeeded(); //This will do the upgrade too if it's needed...
}
}
protected function _initHeadLink()
{
@ -224,8 +233,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
protected function _initViewHelpers()
{
$view = $this->getResource('view');
$view->addHelperPath('../application/views/helpers', 'Airtime_View_Helper');
$view->addHelperPath(APPLICATION_PATH . 'views/helpers', 'Airtime_View_Helper');
$view->assign('suspended', (Application_Model_Preference::getProvisioningStatus() == PROVISIONING_STATUS_SUSPENDED));
}
@ -238,7 +246,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
protected function _initZFDebug()
{
Zend_Controller_Front::getInstance()->throwExceptions(true);
Zend_Controller_Front::getInstance()->throwExceptions(false);
/*
if (APPLICATION_ENV == "development") {

View file

@ -0,0 +1,110 @@
<?php
// Only enable cookie secure if we are supporting https.
// Ideally, this would always be on and we would force https,
// but the default installation configs are likely to be installed by
// amature users on the setup that does not have https. Forcing
// cookie_secure on non https would result in confusing login problems.
if(!empty($_SERVER['HTTPS'])) {
ini_set('session.cookie_secure', '1');
}
ini_set('session.cookie_httponly', '1');
error_reporting(E_ALL|E_STRICT);
function exception_error_handler($errno, $errstr, $errfile, $errline) {
//Check if the statement that threw this error wanted its errors to be
//suppressed. If so then return without with throwing exception.
if (0 === error_reporting()) return;
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
return false;
}
set_error_handler("exception_error_handler");
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
defined('VERBOSE_STACK_TRACE')
|| define('VERBOSE_STACK_TRACE', (getenv('VERBOSE_STACK_TRACE') ? getenv('VERBOSE_STACK_TRACE') : true));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
realpath(LIB_PATH)
)));
set_include_path(APPLICATION_PATH . 'common' . PATH_SEPARATOR . get_include_path());
//Propel classes.
set_include_path(APPLICATION_PATH . 'models' . PATH_SEPARATOR . get_include_path());
//Controller plugins.
set_include_path(APPLICATION_PATH . 'controllers' . PATH_SEPARATOR . get_include_path());
//Controller plugins.
set_include_path(APPLICATION_PATH . 'controllers/plugins' . PATH_SEPARATOR . get_include_path());
//Zend framework
if (file_exists('/usr/share/php/libzend-framework-php')) {
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
}
//Services.
set_include_path(APPLICATION_PATH . '/services/' . PATH_SEPARATOR . get_include_path());
//cloud storage directory
set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path());
//Upgrade directory
set_include_path(APPLICATION_PATH . '/upgrade/' . PATH_SEPARATOR . get_include_path());
//Common directory
set_include_path(APPLICATION_PATH . '/common/' . PATH_SEPARATOR . get_include_path());
/** Zend_Application */
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
CONFIG_PATH . 'application.ini'
);
require_once(APPLICATION_PATH . "logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
Logging::setupParseErrorLogging();
// Create application, bootstrap, and run
try {
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cli') {
set_include_path(APPLICATION_PATH . PATH_SEPARATOR . get_include_path());
require_once("Bootstrap.php");
} else {
$application->bootstrap()->run();
}
} catch (Exception $e) {
if ($e->getCode() == 401)
{
header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized', true, 401);
return;
}
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
Logging::error($e->getMessage());
if (VERBOSE_STACK_TRACE) {
echo $e->getMessage();
echo "<pre>";
echo $e->getTraceAsString();
echo "</pre>";
Logging::info($e->getMessage());
Logging::info($e->getTraceAsString());
} else {
Logging::info($e->getTrace());
}
throw $e;
}

View file

@ -2,8 +2,6 @@
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
* /etc/airtime/airtime.conf
* /etc/airtime/pypo.cfg
* /etc/airtime/recorder.cfg
*/
class Config {
@ -37,7 +35,6 @@ class Config {
$CC_CONFIG['baseDir'] = $values['general']['base_dir'];
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
$CC_CONFIG['basePort'] = $values['general']['base_port'];
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
if (isset($values['general']['dev_env'])) {
$CC_CONFIG['dev_env'] = $values['general']['dev_env'];
} else {
@ -68,12 +65,9 @@ class Config {
// Tells us where file uploads will be uploaded to.
// It will either be set to a cloud storage backend or local file storage.
$CC_CONFIG["current_backend"] = $cloudStorageValues["current_backend"]["storage_backend"];
$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'];

View file

@ -0,0 +1,265 @@
<?php
/*
* We only get here after setup, or if there's an error in the configuration.
*
* Display a table to the user showing the necessary dependencies
* (both PHP and binary) and the status of any application services,
* along with steps to fix them if they're not found or misconfigured.
*/
$phpDependencies = checkPhpDependencies();
$externalServices = checkExternalServices();
$zend = $phpDependencies["zend"];
$postgres = $phpDependencies["postgres"];
$database = $externalServices["database"];
$rabbitmq = $externalServices["rabbitmq"];
$pypo = $externalServices["pypo"];
$liquidsoap = $externalServices["liquidsoap"];
$mediamonitor = $externalServices["media-monitor"];
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
$r2 = array_reduce($externalServices, "booleanReduce", true);
$result = $r1 && $r2;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap-3.3.1.min.css">
<link rel="stylesheet" type="text/css" href="css/setup/config-check.css">
</head>
<style>
/*
This is here because we're using the config-check css for
both this page and the system status page
*/
html {
background-color: #f5f5f5;
}
body {
padding: 2em;
min-width: 600px;
text-align: center;
margin: 3em ;
border: 1px solid lightgray;
border-radius: 5px;
}
</style>
<body>
<h2>
<img class="logo" src="css/images/airtime_logo_jp.png" /><br/>
<strong>Configuration Checklist</strong>
</h2>
<?php
if (!$result) {
?>
<br/>
<h3 class="error">Looks like something went wrong!</h3>
<p>
Take a look at the checklist below for possible solutions. If you're tried the suggestions and are
still experiencing issues, come
<a href="https://forum.sourcefabric.org/">visit our forums</a>
or <a href="http://www.sourcefabric.org/en/airtime/manuals/">check out the manual</a>.
</p>
<?php
} else {
?>
<p>
Your Airtime station is up and running! Get started by logging in with the default username and password: admin/admin
</p>
<button onclick="location = location.pathname;">Log in to Airtime!</button>
<?php
}
?>
<table class="table">
<thead>
<tr>
<th class="component">
Component
</th>
<th class="description">
<strong>Description</strong>
</th>
<th class="solution">
<strong>Status or Solution</strong>
</th>
</tr>
</thead>
</table>
<div class="checklist">
<table class="table table-striped">
<caption class="caption">
PHP Dependencies
</caption>
<tbody>
<tr class="<?=$zend ? 'success' : 'danger';?>">
<td class="component">
Zend
</td>
<td class="description">
Zend MVC Framework
</td>
<td class="solution <?php if ($zend) {echo 'check';?>">
<?php
} else {
?>">
<b>Ubuntu</b>: try running <code>sudo apt-get install libzend-framework-php</code>
<br/><b>Debian</b>: try running <code>sudo apt-get install zendframework</code>
<?php
}
?>
</td>
</tr>
<tr class="<?=$postgres ? 'success' : 'danger';?>">
<td class="component">
Postgres
</td>
<td class="description">
PDO and PostgreSQL libraries
</td>
<td class="solution <?php if ($postgres) {echo 'check';?>">
<?php
} else {
?>">
Try running <code>sudo apt-get install php5-pgsql</code>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
<table class="table table-striped">
<caption class="caption">
External Services
</caption>
<tbody>
<tr class="<?=$database ? 'success' : 'danger';?>">
<td class="component">
Database
</td>
<td class="description">
Database configuration for Airtime
</td>
<td class="solution <?php if ($database) {echo 'check';?>">
<?php
} else {
?>">
Make sure you aren't missing any of the Postgres dependencies in the table above.
If your dependencies check out, make sure your database configuration settings in
<code>/etc/airtime.conf</code> are correct and the Airtime database was installed correctly.
<?php
}
?>
</td>
</tr>
<tr class="<?=$rabbitmq ? 'success' : 'danger';?>">
<td class="component">
RabbitMQ
</td>
<td class="description">
RabbitMQ configuration for Airtime
</td>
<td class="solution <?php if ($rabbitmq) {echo 'check';?>">
<?php
} else {
?>">
Make sure RabbitMQ is installed correctly, and that your settings in /etc/airtime/airtime.conf
are correct. Try using <code>sudo rabbitmqctl list_users</code> and <code>sudo rabbitmqctl list_vhosts</code>
to see if the airtime user (or your custom RabbitMQ user) exists, then checking that
<code>sudo rabbitmqctl list_exchanges</code> contains entries for airtime-media-monitor, airtime-pypo,
and airtime-uploads.
<?php
}
?>
</td>
</tr>
<tr class="<?=$mediamonitor ? 'success' : 'danger';?>">
<td class="component">
Media Monitor
</td>
<td class="description">
Airtime media-monitor service
</td>
<td class="solution <?php if ($mediamonitor) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-media-monitor service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-media-monitor</code><br/>
If not, try running <code>sudo service airtime-media-monitor start</code>
<?php
}
?>
</td>
</tr>
<tr class="<?=$pypo ? 'success' : 'danger';?>">
<td class="component">
Pypo
</td>
<td class="description">
Airtime playout service
</td>
<td class="solution <?php if ($pypo) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-playout service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-playout</code><br/>
If not, try running <code>sudo service airtime-playout restart</code>
<?php
}
?>
</td>
</tr>
<tr class="<?=$liquidsoap ? 'success' : 'danger';?>">
<td class="component">
Liquidsoap
</td>
<td class="description">
Airtime liquidsoap service
</td>
<td class="solution <?php if ($liquidsoap) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-liquidsoap service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-liquidsoap</code><br/>
If not, try running <code>sudo service airtime-liquidsoap restart</code>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</div>
<div class="footer">
<h3>
PHP Extension List
</h3>
<p>
<?php
global $extensions;
$first = true;
foreach ($extensions as $ext) {
if (!$first) {
echo " | ";
} else {
$first = false;
}
echo $ext;
}
?>
</p>
</div>

View file

@ -21,6 +21,7 @@ define('LICENSE_URL' , 'http://www.gnu.org/licenses/agpl-3.0-standalone.h
define('AIRTIME_COPYRIGHT_DATE' , '2010-2012');
define('AIRTIME_REST_VERSION' , '1.1');
define('AIRTIME_API_VERSION' , '1.1');
define('AIRTIME_CODE_VERSION' , '2.5.2');
define('DEFAULT_LOGO_PLACEHOLDER', 1);
define('DEFAULT_LOGO_FILE', 'airtime_logo.png');

View file

@ -66,12 +66,6 @@ $pages = array(
'controller' => 'Preference',
'action' => 'stream-setting'
),
array(
'label' => _('Support Feedback'),
'module' => 'default',
'controller' => 'Preference',
'action' => 'support-setting'
),
array(
'label' => _('Status'),
'module' => 'default',

View file

@ -344,7 +344,7 @@ class ApiController extends Zend_Controller_Action
* variables in the result to reflect the given timezone.
*
* @param object $result reference to the object to send back to the user
* @param string $timezone the user's timezone parameter value
* @param string $timezone the user's timezone parameter value
* @param boolean $upcase whether the timezone output should be upcased
*/
private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase)

View file

@ -38,9 +38,12 @@ class ErrorController extends Zend_Controller_Action {
}
// Log exception, if logger available
/* No idea why this doesn't work or why it was implemented like this. Disabling it -- Albert
if (($log = $this->getLog())) {
$log->crit($this->view->message, $errors->exception);
}
}*/
//Logging that actually works: -- Albert
Logging::error($this->view->message . ": " . $errors->exception);
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {

View file

@ -13,18 +13,9 @@ class SystemstatusController extends Zend_Controller_Action
public function indexAction()
{
/*
$services = array(
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
//"media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus(),
);
*/
$partitions = Application_Model_Systemstatus::GetDiskInfo();
$this->view->status = new StdClass;
//$this->view->status->services = $services;
$this->view->status->partitions = $partitions;
}
}

View file

@ -13,45 +13,25 @@ class UpgradeController extends Zend_Controller_Action
return;
}
$upgraders = array();
array_push($upgraders, new AirtimeUpgrader253());
array_push($upgraders, new AirtimeUpgrader254());
array_push($upgraders, new AirtimeUpgrader255());
array_push($upgraders, new AirtimeUpgrader259());
array_push($upgraders, new AirtimeUpgrader2510());
array_push($upgraders, new AirtimeUpgrader2511());
array_push($upgraders, new AirtimeUpgrader2512());
$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->doUpgrade();
if (!$didWePerformAnUpgrade)
{
if (!$didWePerformAnUpgrade) {
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".<br>");
->setHttpResponseCode(200)
->appendBody("No upgrade was performed. The current schema version is " . Application_Model_Preference::GetSchemaVersion() . ".<br>");
} else {
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("Upgrade to Airtime schema version " . Application_Model_Preference::GetSchemaVersion() . " OK<br>");
}
}
catch (Exception $e)
{
$this->getResponse()
->setHttpResponseCode(400)
->appendBody($e->getMessage());
->setHttpResponseCode(400)
->appendBody($e->getMessage());
}
}

View file

@ -0,0 +1,6 @@
-- Replacing system_version with schema_version
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('schema_version', '2.5.2');
ALTER TABLE cc_show ADD COLUMN image_path varchar(255) DEFAULT '';
ALTER TABLE cc_show_instances ADD COLUMN description varchar(255) DEFAULT '';

View file

@ -886,10 +886,30 @@ class Application_Model_Preference
return self::getValue("enable_stream_conf");
}
public static function SetAirtimeVersion($version)
public static function GetSchemaVersion()
{
self::setValue("system_version", $version);
CcPrefPeer::clearInstancePool(); //Ensure we don't get a cached Propel object (cached DB results)
//because we're updating this version number within this HTTP request as well.
//New versions use schema_version
$pref = CcPrefQuery::create()
->filterByKeystr('schema_version')
->findOne();
if (empty($pref)) {
//Pre-2.5.2 releases all used this ambiguous "system_version" key to represent both the code and schema versions...
$pref = CcPrefQuery::create()
->filterByKeystr('system_version')
->findOne();
}
$schemaVersion = $pref->getValStr();
return $schemaVersion;
}
public static function SetSchemaVersion($version)
{
self::setValue("schema_version", $version);
}
public static function GetAirtimeVersion()

View file

@ -1287,7 +1287,7 @@ SQL;
"starts" => $rows[$i-1]['starts'],
"ends" => $rows[$i-1]['ends'],
"record" => $rows[$i-1]['record'],
"image_path" => $rows[$i-1]['image_path'],
"image_path" => $rows[$i-1]['image_path'],
"type" => "show");
}
@ -1345,7 +1345,6 @@ SQL;
"starts" => $rows[$previousShowIndex]['starts'],
"ends" => $rows[$previousShowIndex]['ends'],
"record" => $rows[$previousShowIndex]['record'],
"image_path" => $rows[$previousShowIndex]['image_path'],
"type" => "show");
}

View file

@ -1024,14 +1024,16 @@ SQL;
$LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.');
// Ask Liquidsoap if file is playable
$ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
/* CC-5990/5991 - Changed to point directly to liquidsoap, removed PATH export */
$command = sprintf('liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
escapeshellarg($audio_file));
$command = "export PATH=/usr/local/bin:/usr/bin:/bin/usr/bin/ && $ls_command";
exec($command, $output, $rv);
$isError = count($output) > 0 && in_array($output[0], $LIQUIDSOAP_ERRORS);
Logging::info("Is error?! : " . $isError);
Logging::info("ls playability response: " . $rv);
return ($rv == 0 && !$isError);
}

View file

@ -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);

View file

@ -1,21 +1,75 @@
<?php
class UpgradeManager
{
/** Used to determine if the database schema needs an upgrade in order for this version of the Airtime codebase to work correctly.
* @return array A list of schema versions that this version of the codebase supports.
*/
public static function getSupportedSchemaVersions()
{
//What versions of the schema does the code support today:
return array('2.5.12');
}
public static function checkIfUpgradeIsNeeded()
{
$schemaVersion = Application_Model_Preference::GetSchemaVersion();
$supportedSchemaVersions = self::getSupportedSchemaVersions();
$upgradeNeeded = !in_array($schemaVersion, $supportedSchemaVersions);
if ($upgradeNeeded) {
self::doUpgrade();
}
}
public static function doUpgrade()
{
$upgradeManager = new UpgradeManager();
$upgraders = array();
array_push($upgraders, new AirtimeUpgrader253());
array_push($upgraders, new AirtimeUpgrader254());
array_push($upgraders, new AirtimeUpgrader255());
array_push($upgraders, new AirtimeUpgrader259());
array_push($upgraders, new AirtimeUpgrader2510());
array_push($upgraders, new AirtimeUpgrader2511());
array_push($upgraders, new AirtimeUpgrader2512());
return $upgradeManager->runUpgrades($upgraders, (dirname(__DIR__) . "/controllers"));
}
/**
* 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 = false;
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). */
abstract protected function getSupportedVersions();
/** The version that this upgrader class will upgrade to. (returns a version string) */
/** Schema versions that this upgrader class can upgrade from (an array of version strings). */
abstract protected function getSupportedSchemaVersions();
/** The schema version that this upgrader class will upgrade to. (returns a version string) */
abstract public function getNewVersion();
public static function getCurrentVersion()
public static function getCurrentSchemaVersion()
{
CcPrefPeer::clearInstancePool(); //Ensure we don't get a cached Propel object (cached DB results)
//because we're updating this version number within this HTTP request as well.
$pref = CcPrefQuery::create()
->filterByKeystr('system_version')
->findOne();
$airtime_version = $pref->getValStr();
return $airtime_version;
return Application_Model_Preference::GetSchemaVersion();
}
/**
@ -24,7 +78,7 @@ abstract class AirtimeUpgrader
*/
public function checkIfUpgradeSupported()
{
if (!in_array(AirtimeUpgrader::getCurrentVersion(), $this->getSupportedVersions())) {
if (!in_array(AirtimeUpgrader::getCurrentSchemaVersion(), $this->getSupportedSchemaVersions())) {
return false;
}
return true;
@ -58,9 +112,10 @@ abstract class AirtimeUpgrader
class AirtimeUpgrader253 extends AirtimeUpgrader
{
protected function getSupportedVersions()
protected function getSupportedSchemaVersions()
{
return array('2.5.1', '2.5.2');
}
public function getNewVersion()
{
@ -109,8 +164,8 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
$database = $values['database']['dbname'];
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_".$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
Application_Model_Preference::SetAirtimeVersion($this->getNewVersion());
Application_Model_Preference::SetSchemaVersion($this->getNewVersion());
//clear out the cache
Cache::clear();
@ -125,7 +180,7 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
class AirtimeUpgrader254 extends AirtimeUpgrader
{
protected function getSupportedVersions()
protected function getSupportedSchemaVersions()
{
return array('2.5.3');
}
@ -195,7 +250,7 @@ class AirtimeUpgrader254 extends AirtimeUpgrader
}
//$con->commit();
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@ -211,7 +266,7 @@ class AirtimeUpgrader254 extends AirtimeUpgrader
}
class AirtimeUpgrader255 extends AirtimeUpgrader {
protected function getSupportedVersions() {
protected function getSupportedSchemaVersions() {
return array (
'2.5.4'
);
@ -243,7 +298,7 @@ class AirtimeUpgrader255 extends AirtimeUpgrader {
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@ -257,7 +312,7 @@ class AirtimeUpgrader255 extends AirtimeUpgrader {
}
class AirtimeUpgrader259 extends AirtimeUpgrader {
protected function getSupportedVersions() {
protected function getSupportedSchemaVersions() {
return array (
'2.5.5'
);
@ -289,7 +344,7 @@ class AirtimeUpgrader259 extends AirtimeUpgrader {
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@ -302,7 +357,7 @@ class AirtimeUpgrader259 extends AirtimeUpgrader {
class AirtimeUpgrader2510 extends AirtimeUpgrader
{
protected function getSupportedVersions() {
protected function getSupportedSchemaVersions() {
return array (
'2.5.9'
);
@ -334,7 +389,7 @@ class AirtimeUpgrader2510 extends AirtimeUpgrader
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@ -347,7 +402,7 @@ class AirtimeUpgrader2510 extends AirtimeUpgrader
class AirtimeUpgrader2511 extends AirtimeUpgrader
{
protected function getSupportedVersions() {
protected function getSupportedSchemaVersions() {
return array (
'2.5.10'
);
@ -375,7 +430,7 @@ class AirtimeUpgrader2511 extends AirtimeUpgrader
$disk_usage = $queryResult[0];
Application_Model_Preference::setDiskUsage($disk_usage);
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@ -391,7 +446,7 @@ class AirtimeUpgrader2511 extends AirtimeUpgrader
class AirtimeUpgrader2512 extends AirtimeUpgrader
{
protected function getSupportedVersions() {
protected function getSupportedSchemaVersions() {
return array (
'2.5.10',
'2.5.11'
@ -424,7 +479,7 @@ class AirtimeUpgrader2512 extends AirtimeUpgrader
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
Application_Model_Preference::SetAirtimeVersion($newVersion);
Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);

View file

@ -11,7 +11,7 @@ echo sprintf(_('%1$s %2$s, the open radio software for scheduling and remote sta
$this->airtime_version)
?>
<br />
<br />© 2013
<br /<?php echo(gmdate('Y')); ?>
<?php
$companySiteAnchor = "<a href='" . COMPANY_SITE_URL . "' target='_blank'>"
. COMPANY_NAME . " " . COMPANY_SUFFIX

View file

@ -1,8 +1,178 @@
<table width="60%" cellpadding="0" cellspacing="0" border="0" class="statustable">
<head>
<link rel="stylesheet" type="text/css" href="css/setup/config-check.css">
</head>
<tbody>
<tr id="partitions" class="even">
<th colspan="5"><?php echo _("Disk Space") ?></th>
</tr>
</tbody>
</table>
<?php
$phpDependencies = checkPhpDependencies();
$externalServices = checkExternalServices();
$zend = $phpDependencies["zend"];
$postgres = $phpDependencies["postgres"];
$database = $externalServices["database"];
$rabbitmq = $externalServices["rabbitmq"];
$pypo = $externalServices["pypo"];
$liquidsoap = $externalServices["liquidsoap"];
$mediamonitor = $externalServices["media-monitor"];
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
$r2 = array_reduce($externalServices, "booleanReduce", true);
$result = $r1 && $r2;
?>
<table width="60%" cellpadding="0" cellspacing="0" border="0" class="statustable">
<thead>
<tr class="ui-state-default strong">
<td><?php echo _("Service") ?></td>
<td><?php echo _("Description") ?></td>
<td><?php echo _("Status") ?></td>
</tr>
</thead>
<tbody>
<!--
<tr class="odd">
<td><?php echo sprintf(_("%s Version"), PRODUCT_NAME) ?></td>
<td>1.9.3</td>
<td>&nbsp;</td>
</tr>
-->
<tr>
<td class="component">
Zend
</td>
<td class="description">
Zend MVC Framework
</td>
<td class="solution <?php if ($zend) {echo 'check';?>">
<?php
} else {
?>">
<b>Ubuntu</b>: try running <code>sudo apt-get install libzend-framework-php</code>
<br/><b>Debian</b>: try running <code>sudo apt-get install zendframework</code>
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
Postgres
</td>
<td class="description">
PDO and PostgreSQL libraries
</td>
<td class="solution <?php if ($postgres) {echo 'check';?>">
<?php
} else {
?>">
Try running <code>sudo apt-get install php5-pgsql</code>
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
Database
</td>
<td class="description">
Database configuration for Airtime
</td>
<td class="solution <?php if ($database) {echo 'check';?>">
<?php
} else {
?>">
Make sure you aren't missing any of the Postgres dependencies in the table above.
If your dependencies check out, make sure your database configuration settings in
<code>/etc/airtime.conf</code> are correct and the Airtime database was installed correctly.
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
RabbitMQ
</td>
<td class="description">
RabbitMQ configuration for Airtime
</td>
<td class="solution <?php if ($rabbitmq) {echo 'check';?>">
<?php
} else {
?>">
Make sure RabbitMQ is installed correctly, and that your settings in /etc/airtime/airtime.conf
are correct. Try using <code>sudo rabbitmqctl list_users</code> and <code>sudo rabbitmqctl list_vhosts</code>
to see if the airtime user (or your custom RabbitMQ user) exists, then checking that
<code>sudo rabbitmqctl list_exchanges</code> contains entries for airtime-media-monitor, airtime-pypo,
and airtime-uploads.
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
Media Monitor
</td>
<td class="description">
Airtime media-monitor service
</td>
<td class="solution <?php if ($mediamonitor) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-media-monitor service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-media-monitor</code><br/>
If not, try <br/><code>sudo service airtime-media-monitor start</code>
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
Pypo
</td>
<td class="description">
Airtime playout service
</td>
<td class="solution <?php if ($pypo) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-playout service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-playout</code><br/>
If not, try <br/><code>sudo service airtime-playout restart</code>
<?php
}
?>
</td>
</tr>
<tr>
<td class="component">
Liquidsoap
</td>
<td class="description">
Airtime liquidsoap service
</td>
<td class="solution <?php if ($liquidsoap) {echo 'check';?>">
<?php
} else {
?>">
Check that the airtime-liquidsoap service is installed correctly in <code>/etc/init</code>,
and ensure that it's running with
<br/><code>initctl list | grep airtime-liquidsoap</code><br/>
If not, try <br/><code>sudo service airtime-liquidsoap restart</code>
<?php
}
?>
</td>
</tr>
<tr id="partitions" class="even">
<th colspan="5"><?php echo _("Disk Space") ?></th>
</tr>
</tbody>
</table>