Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
7876552b38
19 changed files with 197 additions and 139 deletions
|
@ -13,8 +13,8 @@ Linked code:
|
|||
- License: New BSD License
|
||||
- Compatible with GPLv3? Yes.
|
||||
|
||||
* GetID3
|
||||
- Web site: http://getid3.sourceforge.net/
|
||||
* Mutagen
|
||||
- Web site: http://code.google.com/p/mutagen/
|
||||
- License: GPLv2
|
||||
- Compatible with GPLv3? Yes
|
||||
|
||||
|
@ -28,7 +28,7 @@ Linked code:
|
|||
- Note: Only used for development, not needed to run Airtime.
|
||||
- License: LGPLv3
|
||||
|
||||
* Soundcloud php api wrapper
|
||||
* Soundcloud PHP API wrapper
|
||||
- Web site: https://github.com/mptre/php-soundcloud/blob/master/Services/Soundcloud.php
|
||||
- License: MIT
|
||||
- Compatible with the GPL: Yes. See http://www.gnu.org/licenses/license-list.html
|
||||
|
@ -38,6 +38,10 @@ Linked code:
|
|||
- License: New BSD
|
||||
- Compatible with GPLv3? Yes.
|
||||
|
||||
* pyinotify
|
||||
- Web site: https://github.com/seb-m/pyinotify
|
||||
- License: MIT
|
||||
|
||||
* PHP-AMQPLIB
|
||||
- Web site: https://github.com/tnc/php-amqplib
|
||||
- License: LGPLv2.1
|
||||
|
@ -73,6 +77,10 @@ Non-linked code:
|
|||
- Web site: http://www.eca.cx/ecasound/
|
||||
- License: GPLv2
|
||||
|
||||
* monit
|
||||
- Web site: http://mmonit.com/monit/
|
||||
- License: GPLv3
|
||||
|
||||
* jQuery
|
||||
- Web site: http://jquery.com/
|
||||
- License: MIT and GPL. See http://jquery.org/license
|
||||
|
@ -106,5 +114,11 @@ Non-linked code:
|
|||
- Web site: http://fgelinas.com/code/timepicker/
|
||||
- License: Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
|
||||
* Data Tables
|
||||
- Web site: http://www.datatables.net/
|
||||
- License: GPLv2 or BSD 3-Clause
|
||||
|
||||
* Server Browse
|
||||
- Web site: http://code.google.com/p/jq-serverbrowse/
|
||||
- License: BSD 2-Clause
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1,2 +1,2 @@
|
|||
PRODUCT_ID=Airtime
|
||||
PRODUCT_RELEASE=1.9.0
|
||||
PRODUCT_RELEASE=1.9.0-beta1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define('AIRTIME_VERSION', '1.9.0-devel');
|
||||
define('AIRTIME_VERSION', '1.9.0-beta1');
|
||||
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
||||
define('AIRTIME_REST_VERSION', '1.1');
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$file_id = $this->_getParam('id', null);
|
||||
$file = StoredFile::Recall($file_id);
|
||||
|
||||
$url = $file->getFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
|
||||
$url = $file->getRelativeFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
|
||||
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
||||
'title' => 'Download');
|
||||
|
||||
|
|
|
@ -543,8 +543,14 @@ class ScheduleController extends Zend_Controller_Action
|
|||
if($when) {
|
||||
$when = $formWhen->checkReliantFields($data, $startDateModified);
|
||||
}
|
||||
// format add_show_duration value to hh:mm so it can be compatible with
|
||||
// existing code
|
||||
|
||||
|
||||
//The way the following code works is that is parses the hour and
|
||||
//minute from a string with the format "1h 20m" or "2h" or "36m".
|
||||
//So we are detecting whether an hour or minute value exists via strpos
|
||||
//and then parse appropriately. A better way to do this in the future is
|
||||
//actually pass the format from javascript in the format hh:mm so we don't
|
||||
//have to do this extra String parsing.
|
||||
$hPos = strpos($data["add_show_duration"], 'h');
|
||||
$mPos = strpos($data["add_show_duration"], 'm');
|
||||
|
||||
|
@ -555,7 +561,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
|
||||
}
|
||||
if($mPos !== false){
|
||||
$mValue = trim(substr($data["add_show_duration"], $hPos+1, -1 ));
|
||||
$hPos = $hPos === FALSE ? 0 : $hPos+1;
|
||||
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
|
||||
}
|
||||
|
||||
$data["add_show_duration"] = $hValue.":".$mValue;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_PlaylistMetadata extends Zend_Form_SubForm
|
||||
{
|
||||
class Application_Form_PlaylistMetadata extends Zend_Form{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
|
|
@ -88,10 +88,10 @@ class Application_Form_SupportPreferences extends Zend_Form_SubForm
|
|||
->addValidator('Count', false, 1)
|
||||
->addValidator('Extension', false, 'jpg,png,gif')
|
||||
->addValidator('ImageSize', false, array(
|
||||
'minwidth' => 180,
|
||||
'minheight' => 180,
|
||||
'maxwidth' => 1000,
|
||||
'maxheight' => 1000));
|
||||
'minwidth' => 200,
|
||||
'minheight' => 200,
|
||||
'maxwidth' => 600,
|
||||
'maxheight' => 600));
|
||||
$this->addElement($upload);
|
||||
|
||||
//enable support feedback
|
||||
|
@ -121,6 +121,7 @@ class Application_Form_SupportPreferences extends Zend_Form_SubForm
|
|||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'readonly' => true,
|
||||
'cols' => 61,
|
||||
'value' => Application_Model_Preference::GetSystemInfo(),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
|
|
|
@ -91,7 +91,7 @@ class Playlist {
|
|||
{
|
||||
$seconds = $p_seconds;
|
||||
$milliseconds = intval(($seconds - intval($seconds)) * 1000);
|
||||
$milliStr = str_pad($milliseconds, 3, '0');
|
||||
$milliStr = str_pad($milliseconds, 3, '0', STR_PAD_LEFT);
|
||||
$hours = floor($seconds / 3600);
|
||||
$seconds -= $hours * 3600;
|
||||
$minutes = floor($seconds / 60);
|
||||
|
|
|
@ -311,7 +311,7 @@ class Application_Model_Preference
|
|||
$outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite();
|
||||
$outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry();
|
||||
$outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity();
|
||||
$outputArrat['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription();
|
||||
$outputArray['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription();
|
||||
|
||||
// get web server info
|
||||
$url = $systemInfoArray["AIRTIME_VERSION_URL"];
|
||||
|
@ -328,11 +328,13 @@ class Application_Model_Preference
|
|||
$outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s"));
|
||||
$outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId();
|
||||
|
||||
$outputArray = array_merge($outputArray, $systemInfoArray);
|
||||
$outputArray = array_merge($systemInfoArray, $outputArray);
|
||||
|
||||
$outputString = "\n";
|
||||
foreach($outputArray as $key => $out){
|
||||
$outputString .= $key.' : '.$out."\n";
|
||||
if(!empty($out)){
|
||||
$outputString .= $key.' : '.$out."\n";
|
||||
}
|
||||
}
|
||||
if($returnArray){
|
||||
$outputArray['LOGOIMG'] = Application_Model_Preference::GetStationLogo();
|
||||
|
|
|
@ -445,6 +445,16 @@ class StoredFile {
|
|||
return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes we want a relative URL and not a full URL. See bug
|
||||
* http://dev.sourcefabric.org/browse/CC-2403
|
||||
*/
|
||||
public function getRelativeFileUrl()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
return "api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
|
||||
}
|
||||
|
||||
public static function Insert($md=null)
|
||||
{
|
||||
$file = new CcFiles();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<h3 class="plain">Playlist Metadata</h3>
|
||||
<form method="post" action="" enctype="application/x-www-form-urlencoded">
|
||||
<?php echo $this->fieldset; ?>
|
||||
<fieldset>
|
||||
<?php echo $this->fieldset; ?>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -114,10 +114,14 @@ label.wrapp-label input[type="checkbox"] {
|
|||
|
||||
#add_show_start_time {
|
||||
float: left;
|
||||
width: 100px;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
#add_show_end_time, #add_show_end_date_no_repeat, #add_show_start_date {
|
||||
#add_show_end_time {
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
#add_show_end_date_no_repeat, #add_show_start_date {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
|
|
|
@ -1386,10 +1386,14 @@ div.success{
|
|||
#show_content_dialog .datatable {
|
||||
margin-top:8px;
|
||||
}
|
||||
.simple-formblock.metadata {
|
||||
|
||||
.simple-formblock.metadata, #side_playlist .simple-formblock.metadata {
|
||||
border:none;
|
||||
width:100%;
|
||||
width:auto;
|
||||
display:block;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#side_playlist .simple-formblock.metadata .input_text, #side_playlist .simple-formblock.metadata .input_text_area {
|
||||
width:95%;
|
||||
}
|
||||
|
|
|
@ -321,10 +321,12 @@ function setAddShowEvents() {
|
|||
// when start date/time changes, set end date/time to start date/time+1 hr
|
||||
$('#add_show_start_date, #add_show_start_time').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
var startTime = $('#add_show_start_time').val().split(':');
|
||||
var startDateTime = new Date(startDate[0], parseInt(startDate[1])-1, startDate[2], startTime[0], startTime[1], 0, 0);
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
var endTime = $('#add_show_end_time').val().split(':');
|
||||
var endDateTime = new Date(endDate[0], parseInt(endDate[1])-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
||||
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000));
|
||||
|
@ -343,10 +345,12 @@ function setAddShowEvents() {
|
|||
// when end date/time changes, check if the changed date is in past of start date/time
|
||||
$('#add_show_end_date_no_repeat, #add_show_end_time').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
var startTime = $('#add_show_start_time').val().split(':');
|
||||
var startDateTime = new Date(startDate[0], parseInt(startDate[1])-1, startDate[2], startTime[0], startTime[1], 0, 0);
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
var endTime = $('#add_show_end_time').val().split(':');
|
||||
var endDateTime = new Date(endDate[0], parseInt(endDate[1])-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
||||
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
$('#add_show_end_date_no_repeat').css('background-color', '#F49C9C');
|
||||
|
|
20
dev_tools/populate-cc_files.php
Normal file
20
dev_tools/populate-cc_files.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
function GenerateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||
{
|
||||
$string = '';
|
||||
for ($i = 0; $i < $p_len; $i++)
|
||||
{
|
||||
$pos = mt_rand(0, strlen($p_chars)-1);
|
||||
$string .= $p_chars{$pos};
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
$connection = pg_connect("host=localhost dbname=airtime user=airtime password=airtime");
|
||||
|
||||
for ($i=0; $i<1000000; $i++){
|
||||
$md5 = md5($i);
|
||||
$sql = "INSERT INTO cc_files (gunid, name, artist_name, track_title, album_title) VALUES ('$md5', '".md5($i."salt")."', '".md5($i."salt1")."', '".md5($i."salt2")."', '".md5($i."salt3")."')";
|
||||
pg_exec($connection, $sql);
|
||||
}
|
|
@ -10,6 +10,8 @@ class AirtimeInstall
|
|||
const CONF_DIR_WWW = "/var/www/airtime";
|
||||
const CONF_DIR_LOG = "/var/log/airtime";
|
||||
|
||||
public static $databaseTablesCreated = false;
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../airtime_mvc";
|
||||
|
@ -106,12 +108,11 @@ class AirtimeInstall
|
|||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
echo "* Connected to database".PHP_EOL;
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
}
|
||||
|
@ -148,15 +149,6 @@ class AirtimeInstall
|
|||
$success = chown($rp, "pypo");
|
||||
$success = chmod($rp, 02777);
|
||||
$CC_CONFIG['storageDir'] = $rp;
|
||||
|
||||
//add stor directory to MusiDirs
|
||||
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$rp', 'stor')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "* Failed inserting {$rp} in cc_music_dirs".PHP_EOL;
|
||||
echo "* Message {$result->getMessage()}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateDatabaseUser()
|
||||
|
@ -236,6 +228,7 @@ class AirtimeInstall
|
|||
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql";
|
||||
$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
|
||||
@exec($command, $output, $results);
|
||||
AirtimeInstall::$databaseTablesCreated = true;
|
||||
}
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is separated out so that it can be run separately for DEB package installation.
|
||||
* When installing a DEB package, Postgresql may not be installed yet and thus the database
|
||||
* cannot be created. So this script is run after all DEB packages have been installed.
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
|
@ -39,5 +44,18 @@ if (isset($argv[1]) && $argv[1] == 'y') {
|
|||
AirtimeInstall::CreateDatabaseTables();
|
||||
}
|
||||
|
||||
echo "* Setting Airtime version".PHP_EOL;
|
||||
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
||||
|
||||
if (AirtimeInstall::$databaseTablesCreated) {
|
||||
echo "* Inserting stor directory into music_dirs table".PHP_EOL;
|
||||
$stor_dir = realpath($CC_CONFIG['storageDir']);
|
||||
|
||||
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "* Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
|
||||
echo "* Message {$result->getMessage()}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
|
@ -4,9 +4,10 @@
|
|||
* @copyright 2011 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*
|
||||
* Checks if a previous version of Airtime is currently installed, upgrades Airtime if so.
|
||||
* Performs a new install (new configs, database install) if a version of Airtime is not found
|
||||
* If the current version is found to be installed the User is presented with the help menu and can choose -r to reinstall.
|
||||
* Checks if a previous version of Airtime is currently installed and upgrades Airtime if so.
|
||||
* Performs a new install (new configs, database install) if a version of Airtime is not found.
|
||||
* If the current version is found to be installed the user is presented with the help menu and can
|
||||
* choose -r to reinstall.
|
||||
*/
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
|
@ -22,31 +23,40 @@ $version = AirtimeInstall::GetVersionInstalled();
|
|||
require_once('Zend/Loader/Autoloader.php');
|
||||
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||
|
||||
function printUsage($opts)
|
||||
{
|
||||
$msg = $opts->getUsageMessage();
|
||||
echo PHP_EOL."Usage: airtime-install [options]";
|
||||
echo substr($msg, strpos($msg, "\n")).PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
array(
|
||||
'help|h' => 'Displays usage information.',
|
||||
'overwrite|o' => 'Overwrite any existing config files.',
|
||||
'preserve|p' => 'Keep any existing config files.',
|
||||
'no-db|n' => 'Turn off database install.',
|
||||
'no-db|n' => 'Turn off database install.',
|
||||
'reinstall|r' => 'Force a fresh install of this Airtime Version'
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
}
|
||||
catch (Zend_Console_Getopt_Exception $e) {
|
||||
exit($e->getMessage() ."\n\n". $e->getUsageMessage());
|
||||
print $e->getMessage() .PHP_EOL;
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($opts->h)) {
|
||||
echo $opts->getUsageMessage();
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// The current version is already installed.
|
||||
if(isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
|
||||
echo "Airtime $version is already installed.".PHP_EOL;
|
||||
echo $opts->getUsageMessage();
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
// A previous version exists - if so, upgrade.
|
||||
|
@ -122,6 +132,8 @@ echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
|
|||
|
||||
if ($db_install) {
|
||||
if($newInstall) {
|
||||
// This is called with "system" so that we can pass in a parameter. See the file itself
|
||||
// for why we need to do this.
|
||||
system('php '.__DIR__.'/airtime-db-install.php y');
|
||||
AirtimeInstall::DbConnect(true);
|
||||
} else {
|
||||
|
@ -137,11 +149,12 @@ AirtimeInstall::CreateZendPhpLogFile();
|
|||
|
||||
AirtimeInstall::SetUniqueId();
|
||||
|
||||
$h = rand(0,23);
|
||||
$m = rand(0,59);
|
||||
// Create CRON task to run every day. Time of day is initialized to a random time.
|
||||
$hour = rand(0,23);
|
||||
$minute = rand(0,59);
|
||||
|
||||
$fp = fopen('/etc/cron.d/airtime-crons','a');
|
||||
fwrite($fp, "$m $h * * * root /usr/lib/airtime/utils/phone_home_stat\n");
|
||||
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
|
||||
fclose($fp);
|
||||
|
||||
/* FINISHED AIRTIME PHP INSTALLER */
|
||||
|
|
|
@ -21,11 +21,10 @@ AirtimeCheck::PythonLibrariesInstalled();
|
|||
|
||||
AirtimeCheck::CheckRabbitMqConnection($airtimeIni);
|
||||
|
||||
AirtimeCheck::CheckApacheVHostFiles();
|
||||
//AirtimeCheck::CheckApacheVHostFiles();
|
||||
|
||||
AirtimeCheck::GetAirtimeServerVersion($pypoCfg);
|
||||
AirtimeCheck::CheckAirtimePlayoutRunning();
|
||||
AirtimeCheck::CheckLiquidsoapRunning();
|
||||
AirtimeCheck::CheckAirtimeDaemons();
|
||||
AirtimeCheck::CheckIcecastRunning();
|
||||
|
||||
echo PHP_EOL;
|
||||
|
@ -57,17 +56,8 @@ class AirtimeCheck {
|
|||
|
||||
public static $check_system_ok = true;
|
||||
|
||||
public static function CheckAirtimePlayoutRunning()
|
||||
private static function CheckAirtimeDaemonRunning($filename, $process_id_str, $process_running_str, $name, $logFile)
|
||||
{
|
||||
|
||||
//check if airtime-playout.pid exists
|
||||
|
||||
//if it exists we need to get the process id
|
||||
//from the file as well as the time the process
|
||||
//has been running. We can get the latter from
|
||||
//the timestamp of the file
|
||||
$filename = "/var/run/airtime-playout.pid";
|
||||
|
||||
$pid = false;
|
||||
$numSecondsRunning = 0;
|
||||
|
||||
|
@ -87,13 +77,13 @@ class AirtimeCheck {
|
|||
}
|
||||
}
|
||||
|
||||
output_status("PLAYOUT_ENGINE_PROCESS_ID", $pid);
|
||||
output_status($process_id_str, $pid);
|
||||
|
||||
output_status("PLAYOUT_ENGINE_RUNNING_SECONDS", $numSecondsRunning);
|
||||
output_status($process_running_str, $numSecondsRunning);
|
||||
if (is_numeric($numSecondsRunning) && (int)$numSecondsRunning < 3) {
|
||||
self::$check_system_ok = false;
|
||||
output_msg("WARNING! It looks like the playout engine is continually restarting.");
|
||||
$command = "tail -10 /var/log/airtime/pypo/pypo.log";
|
||||
output_msg("WARNING! It looks like the $name engine is continually restarting.");
|
||||
$command = "tail -10 $logFile";
|
||||
exec($command, $output, $result);
|
||||
foreach ($output as $line) {
|
||||
output_msg($line);
|
||||
|
@ -101,49 +91,38 @@ class AirtimeCheck {
|
|||
}
|
||||
}
|
||||
|
||||
public static function CheckLiquidsoapRunning()
|
||||
public static function CheckAirtimeDaemons()
|
||||
{
|
||||
//check if airtime-playout.pid exists
|
||||
self::CheckAirtimeDaemonRunning("/var/run/airtime-playout.pid",
|
||||
"PLAYOUT_ENGINE_PROCESS_ID",
|
||||
"PLAYOUT_ENGINE_RUNNING_SECONDS",
|
||||
"playout",
|
||||
"/var/log/airtime/pypo/pypo.log"
|
||||
);
|
||||
|
||||
//if it exists we need to get the process id
|
||||
//from the file as well as the time the process
|
||||
//has been running. We can get the latter from
|
||||
//the timestamp of the file
|
||||
$filename = "/var/run/airtime-liquidsoap.pid";
|
||||
self::CheckAirtimeDaemonRunning("/var/run/airtime-liquidsoap.pid",
|
||||
"LIQUIDSOAP_PROCESS_ID",
|
||||
"LIQUIDSOAP_RUNNING_SECONDS",
|
||||
"Liquidsoap",
|
||||
"/var/log/airtime/pypo/ls_script.log"
|
||||
);
|
||||
|
||||
$pid = false;
|
||||
$numSecondsRunning = 0;
|
||||
self::CheckAirtimeDaemonRunning("/var/run/airtime-media-monitor.pid",
|
||||
"MEDIA_MONITOR_PROCESS_ID",
|
||||
"MEDIA_MONITOR_RUNNING_SECONDS",
|
||||
"Media Monitor",
|
||||
"/var/log/airtime/media-monitor/media-monitor.log"
|
||||
);
|
||||
|
||||
if (file_exists($filename)){
|
||||
//first get pid
|
||||
$potential_pid = trim(file_get_contents($filename));
|
||||
|
||||
//check if the pid is actually live
|
||||
if (file_exists("/proc/$potential_pid")){
|
||||
$pid = $potential_pid;
|
||||
|
||||
//now lets get the running time
|
||||
$lastModified = filemtime($filename);
|
||||
$currentTime = time();
|
||||
|
||||
$numSecondsRunning = $currentTime - $lastModified;
|
||||
}
|
||||
}
|
||||
|
||||
output_status("LIQUIDSOAP_PROCESS_ID", $pid);
|
||||
|
||||
output_status("LIQUIDSOAP_RUNNING_SECONDS", $numSecondsRunning);
|
||||
if (is_numeric($numSecondsRunning) && (int)$numSecondsRunning < 3) {
|
||||
self::$check_system_ok = false;
|
||||
output_msg("WARNING! It looks like the playout engine is continually restarting.");
|
||||
$command = "tail -10 /var/log/airtime/pypo-liquidsoap/ls_script.log";
|
||||
exec($command, $output, $result);
|
||||
foreach ($output as $line) {
|
||||
output_msg($line);
|
||||
}
|
||||
}
|
||||
self::CheckAirtimeDaemonRunning("/var/run/airtime-show-recorder.pid",
|
||||
"SHOW_RECORDER_PROCESS_ID",
|
||||
"SHOW_RECORDER_RUNNING_SECONDS",
|
||||
"Show Recorder",
|
||||
"/var/log/airtime/media-monitor/show-recorder.log"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static function CheckIcecastRunning()
|
||||
{
|
||||
$command = "ps aux | grep \"^icecast2\"";
|
||||
|
@ -151,7 +130,7 @@ class AirtimeCheck {
|
|||
|
||||
$status = AirtimeCheck::CHECK_FAILED;
|
||||
if (count($output) > 0){
|
||||
$delimited = split("[ ]+", $output[0]);
|
||||
$delimited = preg_split("/[\s]+/", $output[0]);
|
||||
$status = $delimited[1];
|
||||
} else {
|
||||
self::$check_system_ok = false;
|
||||
|
@ -164,7 +143,7 @@ class AirtimeCheck {
|
|||
$command = "cat /proc/cpuinfo |grep -m 1 'model name' ";
|
||||
exec($command, $output, $result);
|
||||
|
||||
$choppedStr = split(":", $output[0]);
|
||||
$choppedStr = explode(":", $output[0]);
|
||||
$status = trim($choppedStr[1]);
|
||||
output_status("CPU", $status);
|
||||
}
|
||||
|
@ -173,14 +152,14 @@ class AirtimeCheck {
|
|||
{
|
||||
$command = "cat /proc/meminfo |grep 'MemTotal' ";
|
||||
exec($command, $output, $result);
|
||||
$choppedStr = split(":", $output[0]);
|
||||
$choppedStr = explode(":", $output[0]);
|
||||
$status = trim($choppedStr[1]);
|
||||
output_status("Total RAM", $status);
|
||||
|
||||
$output = null;
|
||||
$command = "cat /proc/meminfo |grep 'MemFree' ";
|
||||
exec($command, $output, $result);
|
||||
$choppedStr = split(":", $output[0]);
|
||||
$choppedStr = explode(":", $output[0]);
|
||||
$status = trim($choppedStr[1]);
|
||||
output_status("Free RAM", $status);
|
||||
}
|
||||
|
@ -191,6 +170,7 @@ class AirtimeCheck {
|
|||
$confFiles = array("airtime.conf",
|
||||
"liquidsoap.cfg",
|
||||
"pypo.cfg",
|
||||
"media-monitor.cfg",
|
||||
"recorder.cfg");
|
||||
|
||||
$allFound = AirtimeCheck::CHECK_OK;
|
||||
|
@ -200,6 +180,7 @@ class AirtimeCheck {
|
|||
if (!file_exists($fullPath)){
|
||||
$allFound = AirtimeCheck::CHECK_FAILED;
|
||||
self::$check_system_ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +238,7 @@ class AirtimeCheck {
|
|||
|
||||
$status = AirtimeCheck::CHECK_FAILED;
|
||||
if (count($output[0]) > 0){
|
||||
$key_value = split("==", $output[0]);
|
||||
$key_value = explode("==", $output[0]);
|
||||
$status = trim($key_value[1]);
|
||||
} else {
|
||||
self::$check_system_ok = false;
|
||||
|
@ -271,7 +252,7 @@ class AirtimeCheck {
|
|||
|
||||
$status = AirtimeCheck::CHECK_FAILED;
|
||||
if (count($output[0]) > 0){
|
||||
$key_value = split("==", $output[0]);
|
||||
$key_value = explode("==", $output[0]);
|
||||
$status = trim($key_value[1]);
|
||||
} else {
|
||||
self::$check_system_ok = false;
|
||||
|
@ -412,7 +393,7 @@ class AirtimeCheck {
|
|||
// Figure out if 32 or 64 bit
|
||||
$command = "file -b /sbin/init";
|
||||
exec($command, $output, $result);
|
||||
$splitStr = split(",", $output[0]);
|
||||
$splitStr = explode(",", $output[0]);
|
||||
$os_string .= $splitStr[1];
|
||||
|
||||
output_status("OS", $os_string);
|
||||
|
@ -423,20 +404,6 @@ class AirtimeCheck {
|
|||
// error handler function
|
||||
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
return true;
|
||||
|
||||
/*
|
||||
if ($errno == E_WARNING){
|
||||
if (strpos($errstr, "401") !== false){
|
||||
echo "\t\tServer is running but could not find Airtime".PHP_EOL;
|
||||
} else if (strpos($errstr, "Connection refused") !== false){
|
||||
echo "\t\tServer does not appear to be running".PHP_EOL;
|
||||
} else {
|
||||
//echo $errstr;
|
||||
}
|
||||
}
|
||||
|
||||
//Don't execute PHP internal error handler
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue