Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Yuchen Wang 2011-12-02 13:55:39 -05:00
commit 9991cbd16b
39 changed files with 596 additions and 363 deletions

View File

@ -198,6 +198,7 @@ class PreferenceController extends Zend_Controller_Action
}
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
$values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
}
if(!$error){
Application_Model_StreamSetting::setStreamSetting($values);

View File

@ -46,11 +46,11 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js','text/javascript');
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');
@ -385,14 +385,6 @@ class ScheduleController extends Zend_Controller_Action
$start_timestamp = $show->getShowInstanceStart();
$end_timestamp = $show->getShowInstanceEnd();
//check to make sure show doesn't overlap.
if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")),
new DateTime($end_timestamp, new DateTimeZone("UTC")),
array($showInstanceId))) {
$this->view->error = "cannot schedule an overlapping show.";
return;
}
$dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp)));
$dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp)));
@ -574,7 +566,7 @@ class ScheduleController extends Zend_Controller_Action
$i = 1;
foreach ($rebroadcastsAbsolute as $rebroadcast){
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = $rebroadcast['start_time'];
$i++;
}
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);

View File

@ -25,6 +25,17 @@ class Application_Form_StreamSetting extends Zend_Form
$output_sound_device->setAttrib("readonly", true);
}
$this->addElement($output_sound_device);
$output_types = array("ALSA"=>"ALSA", "AO"=>"AO", "OSS"=>"OSS", "Portaudio"=>"Portaudio", "Pulseaudio"=>"Pulseaudio");
$output_type = new Zend_Form_Element_Select('output_sound_device_type');
$output_type->setLabel("Output Type")
->setMultiOptions($output_types)
->setValue($setting['output_sound_device_type'])
->setDecorators(array('ViewHelper'));
if($setting['output_sound_device'] != "true"){
$output_type->setAttrib("disabled", "disabled");
}
$this->addElement($output_type);
}
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
@ -39,7 +50,8 @@ class Application_Form_StreamSetting extends Zend_Form
}
public function isValid($data){
$this->populate(array("output_sound_device"=>$data['output_sound_device'], "icecast_vorbis_metadata"=>$data['icecast_vorbis_metadata']));
$this->populate(array("output_sound_device"=>$data['output_sound_device'], "icecast_vorbis_metadata"=>$data['icecast_vorbis_metadata'],
"output_sound_device_type"=>$data['output_sound_device_type']));
return true;
}
}

View File

@ -68,7 +68,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
if($disable_all){
$bitrate->setAttrib("disabled", "disabled");
}
$this->addElement($type);
$this->addElement($bitrate);
$output = new Zend_Form_Element_Select('output');

View File

@ -105,6 +105,13 @@ class Application_Model_Show {
return $res;
}
//remove everything about this show.
public function deleteShow()
{
$show = CcShowQuery::create()->findPK($this->_showId);
$show->delete();
}
public function resizeShow($deltaDay, $deltaMin)
{
global $CC_DBC;
@ -183,10 +190,10 @@ class Application_Model_Show {
public function removeUncheckedDaysInstances($p_uncheckedDays)
{
global $CC_DBC;
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
$daysRemovedUTC = array();
$showDays = CcShowDaysQuery::create()
->filterByDbShowId($this->getId())
->find();
@ -195,12 +202,12 @@ class Application_Model_Show {
foreach($p_uncheckedDays as $day) {
Logging::log($day);
}
foreach($showDays as $showDay) {
Logging::log("Local show day is: {$showDay->getDbDay()}");
Logging::log("First show day is: {$showDay->getDbFirstShow()}");
Logging::log("Id show days is: {$showDay->getDbId()}");
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
$showDay->reload();
//Logging::log("Local show day is: {$showDay->getDbDay()}");
@ -214,7 +221,7 @@ class Application_Model_Show {
Logging::log("UTC show day is: {$startDay->format('w')}");
}
}
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
$showId = $this->getId();
@ -224,7 +231,7 @@ class Application_Model_Show {
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
Logging::log($sql);
$CC_DBC->query($sql);
@ -278,22 +285,27 @@ class Application_Model_Show {
global $CC_DBC;
$showId = $this->getId();
$sql = "SELECT date(starts) "
."FROM cc_show_instances "
."WHERE show_id = $showId "
."AND record = 1 "
."AND modified_instance != TRUE";
$baseDate = $CC_DBC->GetOne($sql);
if (is_null($baseDate)){
return array();
$sql = "SELECT starts FROM cc_show_instances "
."WHERE show_id = $showId AND rebroadcast = 1 "
."ORDER BY starts";
$rebroadcasts = $CC_DBC->GetAll($sql);
$rebroadcastsLocal = array();
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
$i = 0;
foreach ($rebroadcasts as $show) {
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$rebroadcastsLocal[$i]["start_date"] = $startDateTime->format("Y-m-d");
$rebroadcastsLocal[$i]["start_time"] = $startDateTime->format("H:i");
$i = $i + 1;
}
$sql = "SELECT date(DATE '$baseDate' + day_offset::INTERVAL) as start_date, start_time FROM cc_show_rebroadcast "
."WHERE show_id = $showId "
."ORDER BY start_date";
return $CC_DBC->GetAll($sql);
return $rebroadcastsLocal;
}
/**
@ -815,21 +827,21 @@ class Application_Model_Show {
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
if (count($daysRemoved) > 0){
$this->removeUncheckedDaysInstances($daysRemoved);
}
}
if ($p_data['add_show_start_date'] != $this->getStartDate()
|| $p_data['add_show_start_time'] != $this->getStartTime()){
//start date/time has changed
$newDate = strtotime($p_data['add_show_start_date']);
$oldDate = strtotime($this->getStartDate());
if ($newDate > $oldDate){
$this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
}
$this->updateStartDateTime($p_data, $p_endDate);
}
}
@ -1224,8 +1236,10 @@ class Application_Model_Show {
$showInstance->correctScheduleStartTimes();
}
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
//don't create rebroadcasts for a deleted recorded show.
if ($ccShowInstance->getDbModifiedInstance() == false) {
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
}
if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
@ -1538,23 +1552,23 @@ class Application_Model_Show {
return $event;
}
/* Takes in a UTC DateTime object.
/* Takes in a UTC DateTime object.
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowFirstShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbFirstShow($dt)
->save();
Logging::log("setting show's first show.");
}
@ -1562,15 +1576,15 @@ class Application_Model_Show {
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowLastShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
//add one day since the Last Show date in CcShowDays is non-inclusive.
$dt->add(new DateInterval("P1D"));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();

View File

@ -31,7 +31,7 @@ class Application_Model_ShowInstance {
/* This function is weird. It should return a boolean, but instead returns
* an integer if it is a rebroadcast, or returns null if it isn't. You can convert
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
* means that it is. */
public function isRebroadcast()
{
@ -175,63 +175,104 @@ class Application_Model_ShowInstance {
Application_Model_RabbitMq::PushSchedule();
}
/*
* @param $dateTime
* php Datetime object to add deltas to
*
* @param $deltaDay
* php int, delta days show moved
*
* @param $deltaMin
* php int, delta mins show moved
*
* @return $newDateTime
* php DateTime, $dateTime with the added time deltas.
*/
private static function addDeltas($dateTime, $deltaDay, $deltaMin) {
$newDateTime = clone $dateTime;
Logging::log("deltaDay: {$deltaDay}");
Logging::log("deltaMin: {$deltaMin}");
Logging::log("addDeltas: original time {$newDateTime->format('Y-m-d H:i:s')}");
$days = abs($deltaDay);
$mins = abs($deltaMin);
$dayInterval = new DateInterval("P{$days}D");
$minInterval = new DateInterval("PT{$mins}M");
if ($deltaDay > 0) {
$newDateTime->add($dayInterval);
}
else if ($deltaDay < 0){
$newDateTime->sub($dayInterval);
}
if ($deltaMin > 0) {
$newDateTime->add($minInterval);
}
else if ($deltaMin < 0) {
$newDateTime->sub($minInterval);
}
Logging::log("addDeltas: modified time {$newDateTime->format('Y-m-d H:i:s')}");
return $newDateTime;
}
public function moveShow($deltaDay, $deltaMin)
{
global $CC_DBC;
if ($this->getShow()->isRepeating()){
return "Can't drag and drop repeating shows";
}
$hours = $deltaMin/60;
if($hours > 0)
$hours = floor($hours);
else
$hours = ceil($hours);
$mins = abs($deltaMin%60);
$today_timestamp = time();
$starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd();
$startsDateTime = new DateTime($this->getShowInstanceStart(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($this->getShowInstanceEnd(), new DateTimeZone("UTC"));
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
if($today_timestamp > $startsDateTime->getTimestamp()) {
if ($today_timestamp > $startsDateTime->getTimestamp()) {
return "Can't move a past show";
}
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$new_starts = $CC_DBC->GetOne($sql);
$newStartsDateTime = new DateTime($new_starts, new DateTimeZone("UTC"));
//the user is moving the show on the calendar from the perspective of local time.
//incase a show is moved across a time change border offsets should be added to the localtime
//stamp and then converted back to UTC to avoid show time changes!
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$new_ends = $CC_DBC->GetOne($sql);
$newEndsDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
$newStartsDateTime = self::addDeltas($startsDateTime, $deltaDay, $deltaMin);
$newEndsDateTime = self::addDeltas($endsDateTime, $deltaDay, $deltaMin);
//convert our new starts/ends to UTC.
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
if($today_timestamp > $newStartsDateTime->getTimestamp()) {
if ($today_timestamp > $newStartsDateTime->getTimestamp()) {
return "Can't move show into past";
}
$overlap = Application_Model_Show::getShows($newStartsDateTime, $newEndsDateTime, array($this->_instanceId));
if ($this->isRebroadcast()) {
if(count($overlap) > 0) {
return "Should not overlap shows";
}
try {
$recordedShow = new Application_Model_ShowInstance($this->_showInstance->getDbOriginalShow());
}
//recorded show doesn't exist.
catch (Exception $e) {
$this->_showInstance->delete();
return "Show was deleted because recorded show does not exist!";
}
$rebroadcast = $this->isRebroadcast();
if($rebroadcast) {
$sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})";
$isBeforeRecordedOriginal = $CC_DBC->GetOne($sql);
$recordEndDateTime = new DateTime($recordedShow->getShowInstanceEnd(), new DateTimeZone("UTC"));
$newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60);
if($isBeforeRecordedOriginal === 't'){
return "Cannot move a rebroadcast show before its original show";
if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) {
return "Must wait 1 hour to rebroadcast.";
}
}
$this->setShowStart($new_starts);
$this->setShowEnd($new_ends);
$this->setShowStart($newStartsDateTime);
$this->setShowEnd($newEndsDateTime);
$this->correctScheduleStartTimes();
$show = new Application_Model_Show($this->getShowId());
@ -399,40 +440,55 @@ class Application_Model_ShowInstance {
global $CC_DBC;
// see if it was recording show
$recording = CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->getDbRecord();
$recording = $this->isRecorded();
// get show id
$showId = CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->getDbShowId();
$showId = $this->getShowId();
CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->setDbModifiedInstance(true)
->save();
/* Automatically delete all files scheduled in cc_schedules table. */
CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->delete();
$show = $this->getShow();
// check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbModifiedInstance(false)
->findOne();
$current_timestamp = gmdate("Y-m-d H:i");
/* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should
* take care of deleting all of its instances. */
if(is_null($showInstancesRow)){
CcShowQuery::create()
->filterByDbId($showId)
->delete();
if ($current_timestamp < $this->getShowInstanceStart()) {
if ($show->isRepeating()) {
CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->setDbModifiedInstance(true)
->save();
//delete the rebroadcasts of the removed recorded show.
if ($recording) {
CcShowInstancesQuery::create()
->filterByDbOriginalShow($this->_instanceId)
->delete();
}
/* Automatically delete all files scheduled in cc_schedules table. */
CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->delete();
// check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbModifiedInstance(false)
->findOne();
/* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should
* take care of deleting all of its instances. */
if(is_null($showInstancesRow)){
CcShowQuery::create()
->filterByDbId($showId)
->delete();
}
}
else {
$show->deleteShow();
}
}
Application_Model_RabbitMq::PushSchedule();

View File

@ -442,10 +442,10 @@ class Application_Model_StoredFile {
{
$serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT'];
return $this->constructGetFileUrl($serverName, $serverPort);
}
/**
* Get the URL to access this file using the server name/address that
* is specified in the airtime.conf config file. If either of these is
@ -453,13 +453,13 @@ class Application_Model_StoredFile {
*/
public function getFileUrlUsingConfigAddress(){
global $CC_CONFIG;
if (isset($CC_CONFIG['baseUrl'])){
$serverName = $CC_CONFIG['baseUrl'];
} else {
$serverName = $_SERVER['SERVER_NAME'];
}
if (isset($CC_CONFIG['basePort'])){
$serverPort = $CC_CONFIG['basePort'];
} else {
@ -468,7 +468,7 @@ class Application_Model_StoredFile {
return $this->constructGetFileUrl($serverName, $serverPort);
}
private function constructGetFileUrl($p_serverName, $p_serverPort){
return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
}
@ -604,7 +604,7 @@ class Application_Model_StoredFile {
{
return Application_Model_StoredFile::Recall(null, null, null, $p_filepath);
}
public static function RecallByPartialFilepath($partial_path){
$path_info = Application_Model_MusicDir::splitFilePath($partial_path);
@ -625,11 +625,11 @@ class Application_Model_StoredFile {
}
return $res;
}
public static function searchFilesForPlaylistBuilder($datatables) {
global $CC_CONFIG;
$displayData = array("track_title", "artist_name", "album_title", "track_number", "length", "ftype");
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "ftype");
$plSelect = "SELECT ";
$fileSelect = "SELECT ";
@ -812,11 +812,11 @@ class Application_Model_StoredFile {
// create temp file name (CC-3086)
$command = "mktemp --tmpdir=".$p_targetDir;
$tempFilePath= exec($command);
if($tempFilePath == ""){
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Unable to create tmp file."}, "id" : "id"}');
}
if (strpos($contentType, "multipart") !== false) {
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
// Open temp file
@ -854,7 +854,7 @@ class Application_Model_StoredFile {
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
return $tempFilePath;
}
@ -919,11 +919,11 @@ class Application_Model_StoredFile {
$this->_file->setDbSoundCloudLinkToFile($link_to_file)
->save();
}
public function getSoundCloudLinkToFile(){
return $this->_file->getDbSoundCloudLinkToFile();
}
public function setSoundCloudFileId($p_soundcloud_id)
{
$this->_file->setDbSoundCloudId($p_soundcloud_id)
@ -955,7 +955,7 @@ class Application_Model_StoredFile {
public function uploadToSoundCloud()
{
global $CC_CONFIG;
$file = $this->_file;
if(is_null($file)) {
return "File does not exist";

View File

@ -11,7 +11,7 @@
<th>Title</th>
<th>Creator</th>
<th>Album</th>
<th>Track</th>
<th>Genre</th>
<th>Length</th>
<th>Type</th>
</tr>

View File

@ -20,6 +20,14 @@
<dd id="hardwareOut-element">
<?php echo $this->form->getElement('output_sound_device') ?>
</dd>
<dt id="hardwareOutType-label">
<label class="required">
<?php echo $this->form->getElement('output_sound_device_type')->getLabel() ?> :
</label>
</dt>
<dd id="hardwareOutType-element">
<?php echo $this->form->getElement('output_sound_device_type') ?>
</dd>
<?php } ?>
<dt id="vorbisMetadata-label">
<label class="required">

View File

@ -8,6 +8,7 @@ INSERT INTO cc_pref("keystr", "valstr") VALUES('max_bitrate', '320');
INSERT INTO cc_pref("keystr", "valstr") VALUES('plan_level', 'disabled');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device', 'false', 'boolean');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device_type', 'ALSA', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_enable', 'true', 'boolean');

View File

@ -318,7 +318,7 @@ function createDataTable(data) {
/* Title */ { "sName": "track_title" },
/* Creator */ { "sName": "artist_name" },
/* Album */ { "sName": "album_title" },
/* Track */ { "sName": "track_number" },
/* Genre */ { "sName": "genre" },
/* Length */ { "sName": "length" },
/* Type */ { "sName": "ftype", "bSearchable": false }
],

View File

@ -364,21 +364,23 @@ function editName() {
$("#playlist_name_input")
.removeClass('element_hidden')
.val(playlistName)
.blur(function(){
var input = $(this);
var url;
url = '/Playlist/set-playlist-name';
.keydown(function(event){
if(event.keyCode === 13) {
event.preventDefault();
var input = $(this);
var url;
url = '/Playlist/set-playlist-name';
$.post(url, {format: "json", name: input.val()}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
input.addClass('element_hidden');
nameElement.text(json.playlistName);
redrawDataTablePage();
});
$.post(url, {format: "json", name: input.val()}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
input.addClass('element_hidden');
nameElement.text(json.playlistName);
redrawDataTablePage();
});
}
})
.keydown(submitOnEnter)
.focus();
}
@ -441,9 +443,12 @@ function setUpSPL() {
$.post(url, {format: "json", description: description}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}else{
}
else{
textarea.val(json.playlistDescription);
}
$("#fieldset-metadate_change").addClass("closed");
});
});
@ -455,9 +460,12 @@ function setUpSPL() {
$.post(url, {format: "json"}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}else{
}
else{
textarea.val(json.playlistDescription);
}
$("#fieldset-metadate_change").addClass("closed");
});
});

View File

@ -125,6 +125,14 @@ $(document).ready(function() {
rebuildStreamURL($(this))
})
$("#output_sound_device").change(function(){
if($(this).is(':checked')){
$("select[id=output_sound_device_type]").removeAttr('disabled')
}else{
$("select[id=output_sound_device_type]").attr('disabled', 'disabled')
}
})
$("select[id$=data-type]").change(function(){
if($(this).val() == 'ogg'){
restrictOggBitrate($(this), true)

View File

@ -23,9 +23,35 @@ env.vm_download_url = "http://host.sourcefabric.org/vms/VirtualBox"
#fab -f fab_setup.py ubuntu_lucid_64 airtime_182_tar airtime_190_tar
def do_sudo(command):
result = sudo(command)
if result.return_code != 0:
print "Error running command: %s" %command
shutdown()
sys.exit(1)
else:
return result
def do_run(command):
result = run(command)
if result.return_code != 0:
print "Error running command: %s" %command
shutdown()
sys.exit(1)
else:
return result
def do_local(command, capture=True):
result = local(command, capture)
if result.return_code != 0:
print "Error running command: %s" %command
shutdown()
sys.exit(1)
else:
return result
def shutdown():
sudo("shutdown -hP now")
do_sudo("poweroff")
time.sleep(30)
def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file):
@ -36,12 +62,14 @@ def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file):
print "File %s already exists. No need to re-download" % os.path.join(vdi_dir, vm_vdi_file)
else:
print "File %s not found. Downloading" % vm_vdi_file
tmpPath = local("mktemp", capture=True)
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, tmpPath))
tmpPath = do_local("mktemp", capture=True)
do_local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, tmpPath))
os.rename(tmpPath, os.path.join(vdi_dir, vm_vdi_file))
local("rm -f %s"%os.path.join(xml_dir, vm_xml_file))
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_xml_file, os.path.join(xml_dir, vm_xml_file)))
if os.path.exists(os.path.join(xml_dir, vm_xml_file)):
print "File %s already exists. No need to re-download" % os.path.join(xml_dir, vm_xml_file)
else:
do_local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_xml_file, os.path.join(xml_dir, vm_xml_file)))
def create_fresh_os(vm_name, debian=False):
@ -57,22 +85,23 @@ def create_fresh_os(vm_name, debian=False):
if not os.path.exists("%s/vm_registered"%vdi_dir):
local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True)
local('VBoxManage storagectl "%s" --name "SATA Controller" --add sata'%vm_name)
local('VBoxManage storageattach "%s" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium %s'%(vm_name, os.path.join(vdi_dir, vm_vdi_file)))
local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir))
local("VBoxManage snapshot %s take fresh_install"%vm_name)
local("touch %s/vm_registered"%vdi_dir)
do_local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True)
do_local('VBoxManage storagectl "%s" --name "SATA Controller" --add sata'%vm_name)
do_local('VBoxManage storageattach "%s" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium %s'%(vm_name, os.path.join(vdi_dir, vm_vdi_file)))
do_local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir))
do_local("VBoxManage snapshot %s take fresh_install"%vm_name)
do_local("touch %s/vm_registered"%vdi_dir)
local('VBoxManage snapshot %s restore fresh_install'%vm_name)
local('VBoxManage startvm %s'%vm_name)
do_local('VBoxManage snapshot %s restore fresh_install'%vm_name)
do_local('VBoxManage modifyvm "%s" --bridgeadapter1 eth0'%vm_name)
do_local('VBoxManage startvm %s'%vm_name)
print "Please wait while attempting to acquire IP address"
time.sleep(15)
try_again = True
while try_again:
ret = local('VBoxManage --nologo guestproperty get "%s" /VirtualBox/GuestInfo/Net/0/V4/IP'%vm_name, capture=True)
ret = do_local('VBoxManage --nologo guestproperty get "%s" /VirtualBox/GuestInfo/Net/0/V4/IP'%vm_name, capture=True)
triple = ret.partition(':')
ip_addr = triple[2].strip(' \r\n')
print "Address found %s"%ip_addr
@ -129,25 +158,27 @@ def debian_squeeze_64(fresh_os=True):
def compile_liquidsoap(filename="liquidsoap"):
sudo('apt-get update')
sudo('apt-get upgrade -y --force-yes')
sudo('sudo apt-get install -y --force-yes ocaml-findlib libao-ocaml-dev libportaudio-ocaml-dev ' + \
do_sudo('apt-get update')
do_sudo('apt-get upgrade -y --force-yes')
do_sudo('apt-get install -y --force-yes ocaml-findlib libao-ocaml-dev libportaudio-ocaml-dev ' + \
'libmad-ocaml-dev libtaglib-ocaml-dev libalsa-ocaml-dev libtaglib-ocaml-dev libvorbis-ocaml-dev ' + \
'libspeex-dev libspeexdsp-dev speex libladspa-ocaml-dev festival festival-dev ' + \
'libsamplerate-dev libxmlplaylist-ocaml-dev libxmlrpc-light-ocaml-dev libflac-dev ' + \
'libxml-dom-perl libxml-dom-xpath-perl icecast2 patch autoconf libmp3lame-dev ' + \
'libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev libjack-dev camlidl')
#libocamlcvs-ocaml-dev
root = '/home/martin/src'
run('mkdir -p %s' % root)
do_run('mkdir -p %s' % root)
tmpPath = local("mktemp", capture=True)
run('wget %s -O %s' % ('https://downloads.sourceforge.net/project/savonet/liquidsoap/1.0.0/liquidsoap-1.0.0-full.tar.bz2', tmpPath))
run('mv %s %s/liquidsoap-1.0.0-full.tar.bz2' % (tmpPath, root))
run('cd %s && bunzip2 liquidsoap-1.0.0-full.tar.bz2 && tar xf liquidsoap-1.0.0-full.tar' % root)
run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root)
run('cd %s/liquidsoap-1.0.0-full && ./configure' % root)
run('cd %s/liquidsoap-1.0.0-full && make' % root)
tmpPath = do_local("mktemp", capture=True)
do_run('wget %s -O %s' % ('https://downloads.sourceforge.net/project/savonet/liquidsoap/1.0.0/liquidsoap-1.0.0-full.tar.bz2', tmpPath))
do_run('mv %s %s/liquidsoap-1.0.0-full.tar.bz2' % (tmpPath, root))
do_run('cd %s && bunzip2 liquidsoap-1.0.0-full.tar.bz2 && tar xf liquidsoap-1.0.0-full.tar' % root)
do_run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root)
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-portaudio', 'ocaml-portaudio')
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-alsa', 'ocaml-alsa')
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-pulseaudio', 'ocaml-pulseaudio')
do_run('cd %s/liquidsoap-1.0.0-full && ./configure' % root)
do_run('cd %s/liquidsoap-1.0.0-full && make' % root)
get('%s/liquidsoap-1.0.0-full/liquidsoap-1.0.0/src/liquidsoap' % root, filename)

View File

@ -106,12 +106,8 @@ def create_fresh_os(vm_name, lucid=False, debian=False):
do_local("VBoxManage snapshot %s take fresh_install"%vm_name)
do_local("touch %s/vm_registered"%vdi_dir)
do_local('VBoxManage snapshot %s restore fresh_install'%vm_name)
do_local('VBoxManage modifyvm "%s" --bridgeadapter1 wlan0'%vm_name)
do_local('VBoxManage startvm %s'%vm_name)
print "Please wait while attempting to acquire IP address"

View File

@ -2,7 +2,7 @@
exec 2>&1
ubuntu_versions=("debian_squeeze_32")
ubuntu_versions=("ubuntu_lucid_32" "ubuntu_lucid_64" "ubuntu_maverick_32" "ubuntu_maverick_64" "ubuntu_natty_32" "ubuntu_natty_64" "ubuntu_oneiric_32" "ubuntu_oneiric_64" "debian_squeeze_32" "debian_squeeze_64")
num1=${#ubuntu_versions[@]}
@ -10,5 +10,6 @@ mkdir -p ./upgrade_logs2
for i in $(seq 0 $(($num1 -1)));
do
fab -f fab_liquidsoap_compile.py ${ubuntu_versions[$i]} compile_liquidsoap:filename=${ubuntu_versions[$i]} shutdown 2>&1 | tee "./upgrade_logs2/${ubuntu_versions[$i]}.log"
echo "fab -f fab_liquidsoap_compile.py ${ubuntu_versions[$i]} compile_liquidsoap:filename=${ubuntu_versions[$i]} shutdown"
fab -f fab_liquidsoap_compile.py ${ubuntu_versions[$i]} compile_liquidsoap:filename=${ubuntu_versions[$i]} shutdown 2>&1 #| tee "./upgrade_logs2/${ubuntu_versions[$i]}.log"
done

View File

@ -7,8 +7,6 @@ if [ `whoami` != 'root' ]; then
exit 1
fi
export WEB_ONLY=0
set +e
DEB=$(dpkg -s airtime 2> /dev/null | grep Status)
set -e
@ -17,6 +15,57 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then
exit 1
fi
showhelp () {
echo "Usage: airtime-install [options]
--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.
--reinstall|-r Force a fresh install of this Airtime Version
--media-monitor|-m Install only media-monitor
--pypo|-p Install only pypo and liquidsoap
--show-recorder|-s Install only show-recorder
--web|-w Install only files for web-server"
}
overwrite="f"
preserve="f"
nodb="f"
reinstall="f"
mediamonitor="f"
pypo="f"
showrecorder="f"
web="f"
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web "hopnrmysw" "$@")
while [ $# -gt 0 ]
do
case "$1" in
(-h|--help) showhelp; exit 0;;
(-o|--overwrite) overwrite="t";;
(-p|--preserve) preserve="t";;
(-n|--no-db) nodb="t";;
(-r|--reinstall) reinstall="t";;
(-m|--media-monitor) mediamonitor="t";;
(-y|--pypo) pypo="t";;
(-s|--show-recorder) showrecorder="t";;
(-w|--web) web="t";;
(--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
if [ "$mediamonitor" = "f" -a "$pypo" = "f" -a "$showrecorder" = "f" -a "$web" = "f" ]; then
#none of these install parameters were specified, so by default we install all of them
mediamonitor="t"
pypo="t"
showrecorder="t"
web="t"
fi
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
@ -24,41 +73,55 @@ SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../
# Check if airtime exists already
echo "* Checking for existing Airtime installation..."
set +e
DO_UPGRADE="0"
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php $@
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php
result=$?
set -e
if [ "$result" -eq "1" ]; then
DO_UPGRADE="0"
if [ "$result" -eq "0" ]; then
echo " * None found."
elif [ "$result" -eq "1" -a "$reinstall" = "f" ]; then
echo " * Same version of Airtime already installed!"
exit 1;
elif [ "$result" -eq "2" ]; then
echo " * Previous version of Airtime already installed..will perform upgrade"
DO_UPGRADE="1"
elif [ "$result" -eq "2" -o "$result" -eq "3" ]; then
elif [ "$result" -eq "3" ]; then
echo " * You require at least Airtime 1.8.0 installed for upgrade"
exit 1
elif [ "$result" -eq "4" ]; then
exit 0
elif [ "$result" -eq "5" ]; then
WEB_ONLY=1
fi
#make DO_UPGRADE available in sub bash scripts
#export these variables to make them available in sub bash scripts
export DO_UPGRADE
export mediamonitor
export pypo
export showrecorder
export web
export reinstall
export nodb
export overwrite
export preserve
if [ "$result" = "2" -o "$result" = "3" ]; then
#error message has already been printed inside the php script
exit 1
fi
set +e
test "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t"
export python_service=$?
set -e
echo -e "\n******************************** Install Begin *********************************"
rm -rf "/usr/lib/airtime"
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
if [ "$python_service" -eq "0" ]; then
rm -rf "/usr/lib/airtime"
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
python $AIRTIMEROOT/python_apps/create-pypo-user.py
fi
python $AIRTIMEROOT/python_apps/create-pypo-user.py
if [ "$DO_UPGRADE" -eq "1" ]; then
#do upgrade
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-upgrade.php $@
@ -67,14 +130,20 @@ fi
$SCRIPTPATH/include/airtime-copy-files.sh
$SCRIPTPATH/include/airtime-initialize.sh $@
#deactivate virtualenv
deactivate
if [ "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" ]; then
#deactivate virtualenv
deactivate
fi
/usr/lib/airtime/utils/rabbitmq-update-pid.sh
echo -e "\n*** Verifying your system environment, running airtime-check-system ***"
sleep 10
airtime-check-system --no-color
/usr/lib/airtime/utils/rabbitmq-update-pid.sh > /dev/null
if [ "$python_service" -eq "0" ]; then
#only run airtime-check-system if all components were installed
echo -e "\n*** Verifying your system environment, running airtime-check-system ***"
sleep 15
airtime-check-system --no-color
fi
echo -e "\n******************************* Install Complete *******************************"

View File

@ -73,44 +73,47 @@ class AirtimeIni
exit(1);
}
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/pypo.cfg", AirtimeIni::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/show-recorder/recorder.cfg", AirtimeIni::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
exit(1);
if (getenv("python_service") == "0"){
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/pypo.cfg", AirtimeIni::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/show-recorder/recorder.cfg", AirtimeIni::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
exit(1);
}
}
}
@ -225,8 +228,10 @@ class AirtimeIni
public static function UpdateIniFiles()
{
$api_key = AirtimeIni::GenerateRandomString();
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key);
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
if (getenv("web") == "t"){
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key);
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
}
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'");
}

View File

@ -51,18 +51,23 @@ HOUR=$(($RANDOM%24))
MIN=$(($RANDOM%60))
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons
#virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
#. ${virtualenv_bin}activate
echo "* Creating /usr/lib/airtime"
if [ "$WEB_ONLY" -eq "0" ]; then
if [ "$python_service" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/api_clients/install/api_client_install.py
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-copy-files.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
fi
if [ "$showrecorder" = "t" ]; then
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-copy-files.py
fi
fi
mkdir -p /usr/lib/airtime
cp -R $AIRTIMEROOT/utils /usr/lib/airtime
echo "* Creating symbolic links in /usr/bin"
@ -72,10 +77,12 @@ ln -sf /usr/lib/airtime/utils/airtime-update-db-settings /usr/bin/airtime-update
ln -sf /usr/lib/airtime/utils/airtime-check-system /usr/bin/airtime-check-system
ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log
echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
if [ "$web" = "t" ]; then
echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
fi
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime

View File

@ -30,12 +30,17 @@ if [ "$DO_UPGRADE" -eq "0" ]; then
fi
set -e
if [ "$WEB_ONLY" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-initialize.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-initialize.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-initialize.py
fi
if [ "$showrecorder" = "t" ]; then
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-initialize.py
fi
# Start monit if it is not running, or restart if it is.
# Need to ensure monit is running before Airtime daemons are run. This is
# so we can ensure they can register with monit to monitor them when they start.
@ -47,10 +52,15 @@ fi
sleep 1
set +e
if [ "$WEB_ONLY" -eq "0" ]; then
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
monit monitor airtime-media-monitor
fi
if [ "$showrecorder" = "t" ]; then
monit monitor airtime-show-recorder
fi

View File

@ -11,23 +11,8 @@ require_once(dirname(__FILE__).'/AirtimeIni.php');
require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
$opts = AirtimeInstall::getOpts();
if ($opts == NULL) {
exit(1);
}
$version = AirtimeInstall::GetVersionInstalled();
// A previous version exists - if so, upgrade.
/*
if (isset($version) && ($version != false) && ($version < AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime version $version found.".PHP_EOL;
require_once("airtime-upgrade.php");
exit(0);
}
* */
// -------------------------------------------------------------------------
// The only way we get here is if we are doing a new install or a reinstall.
// -------------------------------------------------------------------------
@ -38,14 +23,14 @@ if(is_null($version)) {
}
$db_install = true;
if (is_null($opts->r) && isset($opts->n)) {
if (getenv("nodb")=="t") {
$db_install = false;
}
$overwrite = false;
if (isset($opts->o) || $newInstall == true) {
if (getenv("overwrite") == "t" || $newInstall == true) {
$overwrite = true;
} else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
} else if (getenv("preserve") == "f" && getenv("overwrite") == "f" && getenv("reinstall") == "t") {
if (AirtimeIni::IniFilesExist()) {
$userAnswer = "x";
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
@ -80,7 +65,7 @@ if ($db_install) {
if($newInstall) {
//call external script. "y" argument means force creation of database tables.
passthru('php '.__DIR__.'/airtime-db-install.php y');
AirtimeInstall::DbConnect(true);
//AirtimeInstall::DbConnect(true);
} else {
require_once('airtime-db-install.php');
}

View File

@ -9,51 +9,32 @@
* choose -r to reinstall.
*
* Returns 0 if Airtime is not installed
* Returns 1 if a previous version of Airtime installed
* Returns 2 if the same version of Airtime is installed
* Returns 3 if a version of Airtime that we can't upgrade from is installed.
* Returns 4 if we need to print help message.
* Returns 5 if we need should only install apache files (web-only).
* Returns 1 if the same version of Airtime already installed
* Returns 2 if a previous version of Airtime is installed we can upgrade from
* Returns 3 if a version of Airtime is installed that we can't upgrade from.
*/
require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
AirtimeInstall::ExitIfNotRoot();
$opts = AirtimeInstall::getOpts();
if (is_null($opts)) {
exit(0);
}
if (isset($opts->h)) {
AirtimeInstall::printUsage($opts);
exit(4);
}
//install media-monitor
if (isset($opts->w)){
exit(5);
}
$version = AirtimeInstall::GetVersionInstalled();
// The current version is already installed.
echo "* Checking for existing install of Airtime...".PHP_EOL;
if (isset($version) && ($version != false)){
if (($version == AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime $version is already installed.".PHP_EOL;
AirtimeInstall::printUsage($opts);
exit(2);
} else if (strcmp($version, AIRTIME_VERSION) < 0){
echo " * Found previous version: $version".PHP_EOL;
exit(1);
if (isset($version)){
if ($version === false){
//version of Airtime older than 1.7.0 detected
exit(3);
} else {
if (($version == AIRTIME_VERSION)) {
//same version of Airtime is already installed
exit(1);
} else if (strcmp($version, AIRTIME_VERSION) < 0){
//previous version of Airtime is installed.
exit(2);
}
}
} else {
echo " * Not Found".PHP_EOL;
}
if($version === false){
echo "A version of Airtime older than 1.7.0 detected, please upgrade to 1.7.0 first.\n";
echo "You will then be able to upgrade to 1.9.0 using this installer.\n";
exit(3);
//no previous version of Airtime found
exit(0);
}

View File

@ -162,6 +162,7 @@ class AirtimeDatabaseUpgrade{
INSERT INTO cc_pref(keystr, valstr) VALUES('plan_level', 'disabled');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('output_sound_device', 'false', 'boolean');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('output_sound_device_type', 'ALSA', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_enable', 'true', 'boolean');

View File

@ -6,6 +6,7 @@
# Output settings #
###########################################
output_sound_device = false
output_sound_device_type = "ALSA"
s1_output = "icecast"
s2_output = "icecast"
s3_output = "icecast"

View File

@ -11,23 +11,6 @@ if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
"""
def is_natty():
try:
f = open('/etc/lsb-release')
except IOError as e:
#File doesn't exist, so we're not even dealing with Ubuntu
return False
for line in f:
split = line.split("=")
split[0] = split[0].strip(" \r\n")
split[1] = split[1].strip(" \r\n")
if split[0] == "DISTRIB_CODENAME" and (split[1] == "natty" or split[1] == "oneiric"):
return True
return False
"""
"""
This function returns the codename of the host OS by querying lsb_release.
If lsb_release does not exist, or an exception occurs the codename returned

View File

@ -1,6 +1,54 @@
# Decoders, enabled when the binary is detected and the os is not Win32.
%ifdef add_decoder
# Enable external Musepack decoder. Requires the
# mpcdec binary in the path. Does not work on
# Win32.
def enable_external_mpc_decoder() =
# A list of know extensions and content-type for Musepack.
# Values from http://en.wikipedia.org/wiki/Musepack
mpc_mimes = [ "audio/x-musepack", "audio/musepack" ]
mpc_filexts = [ "mpc", "mp+", "mpp" ]
def test_mpc(file) =
def get_channels(file) =
int_of_string(
list.hd(
get_process_lines("mpcdec -i #{quote(file)} 2>&1 \
| grep channels | cut -d' ' -f 2")))
end
# Get the file's mime
mime = get_mime(file)
# Test mime
if list.mem(mime,mpc_mimes) then
get_channels(file)
else
# Otherwise test file extension
ret = string.extract(pattern='\.(.+)$',file)
if list.length(ret) != 0 then
ext = ret["1"]
if list.mem(ext,mpc_filexts) then
get_channels(file)
else
0
end
else
get_channels(file)
end
end
end
if test_process("which mpcdec") then
log(level=3,"Found mpcdec binary: enabling musepack external decoder.")
mpcdec_p = fun(f) -> "mpcdec #{quote(f)} - 2>/dev/null"
add_oblivious_decoder(name="MPCDEC",description="Decode files using the mpcdec \
musepack decoder binary",test=test_mpc,mpcdec_p)
else
log(level=3,"Did not find mpcdec binary: musepack decoder disabled.")
end
end
# Enable external FLAC decoders. Requires flac binary
# in the path for audio decoding and metaflac binary for
# metadata. Does not work on Win32. Default: disabled.
@ -30,7 +78,7 @@ def enable_external_flac_decoder() =
end
end
end
add_decoder(name="FLAC",description="Decode files using the flac \
add_decoder(name="EXTERNAL_FLAC",description="Decode files using the flac \
decoder binary.", test=test_flac,flac_p)
else
log(level=3,"Did not find flac binary: flac decoder disabled.")
@ -57,7 +105,7 @@ def enable_external_flac_decoder() =
end
list.fold(f,[],ret)
end
add_metadata_resolver("FLAC",flac_meta)
add_metadata_resolver("EXTERNAL_FLAC",flac_meta)
else
log(level=3,"Did not find metaflac binary: flac metadata resolver disabled.")
end
@ -126,7 +174,7 @@ def enable_external_faad_decoder() =
0
end
end
add_oblivious_decoder(name="FAAD",description="Decode files using \
add_oblivious_decoder(name="EXTERNAL_FAAD",description="Decode files using \
the faad binary.", test=test_faad, faad_p)
def faad_meta(file) =
if faad_test(file) then
@ -146,7 +194,7 @@ def enable_external_faad_decoder() =
[]
end
end
add_metadata_resolver("FAAD",faad_meta)
add_metadata_resolver("EXTERNAL_FAAD",faad_meta)
else
log(level=3,"Did not find faad binary: faad decoder disabled.")
end

View File

@ -341,34 +341,6 @@ def server.rms(~id="",s) =
s
end
# Get the base name of a path.
# Implemented using the corresponding shell command.
# @category System
# @param s Path
def basename(s)
lines = get_process_lines("basename #{quote(s)}")
if list.length(lines) > 0 then
list.hd(lines)
else
# Don't know what to do.. output s
s
end
end
# Get the directory name of a path.
# Implemented using the corresponding shell command.
# @category System
# @param s Path
# @param ~default Value returned in case of error.
def dirname(~default="/nonexistent",s)
lines = get_process_lines("dirname #{quote(s)}")
if list.length(lines) > 0 then
list.hd(lines)
else
default
end
end
# Read some value from standard input (console).
# @category System
# @param ~hide Hide typed characters (for passwords).

View File

@ -6,6 +6,7 @@
# Output settings #
###########################################
output_sound_device = false
output_sound_device_type = "ALSA"
s1_output = "icecast"
s2_output = "icecast"
s3_output = "icecast"

View File

@ -53,7 +53,50 @@ add_skip_command(s)
s = map_metadata(append_title, s)
if output_sound_device then
ignore(out(s))
success = ref false
log(output_sound_device_type)
%ifdef output.alsa
if output_sound_device_type == "ALSA" then
ignore(output.alsa(s))
success := true
end
%endif
%ifdef output.ao
if output_sound_device_type == "AO" then
ignore(output.ao(s))
success := true
end
%endif
%ifdef output.oss
if output_sound_device_type == "OSS" then
ignore(output.oss(s))
success := true
end
%endif
%ifdef output.portaudio
if output_sound_device_type == "Portaudio" then
ignore(output.portaudio(s))
success := true
end
%endif
%ifdef output.pulseaudio
if output_sound_device_type == "Pulseaudio" then
ignore(output.pulseaudio(s))
success := true
end
%endif
if (!success == false) then
ignore(output.prefered(s))
end
end
if s1_enable == true then