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['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
$values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
} }
if(!$error){ if(!$error){
Application_Model_StreamSetting::setStreamSetting($values); Application_Model_StreamSetting::setStreamSetting($values);

View File

@ -385,14 +385,6 @@ class ScheduleController extends Zend_Controller_Action
$start_timestamp = $show->getShowInstanceStart(); $start_timestamp = $show->getShowInstanceStart();
$end_timestamp = $show->getShowInstanceEnd(); $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_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp)));
$dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp))); $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp)));
@ -574,7 +566,7 @@ class ScheduleController extends Zend_Controller_Action
$i = 1; $i = 1;
foreach ($rebroadcastsAbsolute as $rebroadcast){ foreach ($rebroadcastsAbsolute as $rebroadcast){
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; $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++; $i++;
} }
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);

View File

@ -25,6 +25,17 @@ class Application_Form_StreamSetting extends Zend_Form
$output_sound_device->setAttrib("readonly", true); $output_sound_device->setAttrib("readonly", true);
} }
$this->addElement($output_sound_device); $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'); $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){ 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; return true;
} }
} }

View File

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

View File

@ -105,6 +105,13 @@ class Application_Model_Show {
return $res; return $res;
} }
//remove everything about this show.
public function deleteShow()
{
$show = CcShowQuery::create()->findPK($this->_showId);
$show->delete();
}
public function resizeShow($deltaDay, $deltaMin) public function resizeShow($deltaDay, $deltaMin)
{ {
global $CC_DBC; global $CC_DBC;
@ -278,22 +285,27 @@ class Application_Model_Show {
global $CC_DBC; global $CC_DBC;
$showId = $this->getId(); $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)){ $sql = "SELECT starts FROM cc_show_instances "
return array(); ."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 " return $rebroadcastsLocal;
."WHERE show_id = $showId "
."ORDER BY start_date";
return $CC_DBC->GetAll($sql);
} }
/** /**
@ -1224,8 +1236,10 @@ class Application_Model_Show {
$showInstance->correctScheduleStartTimes(); $showInstance->correctScheduleStartTimes();
} }
//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); self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
}
if ($p_interval == 'P1M'){ if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP. /* When adding months, there is a problem if we are on January 31st and add one month with PHP.

View File

@ -175,63 +175,104 @@ class Application_Model_ShowInstance {
Application_Model_RabbitMq::PushSchedule(); 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) public function moveShow($deltaDay, $deltaMin)
{ {
global $CC_DBC;
if ($this->getShow()->isRepeating()){ if ($this->getShow()->isRepeating()){
return "Can't drag and drop repeating shows"; 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(); $today_timestamp = time();
$starts = $this->getShowInstanceStart(); $startsDateTime = new DateTime($this->getShowInstanceStart(), new DateTimeZone("UTC"));
$ends = $this->getShowInstanceEnd(); $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"; return "Can't move a past show";
} }
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; //the user is moving the show on the calendar from the perspective of local time.
$new_starts = $CC_DBC->GetOne($sql); //incase a show is moved across a time change border offsets should be added to the localtime
$newStartsDateTime = new DateTime($new_starts, new DateTimeZone("UTC")); //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}'"; $newStartsDateTime = self::addDeltas($startsDateTime, $deltaDay, $deltaMin);
$new_ends = $CC_DBC->GetOne($sql); $newEndsDateTime = self::addDeltas($endsDateTime, $deltaDay, $deltaMin);
$newEndsDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
//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"; return "Can't move show into past";
} }
$overlap = Application_Model_Show::getShows($newStartsDateTime, $newEndsDateTime, array($this->_instanceId)); if ($this->isRebroadcast()) {
if(count($overlap) > 0) { try {
return "Should not overlap shows"; $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(); $recordEndDateTime = new DateTime($recordedShow->getShowInstanceEnd(), new DateTimeZone("UTC"));
if($rebroadcast) { $newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60);
$sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})";
$isBeforeRecordedOriginal = $CC_DBC->GetOne($sql);
if($isBeforeRecordedOriginal === 't'){ if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) {
return "Cannot move a rebroadcast show before its original show"; return "Must wait 1 hour to rebroadcast.";
} }
} }
$this->setShowStart($new_starts); $this->setShowStart($newStartsDateTime);
$this->setShowEnd($new_ends); $this->setShowEnd($newEndsDateTime);
$this->correctScheduleStartTimes(); $this->correctScheduleStartTimes();
$show = new Application_Model_Show($this->getShowId()); $show = new Application_Model_Show($this->getShowId());
@ -399,19 +440,30 @@ class Application_Model_ShowInstance {
global $CC_DBC; global $CC_DBC;
// see if it was recording show // see if it was recording show
$recording = CcShowInstancesQuery::create() $recording = $this->isRecorded();
->findPK($this->_instanceId)
->getDbRecord();
// get show id // get show id
$showId = CcShowInstancesQuery::create() $showId = $this->getShowId();
->findPK($this->_instanceId)
->getDbShowId(); $show = $this->getShow();
$current_timestamp = gmdate("Y-m-d H:i");
if ($current_timestamp < $this->getShowInstanceStart()) {
if ($show->isRepeating()) {
CcShowInstancesQuery::create() CcShowInstancesQuery::create()
->findPK($this->_instanceId) ->findPK($this->_instanceId)
->setDbModifiedInstance(true) ->setDbModifiedInstance(true)
->save(); ->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. */ /* Automatically delete all files scheduled in cc_schedules table. */
CcScheduleQuery::create() CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId) ->filterByDbInstanceId($this->_instanceId)
@ -423,8 +475,6 @@ class Application_Model_ShowInstance {
->filterByDbModifiedInstance(false) ->filterByDbModifiedInstance(false)
->findOne(); ->findOne();
/* If we didn't find any instances of the show that haven't /* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show. * been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should * We can just delete, the show and the foreign key-constraint should
@ -434,6 +484,12 @@ class Application_Model_ShowInstance {
->filterByDbId($showId) ->filterByDbId($showId)
->delete(); ->delete();
} }
}
else {
$show->deleteShow();
}
}
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
if($recording){ if($recording){

View File

@ -629,7 +629,7 @@ class Application_Model_StoredFile {
public static function searchFilesForPlaylistBuilder($datatables) { public static function searchFilesForPlaylistBuilder($datatables) {
global $CC_CONFIG; 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 "; $plSelect = "SELECT ";
$fileSelect = "SELECT "; $fileSelect = "SELECT ";

View File

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

View File

@ -20,6 +20,14 @@
<dd id="hardwareOut-element"> <dd id="hardwareOut-element">
<?php echo $this->form->getElement('output_sound_device') ?> <?php echo $this->form->getElement('output_sound_device') ?>
</dd> </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 } ?> <?php } ?>
<dt id="vorbisMetadata-label"> <dt id="vorbisMetadata-label">
<label class="required"> <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_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', '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 ('icecast_vorbis_metadata', 'false', 'boolean');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_enable', 'true', '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" }, /* Title */ { "sName": "track_title" },
/* Creator */ { "sName": "artist_name" }, /* Creator */ { "sName": "artist_name" },
/* Album */ { "sName": "album_title" }, /* Album */ { "sName": "album_title" },
/* Track */ { "sName": "track_number" }, /* Genre */ { "sName": "genre" },
/* Length */ { "sName": "length" }, /* Length */ { "sName": "length" },
/* Type */ { "sName": "ftype", "bSearchable": false } /* Type */ { "sName": "ftype", "bSearchable": false }
], ],

View File

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

View File

@ -125,6 +125,14 @@ $(document).ready(function() {
rebuildStreamURL($(this)) 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(){ $("select[id$=data-type]").change(function(){
if($(this).val() == 'ogg'){ if($(this).val() == 'ogg'){
restrictOggBitrate($(this), true) 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 #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(): def shutdown():
sudo("shutdown -hP now") do_sudo("poweroff")
time.sleep(30) time.sleep(30)
def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file): 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) print "File %s already exists. No need to re-download" % os.path.join(vdi_dir, vm_vdi_file)
else: else:
print "File %s not found. Downloading" % vm_vdi_file print "File %s not found. Downloading" % vm_vdi_file
tmpPath = local("mktemp", capture=True) tmpPath = do_local("mktemp", capture=True)
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, tmpPath)) 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)) os.rename(tmpPath, os.path.join(vdi_dir, vm_vdi_file))
local("rm -f %s"%os.path.join(xml_dir, vm_xml_file)) if os.path.exists(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))) 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): 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): if not os.path.exists("%s/vm_registered"%vdi_dir):
local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True) do_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) do_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))) 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)))
local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir)) do_local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir))
local("VBoxManage snapshot %s take fresh_install"%vm_name) do_local("VBoxManage snapshot %s take fresh_install"%vm_name)
local("touch %s/vm_registered"%vdi_dir) do_local("touch %s/vm_registered"%vdi_dir)
local('VBoxManage snapshot %s restore fresh_install'%vm_name) do_local('VBoxManage snapshot %s restore fresh_install'%vm_name)
local('VBoxManage startvm %s'%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" print "Please wait while attempting to acquire IP address"
time.sleep(15) time.sleep(15)
try_again = True try_again = True
while try_again: 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(':') triple = ret.partition(':')
ip_addr = triple[2].strip(' \r\n') ip_addr = triple[2].strip(' \r\n')
print "Address found %s"%ip_addr print "Address found %s"%ip_addr
@ -129,25 +158,27 @@ def debian_squeeze_64(fresh_os=True):
def compile_liquidsoap(filename="liquidsoap"): def compile_liquidsoap(filename="liquidsoap"):
sudo('apt-get update') do_sudo('apt-get update')
sudo('apt-get upgrade -y --force-yes') do_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 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 ' + \ '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 ' + \ 'libspeex-dev libspeexdsp-dev speex libladspa-ocaml-dev festival festival-dev ' + \
'libsamplerate-dev libxmlplaylist-ocaml-dev libxmlrpc-light-ocaml-dev libflac-dev ' + \ 'libsamplerate-dev libxmlplaylist-ocaml-dev libxmlrpc-light-ocaml-dev libflac-dev ' + \
'libxml-dom-perl libxml-dom-xpath-perl icecast2 patch autoconf libmp3lame-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') 'libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev libjack-dev camlidl')
#libocamlcvs-ocaml-dev
root = '/home/martin/src' root = '/home/martin/src'
run('mkdir -p %s' % root) do_run('mkdir -p %s' % root)
tmpPath = local("mktemp", capture=True) tmpPath = do_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)) do_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)) do_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) do_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) do_run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root)
run('cd %s/liquidsoap-1.0.0-full && make' % 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) 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("VBoxManage snapshot %s take fresh_install"%vm_name)
do_local("touch %s/vm_registered"%vdi_dir) do_local("touch %s/vm_registered"%vdi_dir)
do_local('VBoxManage snapshot %s restore fresh_install'%vm_name) do_local('VBoxManage snapshot %s restore fresh_install'%vm_name)
do_local('VBoxManage modifyvm "%s" --bridgeadapter1 wlan0'%vm_name) do_local('VBoxManage modifyvm "%s" --bridgeadapter1 wlan0'%vm_name)
do_local('VBoxManage startvm %s'%vm_name) do_local('VBoxManage startvm %s'%vm_name)
print "Please wait while attempting to acquire IP address" print "Please wait while attempting to acquire IP address"

View File

@ -2,7 +2,7 @@
exec 2>&1 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[@]} num1=${#ubuntu_versions[@]}
@ -10,5 +10,6 @@ mkdir -p ./upgrade_logs2
for i in $(seq 0 $(($num1 -1))); for i in $(seq 0 $(($num1 -1)));
do 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 done

View File

@ -7,8 +7,6 @@ if [ `whoami` != 'root' ]; then
exit 1 exit 1
fi fi
export WEB_ONLY=0
set +e set +e
DEB=$(dpkg -s airtime 2> /dev/null | grep Status) DEB=$(dpkg -s airtime 2> /dev/null | grep Status)
set -e set -e
@ -17,6 +15,57 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then
exit 1 exit 1
fi 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 # Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0` SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin # Absolute path this script is in, thus /home/user/bin
@ -24,40 +73,54 @@ SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../ AIRTIMEROOT=$SCRIPTPATH/../
# Check if airtime exists already # Check if airtime exists already
echo "* Checking for existing Airtime installation..."
set +e 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=$? result=$?
set -e 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" 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 exit 1
elif [ "$result" -eq "4" ]; then
exit 0
elif [ "$result" -eq "5" ]; then
WEB_ONLY=1
fi fi
#make DO_UPGRADE available in sub bash scripts
#export these variables to make them available in sub bash scripts
export DO_UPGRADE 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 set +e
#error message has already been printed inside the php script test "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t"
exit 1 export python_service=$?
fi set -e
echo -e "\n******************************** Install Begin *********************************" echo -e "\n******************************** Install Begin *********************************"
if [ "$python_service" -eq "0" ]; then
rm -rf "/usr/lib/airtime" rm -rf "/usr/lib/airtime"
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh $AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate . ${virtualenv_bin}activate
python $AIRTIMEROOT/python_apps/create-pypo-user.py python $AIRTIMEROOT/python_apps/create-pypo-user.py
fi
if [ "$DO_UPGRADE" -eq "1" ]; then if [ "$DO_UPGRADE" -eq "1" ]; then
#do upgrade #do upgrade
@ -67,14 +130,20 @@ fi
$SCRIPTPATH/include/airtime-copy-files.sh $SCRIPTPATH/include/airtime-copy-files.sh
$SCRIPTPATH/include/airtime-initialize.sh $@ $SCRIPTPATH/include/airtime-initialize.sh $@
if [ "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" ]; then
#deactivate virtualenv #deactivate virtualenv
deactivate deactivate
fi
/usr/lib/airtime/utils/rabbitmq-update-pid.sh
/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 ***" echo -e "\n*** Verifying your system environment, running airtime-check-system ***"
sleep 10 sleep 15
airtime-check-system --no-color
airtime-check-system --no-color
fi
echo -e "\n******************************* Install Complete *******************************" echo -e "\n******************************* Install Complete *******************************"

View File

@ -73,6 +73,8 @@ class AirtimeIni
exit(1); exit(1);
} }
if (getenv("python_service") == "0"){
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){ 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."; echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1); exit(1);
@ -113,6 +115,7 @@ class AirtimeIni
exit(1); exit(1);
} }
} }
}
public static function ChangeFileOwnerGroupMod($filename, $user){ public static function ChangeFileOwnerGroupMod($filename, $user){
return (chown($filename, $user) && return (chown($filename, $user) &&
@ -225,8 +228,10 @@ class AirtimeIni
public static function UpdateIniFiles() public static function UpdateIniFiles()
{ {
$api_key = AirtimeIni::GenerateRandomString(); $api_key = AirtimeIni::GenerateRandomString();
if (getenv("web") == "t"){
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key); 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_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
}
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'"); AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'");
} }

View File

@ -51,18 +51,23 @@ HOUR=$(($RANDOM%24))
MIN=$(($RANDOM%60)) MIN=$(($RANDOM%60))
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons 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" 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/api_clients/install/api_client_install.py
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py 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 python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-copy-files.py
fi fi
fi
mkdir -p /usr/lib/airtime
cp -R $AIRTIMEROOT/utils /usr/lib/airtime cp -R $AIRTIMEROOT/utils /usr/lib/airtime
echo "* Creating symbolic links in /usr/bin" 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-check-system /usr/bin/airtime-check-system
ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log
if [ "$web" = "t" ]; then
echo "* Creating /usr/share/airtime" echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime" rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/ cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
fi
echo "* Creating /var/log/airtime" echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime mkdir -p /var/log/airtime

View File

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

View File

@ -11,23 +11,8 @@ require_once(dirname(__FILE__).'/AirtimeIni.php');
require_once(dirname(__FILE__).'/AirtimeInstall.php'); require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php'); require_once(__DIR__.'/airtime-constants.php');
$opts = AirtimeInstall::getOpts();
if ($opts == NULL) {
exit(1);
}
$version = AirtimeInstall::GetVersionInstalled(); $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. // 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; $db_install = true;
if (is_null($opts->r) && isset($opts->n)) { if (getenv("nodb")=="t") {
$db_install = false; $db_install = false;
} }
$overwrite = false; $overwrite = false;
if (isset($opts->o) || $newInstall == true) { if (getenv("overwrite") == "t" || $newInstall == true) {
$overwrite = 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()) { if (AirtimeIni::IniFilesExist()) {
$userAnswer = "x"; $userAnswer = "x";
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) { while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
@ -80,7 +65,7 @@ if ($db_install) {
if($newInstall) { if($newInstall) {
//call external script. "y" argument means force creation of database tables. //call external script. "y" argument means force creation of database tables.
passthru('php '.__DIR__.'/airtime-db-install.php y'); passthru('php '.__DIR__.'/airtime-db-install.php y');
AirtimeInstall::DbConnect(true); //AirtimeInstall::DbConnect(true);
} else { } else {
require_once('airtime-db-install.php'); require_once('airtime-db-install.php');
} }

View File

@ -9,51 +9,32 @@
* choose -r to reinstall. * choose -r to reinstall.
* *
* Returns 0 if Airtime is not installed * Returns 0 if Airtime is not installed
* Returns 1 if a previous version of Airtime installed * Returns 1 if the same version of Airtime already installed
* Returns 2 if the same version of Airtime is installed * Returns 2 if a previous version of Airtime is installed we can upgrade from
* Returns 3 if a version of Airtime that we can't upgrade from is installed. * Returns 3 if a version of Airtime is installed that we can't upgrade from.
* Returns 4 if we need to print help message.
* Returns 5 if we need should only install apache files (web-only).
*/ */
require_once(dirname(__FILE__).'/AirtimeInstall.php'); require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php'); require_once(__DIR__.'/airtime-constants.php');
AirtimeInstall::ExitIfNotRoot(); 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(); $version = AirtimeInstall::GetVersionInstalled();
// The current version is already installed. // The current version is already installed.
echo "* Checking for existing install of Airtime...".PHP_EOL; echo "* Checking for existing install of Airtime...".PHP_EOL;
if (isset($version) && ($version != false)){ if (isset($version)){
if (($version == AIRTIME_VERSION) && !isset($opts->r)) { if ($version === false){
echo "Airtime $version is already installed.".PHP_EOL; //version of Airtime older than 1.7.0 detected
AirtimeInstall::printUsage($opts); exit(3);
exit(2); } else {
} else if (strcmp($version, AIRTIME_VERSION) < 0){ if (($version == AIRTIME_VERSION)) {
echo " * Found previous version: $version".PHP_EOL; //same version of Airtime is already installed
exit(1); exit(1);
} else if (strcmp($version, AIRTIME_VERSION) < 0){
//previous version of Airtime is installed.
exit(2);
}
} }
} else { } else {
echo " * Not Found".PHP_EOL; //no previous version of Airtime found
} exit(0);
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);
} }

View File

@ -162,6 +162,7 @@ class AirtimeDatabaseUpgrade{
INSERT INTO cc_pref(keystr, valstr) VALUES('plan_level', 'disabled'); 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', '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 ('icecast_vorbis_metadata', 'false', 'boolean');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_enable', 'true', 'boolean'); INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_enable', 'true', 'boolean');

View File

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

View File

@ -11,23 +11,6 @@ if os.geteuid() != 0:
print "Please run this as root." print "Please run this as root."
sys.exit(1) 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. 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 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. # Decoders, enabled when the binary is detected and the os is not Win32.
%ifdef add_decoder %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 # Enable external FLAC decoders. Requires flac binary
# in the path for audio decoding and metaflac binary for # in the path for audio decoding and metaflac binary for
# metadata. Does not work on Win32. Default: disabled. # metadata. Does not work on Win32. Default: disabled.
@ -30,7 +78,7 @@ def enable_external_flac_decoder() =
end end
end 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) decoder binary.", test=test_flac,flac_p)
else else
log(level=3,"Did not find flac binary: flac decoder disabled.") log(level=3,"Did not find flac binary: flac decoder disabled.")
@ -57,7 +105,7 @@ def enable_external_flac_decoder() =
end end
list.fold(f,[],ret) list.fold(f,[],ret)
end end
add_metadata_resolver("FLAC",flac_meta) add_metadata_resolver("EXTERNAL_FLAC",flac_meta)
else else
log(level=3,"Did not find metaflac binary: flac metadata resolver disabled.") log(level=3,"Did not find metaflac binary: flac metadata resolver disabled.")
end end
@ -126,7 +174,7 @@ def enable_external_faad_decoder() =
0 0
end end
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) the faad binary.", test=test_faad, faad_p)
def faad_meta(file) = def faad_meta(file) =
if faad_test(file) then if faad_test(file) then
@ -146,7 +194,7 @@ def enable_external_faad_decoder() =
[] []
end end
end end
add_metadata_resolver("FAAD",faad_meta) add_metadata_resolver("EXTERNAL_FAAD",faad_meta)
else else
log(level=3,"Did not find faad binary: faad decoder disabled.") log(level=3,"Did not find faad binary: faad decoder disabled.")
end end

View File

@ -341,34 +341,6 @@ def server.rms(~id="",s) =
s s
end 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). # Read some value from standard input (console).
# @category System # @category System
# @param ~hide Hide typed characters (for passwords). # @param ~hide Hide typed characters (for passwords).

View File

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

View File

@ -53,7 +53,50 @@ add_skip_command(s)
s = map_metadata(append_title, s) s = map_metadata(append_title, s)
if output_sound_device then 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 end
if s1_enable == true then if s1_enable == true then