Merge saas-dev into soundcloud

This commit is contained in:
Duncan Sommerville 2015-06-10 16:08:52 -04:00
commit 459f9494c3
373 changed files with 6577 additions and 10376 deletions

View file

@ -0,0 +1,53 @@
<?php
$tempConfigPath = "/etc/airtime/airtime.conf.tmp";
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$db = $airtimeConfig["database"];
}
?>
<form action="#" role="form" id="dbSettingsForm">
<h3 class="form-title">Database Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Enter your Airtime database settings here. Empty or non-existent databases will be created and populated
if the given user has administrative permissions in postgres.
</p>
<div class="form-group">
<label class="control-label" for="dbUser">Username</label>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username"
value="<?php echo (isset($db) ? $db["dbuser"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbPass">Password</label>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password"
value="<?php echo (isset($db) ? $db["dbpass"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbName">Name</label>
<input required class="form-control" type="text" name="dbName" id="dbName" placeholder="Name"
value="<?php echo (isset($db) ? $db["dbname"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbHost">Host</label>
<input required class="form-control" type="text" name="dbHost" id="dbHost" placeholder="Host"
value="<?php echo (isset($db) ? $db["host"] : "localhost"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="dbErr" id="dbErr" aria-describedby="helpBlock"/>
<div>
<p style="text-align:right">
This may take up to 30 seconds to complete!
</p>
<input type="submit" formtarget="dbSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
</div>
</form>
<script>
$("#dbSettingsForm").submit(function(e) {
submitForm(e, "DatabaseSetup");
});
</script>

View file

@ -0,0 +1,30 @@
<?php
?>
<form action="#" role="form" id="finishSettingsForm">
<h3 class="form-title">Manual Step: Start Airtime Services</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Looks like you're almost done! As a final step, please run the following commands from the terminal:
</p>
<pre style="text-align: left">sudo service airtime-playout start
sudo service airtime-liquidsoap start
sudo service airtime-media-monitor start</pre>
<p>
Click "Done!" to bring up the Airtime configuration checklist; if your configuration is all green,
you're ready to get started with your personal Airtime station!
</p>
<p>
If you need to re-run the web installer, just remove <code>/etc/airtime/airtime.conf</code>.
</p>
<div>
<input type="submit" formtarget="finishSettingsForm" class="btn btn-primary btn-next" value="Done!"/>
</div>
</form>
<script>
$("#finishSettingsForm").submit(function(e) {
e.preventDefault();
window.location.assign("/?config");
});
</script>

View file

@ -0,0 +1,33 @@
<?php
?>
<form action="#" role="form" id="generalSettingsForm">
<h3 class="form-title">General Settings</h3>
<p>
These values are automatically pulled from your webserver settings, under most circumstances you will not need to change them.
</p>
<span id="helpBlock" class="help-block help-message"></span>
<div id="generalFormBody">
<div class="form-group">
<label class="control-label" for="generalHost">Webserver Host</label>
<input required class="form-control" type="text" name="generalHost" id="generalHost" placeholder="Host" value="<?=$_SERVER["SERVER_NAME"]?>"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="generalPort">Webserver Port</label>
<input required class="form-control" type="text" name="generalPort" id="generalPort" placeholder="Port" value="<?=$_SERVER["SERVER_PORT"]?>"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="generalErr" id="generalErr" aria-describedby="helpBlock"/>
</div>
<div>
<input type="submit" formtarget="generalSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#generalSettingsForm").submit(function(e) {
submitForm(e, "GeneralSetup");
});
</script>

View file

@ -0,0 +1,30 @@
<?php
?>
<form action="#" role="form" id="mediaSettingsForm">
<h3 class="form-title">Media Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Here you can set the default media storage directory for Airtime. If left blank, we'll create a new
directory located at <code>/srv/airtime/stor/</code> for you.
</p>
<div class="form-group">
<label class="control-label" for="mediaFolder">Media folder</label>
<input class="form-control" type="text" name="mediaFolder" id="mediaFolder" placeholder="/path/to/my/airtime/music/directory/"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="mediaHelpBlock" class="help-block">
Note that you need to enter the <strong>fully qualified</strong> path name!
</span>
</div>
<input class="form-control" type="hidden" name="mediaErr" id="mediaErr" aria-describedby="helpBlock"/>
<div>
<input type="submit" formtarget="mediaSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#mediaSettingsForm").submit(function(e) {
submitForm(e, "MediaSetup");
});
</script>

View file

@ -0,0 +1,75 @@
<?php
$tempConfigPath = "/etc/airtime/airtime.conf.tmp";
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$rmq = $airtimeConfig["rabbitmq"];
}
?>
<form action="#" role="form" id="rmqSettingsForm">
<h3 class="form-title">RabbitMQ Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
RabbitMQ is an AMQP-based messaging system used by Airtime. You should only edit these settings
if you have changed the defaults since running the installer, or if you've opted to install RabbitMQ manually.
</p>
<p>
In either case, we recommend that you change at least the default password provided -
you can do this by running the following line from the command line:<br/>
<code>sudo rabbitmqctl change_password &lt;username&gt; &lt;newpassword&gt;</code>
</p>
<div id="rmqSlideToggle">
<span><strong>Advanced </strong></span><span id="advCaret" class="caret"></span><hr/>
</div>
<div id="rmqFormBody">
<div class="form-group">
<label class="control-label" for="rmqUser">Username</label>
<input required class="form-control" type="text" name="rmqUser" id="rmqUser" placeholder="Username"
value="<?php echo (isset($rmq) ? $rmq["user"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPass">Password</label>
<input class="form-control" type="password" name="rmqPass" id="rmqPass" placeholder="Password"
value="<?php echo (isset($rmq) ? $rmq["password"] : "airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="rmqHelpBlock" class="help-block">
You probably want to change this!
</span>
</div>
<div class="form-group">
<label class="control-label" for="rmqHost">Host</label>
<input required class="form-control" type="text" name="rmqHost" id="rmqHost" placeholder="Host"
value="<?php echo (isset($rmq) ? $rmq["host"] : "127.0.0.1"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPort">Port</label>
<input required class="form-control" type="text" name="rmqPort" id="rmqPort" placeholder="Port"
value="<?php echo (isset($rmq) ? $rmq["port"] : "5672"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqVHost">Virtual Host</label>
<input required class="form-control" type="text" name="rmqVHost" id="rmqVHost" placeholder="VHost"
value="<?php echo (isset($rmq) ? $rmq["vhost"] : "/airtime"); ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="rmqErr" id="rmqErr" aria-describedby="helpBlock"/>
</div>
<div>
<input type="submit" formtarget="rmqSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#rmqSlideToggle").click(function() {
$("#rmqFormBody").slideToggle(500);
$("#advCaret").toggleClass("caret-up");
});
$("#rmqSettingsForm").submit(function(e) {
submitForm(e, "RabbitMQSetup");
});
</script>

View file

@ -0,0 +1,158 @@
<?php
define("RMQ_INI_SECTION", "rabbitmq");
require_once dirname(dirname( __DIR__)) . '/library/php-amqplib/amqp.inc';
function booleanReduce($a, $b) {
return $a && $b;
}
/**
* Check to see if Airtime is properly configured.
*
* @return boolean true if all Airtime dependencies and services are
* properly configured and running
*/
function checkConfiguration() {
$r1 = array_reduce(checkPhpDependencies(), "booleanReduce", true);
$r2 = array_reduce(checkExternalServices(), "booleanReduce", true);
return $r1 && $r2;
}
/**
* Check for Airtime's PHP dependencies and return an associative
* array with the results
*
* @return array associative array of dependency check results
*/
function checkPhpDependencies() {
return array(
"zend" => checkZendDependencies(),
"postgres" => checkDatabaseDependencies()
);
}
/**
* Check that the Zend framework libraries are installed
*
* @return boolean true if Zend exists in /usr/share/php
*/
function checkZendDependencies() {
return file_exists('/usr/share/php/libzend-framework-php')
|| file_exists('/usr/share/php/Zend'); // Debian version
}
/**
* Check that the PHP dependencies for the database exist
*
* @return boolean true if the database dependencies exist
*/
function checkDatabaseDependencies() {
global $extensions;
// Check the PHP extension list for the Postgres db extensions
return (in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions));
}
/**
* Check that all external services are configured correctly and return an associative
* array with the results
*
* @return array associative array of external service check results
*/
function checkExternalServices() {
return array(
"database" => checkDatabaseConfiguration(),
"media-monitor" => checkMediaMonitorService(),
"pypo" => checkPlayoutService(),
"liquidsoap" => checkLiquidsoapService(),
"rabbitmq" => checkRMQConnection()
);
}
/**
* Check the database configuration by fetching a connection from Propel
*
* @return boolean true if a connection is made to the database
*/
function checkDatabaseConfiguration() {
configureDatabase();
try {
// Try to establish a database connection. If something goes
// wrong, the database is improperly configured
Propel::getConnection();
Propel::close();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Initialize Propel to configure the Airtime database
*/
function configureDatabase() {
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}
/**
* Check that we can connect to RabbitMQ
*
* @return true if the RabbitMQ connection can be established
*/
function checkRMQConnection() {
// Check for airtime.conf in /etc/airtime/ first, then check in the build directory,
if (file_exists(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG)) {
$ini = parse_ini_file(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG, true);
} else {
$ini = parse_ini_file(BUILD_PATH . "airtime.example.conf", true);
}
$conn = new AMQPConnection($ini[RMQ_INI_SECTION]["host"],
$ini[RMQ_INI_SECTION]["port"],
$ini[RMQ_INI_SECTION]["user"],
$ini[RMQ_INI_SECTION]["password"],
$ini[RMQ_INI_SECTION]["vhost"]);
return isset($conn);
}
/**
* Check if airtime-media-monitor is currently running
*
* @return boolean true if airtime-media-monitor is running
*/
function checkMediaMonitorService() {
exec("pgrep -f -u www-data airtime-media-monitor", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}
/**
* Check if airtime-playout is currently running
*
* @return boolean true if airtime-playout is running
*/
function checkPlayoutService() {
exec("pgrep -f -u www-data airtime-playout", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}
/**
* Check if airtime-liquidsoap is currently running
*
* @return boolean true if airtime-liquidsoap is running
*/
function checkLiquidsoapService() {
exec("pgrep -f -u www-data airtime-liquidsoap", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}

View file

@ -0,0 +1,57 @@
<?php
?>
<html>
<head>
<script type="text/javascript" src="js/libs/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui-1.8.24.min.js"></script>
<script type="text/javascript" src="js/setup/setup-config.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap-3.3.1.min.css" />
<link rel="stylesheet" type="text/css" href="css/setup/setup-config.css" />
</head>
<body>
<div class="header">
<h3 class="logo">
<img src="css/images/airtime_logo_jp.png" id="airtimeLogo" /><br/>
<strong>Setup</strong>
</h3>
<strong>Step <span id="stepCount">1</span> of 5</strong>
</div>
<div class="viewport">
<div class="form-slider">
<div id="databaseSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/database-settings.php";
?>
</div>
<div id="rabbitmqSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/rabbitmq-settings.php";
?>
</div>
<div id="generalSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/general-settings.php";
?>
</div>
<div id="mediaSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/media-settings.php";
?>
</div>
<div id="finishSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/finish-settings.php";
?>
</div>
</div>
</div>
<script>
$(".btn-skip").click(nextSlide);
$(".btn-back").click(prevSlide);
</script>
</body>
</html>

View file

@ -1,32 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_url = localhost
base_port = 80
base_dir = '/'
;How many hours ahead of time should Airtime playout engine (PYPO)
;cache scheduled media files.
cache_ahead_hours = 1
[monit]
monit_user = guest
monit_password = airtime
[soundcloud]
connection_retries = 3
time_between_retries = 60

View file

@ -0,0 +1,274 @@
# ----------------------------------------------------------------------
# A I R T I M E C O N F I G U R A T I O N
# ----------------------------------------------------------------------
#
# This is an example configuration for Airtime. If you just want to
# get started with a basic Airtime setup, or don't know if you should
# be reconfiguring any of the following values, just rename this file
# to 'airtime.conf'.
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# G E N E R A L S E T T I N G S
# ----------------------------------------------------------------------
#
# These settings are used for Airtime's webserver configuration, and
# for general-purpose properties.
#
# api_key: The API key for your Airtime installation.
# The value is generated the first time you use Airtime.
#
# web_server_user: The default webserver user.
# The default is www-data.
#
# base_url: The host name for your webserver.
# The default is localhost.
#
# base_port: The port for your webserver.
# The default is 80.
#
# base_dir: The root directory for your Airtime installation
# on your webserver, relative to the base_url.
# The default is /.
#
# cache_ahead_hours: How many hours ahead of time the Airtime playout
# engine (pypo) should cache scheduled media files.
# The default is 1.
#
[general]
api_key =
web_server_user = www-data
base_url = localhost
base_port = 80
base_dir = /
cache_ahead_hours = 1
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# D A T A B A S E
# ----------------------------------------------------------------------
#
# These settings are used to configure your database connection.
#
# host: The hostname of the database server.
# On a default Airtime installation, set this to localhost.
#
# dbname: The name of the Airtime database.
# The default is airtime.
#
# dbuser: The username for the Airtime database user.
# The default is airtime.
#
# dbpass: The password for the Airtime database user.
# The default is airtime.
#
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# R A B B I T M Q
# ----------------------------------------------------------------------
#
# These settings are used to configure the RabbitMQ messaging
# configuration for your Airtime installation.
#
# host: The IP address for the RabbitMQ service.
# The default is 127.0.0.1.
#
# port: The port for the RabbitMQ service.
# The default is 5672.
#
# user: The username for the RabbitMQ user.
# The default is airtime.
#
# password: The password for the RabbitMQ user.
# The default is airtime.
#
# vhost: The virtual host for the RabbitMQ service database.
# The default is /airtime.
#
[rabbitmq]
host = 127.0.0.1
port = 5672
user = airtime
password = airtime
vhost = /airtime
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# M E D I A M O N I T O R
# ----------------------------------------------------------------------
#
# check_filesystem_events: How long to queue up events performed on the
# files themselves, in seconds
# The default is 5
#
# check_airtime_events: How long to queue metadata input from airtime,
# in seconds
# The default is 30
#
# touch_interval:
# The default is 5
#
# chunking_number:
# The default is 450
#
# request_max_wait: The maximum request wait time, in seconds
# The default is 3.0
#
# rmq_event_wait: The RabbitMQ event wait time, in seconds
# The default is 0.1
#
# logpath: The media monitor log file path
# The default is '/var/log/airtime/media-monitor/media-monitor.log'
#
# index_path: The media monitor index path
# The default is '/var/tmp/airtime/media-monitor/last_index'
#
[media-monitor]
check_filesystem_events = 5
check_airtime_events = 30
touch_interval = 5
chunking_number = 450
request_max_wait = 3.0
rmq_event_wait = 0.1
logpath = '/var/log/airtime/media-monitor/media-monitor.log'
index_path = '/var/tmp/airtime/media-monitor/last_index'
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# P Y P O
# ----------------------------------------------------------------------
#
# api_client: Set the type of client you are using.
# Currently supported types:
# 1) 'obp' = Open Broadcast Platform
# 2) 'airtime'
# The default is 'airtime'
#
# cache_dir: The directory for pypo cache files
# The default is '/var/tmp/airtime/pypo/cache/'
#
# file_dir: The directory for pypo media files
# The default is '/var/tmp/airtime/pypo/files/'
#
# tmp_dir: The directory for pypo temp files
# The default is '/var/tmp/airtime/pypo/tmp/'
#
# cache_base_dir: The pypo base cache directory
# The default is '/var/tmp/airtime/pypo/'
#
# log_base_dir: The base directory for Airtime log files
# The default is '/var/log/airtime'
#
# pypo_log_dir: The directory for pypo log files
# The default is '/var/log/airtime/pypo'
#
# liquidsoap_log_dir: The directory for liquidsoap log files
# The default is '/var/log/airtime/pypo-liquidsoap'
#
# ls_host: Liquidsoap connection host
# The default is '127.0.0.1'
#
# ls_port: Liquidsoap connection port
# The default is '1234'
#
# poll_interval: Poll interval in seconds
#
# This will rarely need to be changed because any schedule
# changes are automatically sent to pypo immediately
# This is how often the poll script downloads new schedules
# and files from the server in the event that no changes
# are made to the schedule
# The default is 3600
#
# push_interval: Push interval in seconds
#
# This is how often the push script checks whether it has
# something new to push to liquidsoap
# The default is 1
#
# cue_style: Can be set to 'pre' or 'otf'
# 'pre' cues while playlist preparation
# 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
# The default is 'pre'
#
# record_bitrate: The bitrate for recordings
# The default is 256
#
# record_samplerate: The samplerate for recordings
# The default is 44100
#
# record_channels: The number of channels for recordings
# The default is 2
#
# record_sample_size: The sample size for recordings
# The default is 16
#
# record_file_type: Can be either ogg|mp3, mp3 recording requires
# installation of the package "lame"
# The default is ogg
#
# base_recorded_files: Base path to store recordered shows at
# The default is '/var/tmp/airtime/show-recorder/'
#
[pypo]
api_client = 'airtime'
# ---------- Cache directories - !! Include trailing slash !! ----------
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
# ------- Setup directories - !! Don't include trailing slash !! -------
cache_base_dir = '/var/tmp/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
# ------------------------ Liquidsoap Settings -------------------------
ls_host = '127.0.0.1'
ls_port = '1234'
# -------------------------- Pypo Preferences --------------------------
poll_interval = 3600
push_interval = 1
cue_style = 'pre'
# ---------------------- Recorded Audio Settings -----------------------
record_bitrate = 256
record_samplerate = 44100
record_channels = 2
record_sample_size = 16
record_file_type = 'ogg'
base_recorded_files = '/var/tmp/airtime/show-recorder/'
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# S O U N D C L O U D
# ----------------------------------------------------------------------
#
# connection_retries: The number of times to retry the connection to
# Soundcloud.
# The default is 3.
#
# time_between_retries: The time between connection retries, in seconds.
# The default is 60.
#
[soundcloud]
connection_retries = 3
time_between_retries = 60
#
# ----------------------------------------------------------------------

View file

@ -1,5 +1,5 @@
-- Schema version
INSERT INTO cc_pref("keystr", "valstr") VALUES('system_version', '2.5.9');
INSERT INTO cc_pref("keystr", "valstr") VALUES('schema_version', '2.5.12');
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));
-- added in 2.3