Removed many unnecessary files and started changing pypo to use setuptools

This commit is contained in:
Duncan Sommerville 2014-12-17 16:22:40 -05:00
parent 144923c353
commit 97805ad271
169 changed files with 5 additions and 8620 deletions

View File

@ -1,12 +0,0 @@
<VirtualHost *:80>
ServerAdmin foo@bar.org
DocumentRoot /usr/share/airtime/public
php_admin_value upload_tmp_dir /tmp
<Directory /usr/share/airtime/public>
DirectoryIndex index.php
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

View File

@ -1,14 +0,0 @@
#!/bin/bash
#
# Auto install script for airtime on Debian
#Current dir
# 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
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH/../ubuntu
./airtime-full-install

View File

@ -1,56 +0,0 @@
# This file is contributed by Eugene MechanisM
# Link to the post:
# http://forum.sourcefabric.org/discussion/13563/first-step-to-run-airtime-via-nginx-based-on-airtime-2.0-beta-files
upstream php5-fpm {
ip_hash;
server unix:/var/run/airtime.php.sock;
}
server {
listen 80;
server_name airtime; #change to your host
include mime.types;
root /usr/share/airtime/public;
access_log /var/log/airtime.access.log;
error_log /var/log/airtime.error.log;
index index.php;
include fastcgi_params;
client_max_body_size 1G;
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location / {
if (-e $request_filename){
set $rule_0 1;
}
if ($request_filename ~ "-l"){
set $rule_0 1;
}
if (-d $request_filename){
set $rule_0 1;
}
rewrite ^/.*$ /index.php last;
try_files $uri $uri/ index.php;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php5-fpm;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\.ht {
deny all;
}
}

View File

@ -1,250 +0,0 @@
# NGINX changes are contributed by Eugene MechanisM
# Link to the post:
# http://forum.sourcefabric.org/discussion/13563/first-step-to-run-airtime-via-nginx-based-on-airtime-2.0-beta-files
; Start a new pool named 'airtime'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('airtime' here)
[airtime]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = '/var/run/airtime.php.sock'
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = -1
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0666
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives:
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 10
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 4
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 2
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 6
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool;
; process manager - static or dynamic;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes.
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic')
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
; accepted conn: 12073
; pool: www
; process manager: static
; idle processes: 35
; active processes: 65
; total processes: 100
; max children reached: 1
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
php_admin_value[error_log] = /var/log/airtime.php-fpm.error.log
php_admin_value[post_max_size] = 500M
php_admin_value[upload_max_filesize] = 500M
php_admin_value[request_order] = GPC
php_admin_value[session.gc_probability] = 0
php_admin_value[upload_tmp_dir] = /tmp

View File

@ -1,8 +0,0 @@
[PHP]
memory_limit = 512M
magic_quotes_gpc = Off
file_uploads = On
upload_tmp_dir = /tmp
apc.write_lock = 1
apc.slam_defense = 0

View File

@ -1,216 +0,0 @@
#!/bin/bash -e
#
# Auto install script for airtime on Ubuntu
#
# NGINX changes are contributed by Eugene MechanisM
# Link to the post:
# http://forum.sourcefabric.org/discussion/13563/first-step-to-run-airtime-via-nginx-based-on-airtime-2.0-beta-files
exec > >(tee install_log.txt)
exec 2>&1
if [ "$(id -u)" != "0" ]; then
echo "Please run as root user."
exit 1
fi
server="$1"
#Current dir
# 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
SCRIPTPATH=`dirname $SCRIPT`
#Prerequisite
echo "----------------------------------------------------"
echo " 1. Install Packages"
echo "----------------------------------------------------"
dist=`lsb_release -is`
code=`lsb_release -cs`
#enable squeeze backports to get lame packages
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
set +e
grep -E "deb http://backports.debian.org/debian-backports squeeze-backports main" /etc/apt/sources.list
returncode=$?
set -e
if [ "$returncode" -ne "0" ]; then
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list
fi
fi
codename=`lsb_release -sc`
set +e
grep -E "deb +http://apt.sourcefabric.org/? +$codename +main" /etc/apt/sources.list
returncode=$?
set -e
if [ "$returncode" != "0" ]; then
echo "deb http://apt.sourcefabric.org/ $codename main" >> /etc/apt/sources.list
fi
apt-get update
# Updated package list
apt-get -y --force-yes install tar gzip curl php5-pgsql \
php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \
pwgen libfaad2 php-apc
#install packages with --force-yes option (this is useful in the case
#of Debian, where these packages are unauthorized)
apt-get -y --force-yes install libmp3lame-dev lame icecast2
#Debian Squeeze only has zendframework package. Newer versions of Ubuntu have zend-framework package.
#Ubuntu Lucid has both zendframework and zend-framework. Difference appears to be that zendframework is for
#1.10 and zend-framework is 1.11
if [ "$dist" = "Debian" ]; then
apt-get -y --force-yes install zendframework
else
apt-get -y --force-yes install libzend-framework-php
fi
#get the "timeout" unix command
if [ "$code" = "lucid" ]; then
apt-get -y --force-yes install timeout
else
apt-get -y --force-yes install coreutils
fi
#install aac package only available in new distributions: (Debian Wheezy, Ubuntu Precise or newer)
if [ "$code" != "squeeze" -a "$code" != "lucid" ]; then
apt-get -y --force-yes install libvo-aacenc0
fi
#Install some plugin packages on Ubuntu Saucy.
if [ "$dist" = "Ubuntu" -a "$code" = "saucy" ]; then
apt-get -y --force-yes install php5-json
apt-get -y --force-yes install liquidsoap-plugin-alsa liquidsoap-plugin-ao liquidsoap-plugin-faad liquidsoap-plugin-flac liquidsoap-plugin-icecast liquidsoap-plugin-lame liquidsoap-plugin-mad liquidsoap-plugin-ogg liquidsoap-plugin-opus liquidsoap-plugin-portaudio liquidsoap-plugin-pulseaudio liquidsoap-plugin-taglib liquidsoap-plugin-voaacenc liquidsoap-plugin-vorbis
fi
#Install packages back-ported by Sourcefabric
apt-get -y --force-yes install sourcefabric-keyring
apt-get -y --force-yes install liquidsoap
apt-get -y --force-yes install silan
apt-get -y --force-yes install libopus0
if [ "$server" = "nginx" ]; then
apt-get -y --force-yes install nginx php5-fpm
# NGINX Config File
echo "----------------------------------------------------"
echo "2.1 NGINX Config File"
echo "----------------------------------------------------"
if [ ! -f /etc/nginx/sites-available/airtime ]; then
cp $SCRIPTPATH/../nginx/airtime-vhost /etc/nginx/sites-available/airtime
ln -s /etc/nginx/sites-available/airtime /etc/nginx/sites-enabled/airtime
service nginx reload
else
echo "NGINX config for Airtime already exists..."
fi
# php-fpm Airtime pool file
echo "----------------------------------------------------"
echo "2.2 Airtime php pool file"
echo "----------------------------------------------------"
if [ ! -f /etc/php5/fpm/pool.d/airtime.conf ]; then
cp $SCRIPTPATH/../php5-fpm/airtime.conf /etc/php5/fpm/pool.d/airtime.conf
service php5-fpm reload
else
echo "Airtime php pool file already exists..."
fi
else
apt-get -y --force-yes install apache2 libapache2-mod-php5
set +e
apache2 -v | grep "2\.4" > /dev/null
apacheversion=$?
set -e
# Apache Config File
echo "----------------------------------------------------"
echo "2.1 Apache Config File"
echo "----------------------------------------------------"
if [ "$apacheversion" != "1" ]; then
airtimeconfigfile="airtime.conf"
else
airtimeconfigfile="airtime"
fi
if [ ! -f /etc/apache2/sites-available/$airtimeconfigfile ]; then
echo "Creating Apache config for Airtime..."
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/$airtimeconfigfile
a2dissite 000-default
a2ensite airtime
else
echo "Apache config for Airtime already exists..."
fi
if [ ! -d /usr/share/airtime/public ]; then
echo "Creating Apache web root directory..."
mkdir -p /usr/share/airtime/public/
else
echo "Airtime web root directory already exists..."
fi
# PHP Config File for Apache
echo "----------------------------------------------------"
echo "2.2 PHP Config File for Apache"
echo "----------------------------------------------------"
if [ ! -f /etc/php5/apache2/airtime.ini ]; then
echo "Creating Airtime PHP config for Apache..."
cp $SCRIPTPATH/../php5/airtime.ini /etc/php5/apache2/conf.d/airtime.ini
else
echo "Airtime PHP config for Apache already exists..."
fi
# Enable modules and restart Apache to enable any configuration changes
echo "----------------------------------------------------"
echo "2.3 Enable Apache Modules and Restart Apache"
echo "----------------------------------------------------"
a2enmod rewrite php5
service apache2 restart
fi
# Enable Icecast
echo "----------------------------------------------------"
echo "3. Enable Icecast"
echo "----------------------------------------------------"
cd /etc/default/
sed -i 's/ENABLE=false/ENABLE=true/g' icecast2
set +e
service icecast2 start
set -e
echo ""
# Enable Monit
echo "----------------------------------------------------"
echo "4. Enable Monit"
echo "----------------------------------------------------"
cd /etc/default/
sed -i 's/startup=0/startup=1/g' monit
set +e
grep -q "include /etc/monit/conf.d" /etc/monit/monitrc
RETVAL=$?
set -e
if [ $RETVAL -ne 0 ] ; then
mkdir -p /etc/monit/conf.d
echo "include /etc/monit/conf.d/*" >> /etc/monit/monitrc
fi
# Run Airtime Install
echo "----------------------------------------------------"
echo "5. Run Airtime Install"
echo "----------------------------------------------------"
cd $SCRIPTPATH/../../install_minimal
# Restart apache to clear php cache
service apache2 restart
./airtime-install

View File

@ -1,10 +0,0 @@
#!/bin/bash
# Auto install script for airtime + nginx
# 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
SCRIPTPATH=`dirname $SCRIPT`
$SCRIPTPATH/airtime-full-install nginx

View File

@ -1,19 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110312121200 extends AbstractMigration
{
public function up(Schema $schema)
{
$schema->dropTable("cc_backup");
$schema->dropTable("cc_trans");
}
public function down(Schema $schema)
{
}
}

View File

@ -1,96 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema,
Doctrine\DBAL\Schema\Table,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Types\Type;
class Version20110331111708 extends AbstractMigration
{
public function up(Schema $schema)
{
//start cc_show_instances modifications
$show_instances_table = $schema->getTable('cc_show_instances');
$show_instances_table->addColumn('record', 'smallint', array('notnull' => 0, 'default' => 0));
$show_instances_table->addColumn('rebroadcast', 'smallint', array('notnull' => 0, 'default' => 0));
$show_instances_table->addColumn('instance_id', 'integer', array('notnull' => 0));
$show_instances_table->addColumn('file_id', 'integer', array('notnull' => 0));
$show_instances_table->addColumn('soundcloud_id', 'integer', array('notnull' => 0));
$show_instances_table->addNamedForeignKeyConstraint('cc_original_show_instance_fkey', $show_instances_table, array('instance_id'), array('id'), array('onDelete' => 'CASCADE'));
$files_table = $schema->getTable('cc_files');
$show_instances_table->addNamedForeignKeyConstraint('cc_recorded_file_fkey', $files_table, array('file_id'), array('id'), array('onDelete' => 'CASCADE'));
//end cc_show_instances modifications
//start cc_show_days modifications
$show_days_table = $schema->getTable('cc_show_days');
$show_days_table->addColumn('record', 'smallint', array( 'notnull' => 0, 'default' => 0));
//end cc_show_days modifications
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->addColumn('url', 'string', array('notnull' => 0, 'length' => 255));
//end cc_show modifications
//start cc_schedule modifications
$schedule_table = $schema->getTable('cc_schedule');
$playlist_id_col = $schedule_table->getColumn('playlist_id');
$playlist_id_col->setNotnull(false);
//end cc_schedule modifications
//create cc_show_rebroadcast table
$cc_show_rebroadcast_table = $schema->createTable('cc_show_rebroadcast');
$cc_show_rebroadcast_table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
$cc_show_rebroadcast_table->addColumn('day_offset', 'string', array('length' => 255));
$cc_show_rebroadcast_table->addColumn('start_time', 'datetime', array('notnull' => 1));
$cc_show_rebroadcast_table->addColumn('show_id', 'integer', array('notnull' => 1));
$cc_show_rebroadcast_table->setPrimaryKey(array('id'));
//end create cc_show_rebroadcast table
}
public function down(Schema $schema)
{
//start cc_show_instances modifications
$show_instances_table = $schema->getTable('cc_show_instances');
$show_instances_table->dropColumn('record');
$show_instances_table->dropColumn('rebroadcast');
$show_instances_table->dropColumn('instance_id');
$show_instances_table->dropColumn('file_id');
$show_instances_table->dropColumn('soundcloud_id');
//end cc_show_instances modifications
//start cc_show_days modifications
$show_days_table = $schema->getTable('cc_show_days');
$show_days_table->dropColumn('record');
//end cc_show_days modifications
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->dropColumn('url');
//end cc_show modifications
//start cc_schedule modifications
$schedule_table = $schema->getTable('cc_schedule');
$playlist_id_col = $schedule_table->getColumn('playlist_id');
$playlist_id_col->setNotnull(true);
//end cc_schedule modifications
//drop cc_show_rebroadcast table
$schema->dropTable('cc_show_rebroadcast');
//end drop cc_show_rebroadcast table
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110402164819 extends AbstractMigration
{
public function up(Schema $schema)
{
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->addColumn('genre', 'string', array('notnull' => 0, 'length' => 255, 'default' => ""));
//end cc_show modifications
}
public function down(Schema $schema)
{
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->dropColumn('genre');
//end cc_show modifications
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110406182005 extends AbstractMigration
{
public function up(Schema $schema)
{
//start cc_show_instances modifications
$cc_show_instances = $schema->getTable('cc_show_instances');
$cc_show_instances->addColumn('time_filled', 'time', array('notnull' => false));
//end cc_show_instances modifications
//start cc_show_rebroadcast modifications
$cc_show_rebroadcast = $schema->getTable('cc_show_rebroadcast');
$type = $cc_show_rebroadcast->getColumn('start_time')->getType()->getName();
if($type == 'datetime') {
$cc_show_rebroadcast->dropColumn('start_time');
$cc_show_rebroadcast->addColumn('start_time', 'time', array('notnull' => true));
}
//end cc_show_rebroadcast modifications
}
public function down(Schema $schema)
{
//start cc_show_instances modifications
$cc_show_instances = $schema->getTable('cc_show_instances');
$cc_show_instances->dropColumn('time_filled');
//end cc_show_instances modifications
//start cc_show_rebroadcast modifications
$cc_show_rebroadcast = $schema->getTable('cc_show_rebroadcast');
$type = $cc_show_rebroadcast->getColumn('start_time')->getType()->getName();
if($type == 'datetime') {
$cc_show_rebroadcast->dropColumn('start_time');
$cc_show_rebroadcast->addColumn('start_time', 'datetime', array('notnull' => 1));
}
//end cc_show_rebroadcast modifications
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace DoctrineMigrations;
//CC-2279 Upgrade script for creating the cc_music_dirs table.
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110629143017 extends AbstractMigration
{
public function up(Schema $schema)
{
//create cc_music_dirs table
$cc_music_dirs = $schema->createTable('cc_music_dirs');
$cc_music_dirs->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
$cc_music_dirs->addColumn('type', 'string', array('length' => 255));
$cc_music_dirs->addColumn('directory', 'text', array('unique' => true));
$cc_music_dirs->setPrimaryKey(array('id'));
//end create cc_music_dirs table
}
public function down(Schema $schema)
{
$schema->dropTable('cc_music_dirs');
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace DoctrineMigrations;
/*
1) update cc_files table to include to "directory" column
2) create a foreign key relationship from cc_files to cc_music_dirs
3) create a foreign key relationship from cc_schedule to cc_files
*/
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110711161043 extends AbstractMigration
{
public function up(Schema $schema)
{
$ini = parse_ini_file(__DIR__."/../include/airtime-install.ini");
$stor_dir = $ini["storage_dir"];
/* 1) update cc_files table to include to "directory" column */
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', $stor_dir);");
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('link', '');");
$cc_music_dirs = $schema->getTable('cc_music_dirs');
/* 2) create a foreign key relationship from cc_files to cc_music_dirs */
$cc_files = $schema->getTable('cc_files');
$cc_files->addColumn('directory', 'integer', array('notnull' => 0, 'default'=> NULL));
$cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE'));
// before 3) we have to delete all entries in cc_schedule with file_id that are not in cc_file table
$this->_addSql("DELETE FROM cc_schedule WHERE cc_schedule.id IN(
SELECT cc_schedule.id
FROM cc_schedule
LEFT JOIN cc_files
ON cc_schedule.file_id = cc_files.id
WHERE cc_files.id IS NULL)");
/* 3) create a foreign key relationship from cc_schedule to cc_files */
$cc_schedule = $schema->getTable('cc_schedule');
$cc_schedule->addNamedForeignKeyConstraint('cc_files_folder_fkey', $cc_files, array('file_id'), array('id'), array('onDelete' => 'CASCADE'));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110713161043 extends AbstractMigration
{
public function up(Schema $schema)
{
//create cc_country table
$cc_country = $schema->createTable('cc_country');
$cc_country->addColumn('isocode', 'string', array('length' => 3));
$cc_country->addColumn('name', 'string', array('length' => 255));
$cc_country->setPrimaryKey(array('isocode'));
//end create cc_country table
}
public function down(Schema $schema)
{
$schema->dropTable('cc_country');
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110829143306 extends AbstractMigration
{
public function up(Schema $schema)
{
//create cc_stream_setting table
$cc_stream_setting = $schema->createTable('cc_stream_setting');
$cc_stream_setting->addColumn('keyname', 'string', array('length' => 64));
$cc_stream_setting->addColumn('value', 'string', array('length' => 255));
$cc_stream_setting->addColumn('type', 'string', array('length' => 16));
$cc_stream_setting->setPrimaryKey(array('keyname'));
//end create cc_stream_setting table
}
public function down(Schema $schema)
{
$schema->dropTable('cc_stream_setting');
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110922153933 extends AbstractMigration
{
public function up(Schema $schema)
{
// add soundcloud_id, soundcloud_error_code, soundcloud_error_msg columns to cc_files
$cc_files = $schema->getTable('cc_files');
$cc_files->addColumn('soundcloud_id', 'integer', array('notnull' => 0, 'default'=> NULL));
$cc_files->addColumn('soundcloud_error_code', 'integer', array('notnull' => 0, 'default'=> NULL));
$cc_files->addColumn('soundcloud_error_msg', 'string', array('length' => 255, 'notnull' => 0, 'default'=> NULL));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110925171051 extends AbstractMigration
{
public function up(Schema $schema)
{
// move soundcloud_id from cc_show_instances to cc_files
$this->_addSql("update cc_files as cf set soundcloud_id = csi.soundcloud_id
from cc_show_instances as csi
where csi.file_id = cf.id and file_id is not NULL");
// remove soundcloud_id from cc_show_instance table
$cc_show_instances = $schema->getTable('cc_show_instances');
$cc_show_instances->dropColumn('soundcloud_id');
}
public function down(Schema $schema)
{
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110925171256 extends AbstractMigration
{
public function up(Schema $schema)
{
// create cc_login_sttempts table
$cc_login = $schema->createTable('cc_login_attempts');
$cc_login->addColumn('ip', 'string', array('length' => 32));
$cc_login->addColumn('attempts', 'integer', array('notnull' => 0, 'default'=> 0));
$cc_login->setPrimaryKey(array('ip'));
// add login_attempts column to cc_subjs table
$cc_subjs = $schema->getTable('cc_subjs');
$cc_subjs->addColumn('login_attempts', 'integer', array('notnull' => 0, 'default'=> 0));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110929184401 extends AbstractMigration
{
public function up(Schema $schema)
{
$cc_component = $schema->createTable('cc_service_register');
$cc_component->addColumn('name', 'string', array('length' => 32));
$cc_component->addColumn('ip', 'string', array('length' => 18));
$cc_component->setPrimaryKey(array('name'));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20111102142811 extends AbstractMigration
{
public function up(Schema $schema)
{
// change 'soundcloud_upload' -> 'soundcloud_auto_upload_recorded_show' CC-2928
$this->_addSql("UPDATE cc_pref SET keystr = 'soundcloud_auto_upload_recorded_show'
WHERE keystr = 'soundcloud_upload'");
// add soundcloud_link_to_file
$cc_files = $schema->getTable('cc_files');
$cc_files->addColumn('soundcloud_link_to_file', 'string', array('length' => 4096, 'notnull' => 0, 'default'=> NULL));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,21 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20111103141311 extends AbstractMigration
{
public function up(Schema $schema)
{
// add timezone column to cc_show_days
$cc_subjs = $schema->getTable('cc_show_days');
$cc_subjs->addColumn('timezone', 'string', array('required' => true, 'default'=> ''));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20111114222927 extends AbstractMigration
{
public function up(Schema $schema)
{
$cc_show_instances = $schema->getTable('cc_show_instances');
$cc_show_instances->addColumn('modified_instance', 'boolean', array('notnull' => true, 'default'=> '0'));
}
public function down(Schema $schema)
{
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20120613123039 extends AbstractMigration
{
public function up(Schema $schema)
{
$table = $schema->getTable("cc_subjs");
$table->addColumn("cell_phone", "string");
}
public function down(Schema $schema)
{
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-migrations xmlns="http://doctrine-project.org/schemas/migrations/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration
http://doctrine-project.org/schemas/migrations/configuration.xsd">
<name>Airtime 2.0.0 Database Upgrade</name>
<migrations-namespace>DoctrineMigrations</migrations-namespace>
<table name="doctrine_migration_versions" />
<migrations-directory>./</migrations-directory>
</doctrine-migrations>

View File

@ -1,5 +0,0 @@
<?php
require_once(dirname(__FILE__).'/include/AirtimeIni.php');
require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
AirtimeInstall::DirCheck();

View File

@ -1,253 +0,0 @@
#!/bin/bash -e
#-e Causes bash script to exit if any of the installers
#return with a non-zero return value.
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
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
--web|-w Install only files for web-server"
exit 0
}
rabbitmq_install () {
RABBITMQ_VHOST="/airtime"
RABBITMQ_USER="airtime"
RABBITMQ_PASSWORD=$(awk -F ' = ' '{if (! ($0 ~ /^;/) && $0 ~ /^password/ ) print $2}' /etc/airtime/airtime.conf)
EXCHANGES="airtime-pypo|pypo-fetch|airtime-media-monitor|media-monitor"
rabbitmqctl list_vhosts | grep $RABBITMQ_VHOST
RESULT="$?"
if [ $RESULT = "0" ]; then
rabbitmqctl delete_vhost $RABBITMQ_VHOST
rabbitmqctl delete_user $RABBITMQ_USER
fi
rabbitmqctl add_vhost $RABBITMQ_VHOST
rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD
rabbitmqctl set_permissions -p $RABBITMQ_VHOST $RABBITMQ_USER "$EXCHANGES" "$EXCHANGES" "$EXCHANGES"
export RABBITMQ_USER
export RABBITMQ_PASSWORD
export RABBITMQ_VHOST
}
overwrite="f"
preserve="f"
nodb="f"
reinstall="f"
mediamonitor="f"
pypo="f"
showrecorder="f"
web="f"
disable_deb_check="f"
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,web,liquidsoap-keep-alive,disable-deb-check "hopnrmywld" "$@")
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";;
(-w|--web) web="t";;
(-d|--disable-deb-check) disable_deb_check="t";;
(--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
if [ "$mediamonitor" = "f" -a "$pypo" = "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
if [ "$disable_deb_check" == "f" ]; then
set +e
DEB=$(dpkg -s airtime 2> /dev/null | grep Status)
set -e
if [[ "$DEB" = "Status: install ok installed" ]]; then
echo -e "\nDebian package of Airtime detected. Please use the debian package to upgrade.\n"
exit 1
fi
fi
#Update apt sources.list to point to the new deb-multimedia domain.
sed -i s/www.debian-multimedia.org/www.deb-multimedia.org/g /etc/apt/sources.list
# 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
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../
echo "* Making sure /etc/default/locale is set properly"
set +e
update-locale
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
if [ "$?" != "0" ]; then
echo -e " * Fail\n"
echo "A non UTF-8 default locale found in /etc/default/locale. Airtime requires
a UTF-8 locale to run. To fix this please do the following:
Ubuntu:
Put line 'en_US.UTF-8 UTF-8' (or similar) without quotes to '/var/lib/locales/supported.d/local',
replacing any existing lines.
A list of supported locales is available in '/usr/share/i18n/SUPPORTED'
Then run 'sudo dpkg-reconfigure locales'
Debian:
Run 'sudo dpkg-reconfigure locales' and use the interface to select 'en_US.UTF-8 UTF-8' (or similar).
On the second page select this new locale as the default.
After these changes have been made simply run install again.
Now exiting install...
"
exit 1
fi
set -e
# Check if airtime exists already
set +e
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php
result=$?
set -e
DO_UPGRADE="0"
if [ "$result" -eq "0" ]; then
echo " * None found."
#Make sure any straggler config files are removed. Reason for this is that they may be from
#an older version of Airtime, but since there no database installed, we have no idea how to
#handle these (what version are they from?).
rm -f "/etc/airtime/airtime.conf"
rm -f "/etc/airtime/api_client.cfg"
rm -f "/etc/airtime/liquidsoap.cfg"
rm -f "/etc/airtime/media-monitor.cfg"
rm -f "/etc/airtime/pypo.cfg"
elif [ "$result" -eq "1" -a "$reinstall" = "f" ]; then
echo " * Same version of Airtime already installed! Reusing database."
nodb='t'
overwrite='f'
elif [ "$result" -eq "2" ]; then
echo " * Previous version of Airtime already installed..will perform upgrade."
DO_UPGRADE="1"
elif [ "$result" -eq "3" ]; then
echo " * You require at least Airtime 1.8.0 installed for upgrade."
exit 1
fi
#We don't want any of our python services running if we are doing an upgrade/reinstall.
#They will be automatically restarted later on.
echo "* Temporarily stopping any previous running services"
set +e
monit unmonitor airtime-media-monitor >/dev/null 2>&1
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
monit unmonitor airtime-playout >/dev/null 2>&1
set -e
if [ -e /etc/init.d/airtime-media-monitor ]; then
invoke-rc.d airtime-media-monitor stop > /dev/null 2>&1
fi
if [ -e /etc/init.d/airtime-playout ]; then
invoke-rc.d airtime-playout stop > /dev/null 2>&1
fi
if [ -e /etc/init.d/airtime-liquidsoap ]; then
invoke-rc.d airtime-liquidsoap stop > /dev/null 2>&1
fi
#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
set +e
test "$mediamonitor" = "t" -o "$pypo" = "t"
export python_service=$?
set -e
echo -e "\n******************************** Install Begin *********************************"
rm -rf "/usr/lib/airtime"
mkdir -p /usr/lib/airtime
if [ "$python_service" -eq "0" ]; then
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
python $AIRTIMEROOT/python_apps/create-pypo-user.py
fi
if [ "$DO_UPGRADE" -eq "1" ]; then
#do upgrade
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-upgrade.php $@
fi
set +e
if [ "$DO_UPGRADE" -eq "0" ]; then
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-install.php $@
result=$?
if [ "$result" -ne "0" ]; then
#There was an error, exit with error code.
echo "There was an error during install. Exit code $result"
exit 1
fi
fi
rabbitmq_install
set -e
export airtime_service_start='t'
$SCRIPTPATH/include/airtime-copy-files.sh
$SCRIPTPATH/include/airtime-initialize.sh $@
if [ "$mediamonitor" = "t" -o "$pypo" = "t" ]; then
#deactivate virtualenv
deactivate
fi
#An attempt to force apache to realize that files are updated on upgrade...
touch /usr/share/airtime/public/index.php
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 10
set +e
airtime-check-system --no-color
set -e
fi
echo -e "\n******************************* Install Complete *******************************"

File diff suppressed because it is too large Load Diff

View File

@ -1,66 +0,0 @@
#!/bin/bash
#Check if root user
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
options=$(getopt -o p -l purge -- "$@")
if [ $? -ne 0 ]; then
echo "only -p or --purge parameter allowed"
exit 1
fi
eval set -- "$options"
purge='f'
while true
do
case "$1" in
-p|--purge) purge='t'; shift;;
--) shift 1; break ;;
*) break ;;
esac
done
#Make 'purge' env variable available to sub bash script
export purge
rabbitmq_uninstall () {
RABBITMQ_VHOST="/airtime"
RABBITMQ_USER="airtime"
rabbitmqctl delete_vhost $RABBITMQ_VHOST
rabbitmqctl delete_user $RABBITMQ_USER
}
echo -e "\n******************************* Uninstall Begin ********************************"
# 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
SCRIPTPATH=`dirname $SCRIPT`
rabbitmq_uninstall
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
#Uninitialize Airtime
$SCRIPTPATH/include/airtime-uninitialize.sh
#Remove Airtime files
$SCRIPTPATH/include/airtime-remove-files.sh
#Remove pypo user
python $SCRIPTPATH/../python_apps/remove-pypo-user.py
#deactivate virtualenv
deactivate
echo -e "\n****************************** Uninstall Complete *******************************\n"
echo "NOTE: To fully remove all Airtime files, you will also have to manually delete"
echo " the directories '/srv/airtime'(default storage location of media files)"
echo -e " and '/etc/airtime'(where the config files are stored).\n"

View File

@ -1,349 +0,0 @@
<?php
/**
* @package Airtime
* @copyright 2011 Sourcefabric o.p.s.
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
// Do not allow remote execution
$arr = array_diff_assoc($_SERVER, $_ENV);
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
header("HTTP/1.1 400");
header("Content-type: text/plain; charset=UTF-8");
echo "400 Not executable\r\n";
exit(1);
}
//make sure user has Postgresql PHP extension installed.
if (!function_exists('pg_connect')) {
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
exit(2);
}
/* This class deals with the config files stored in /etc/airtime */
class AirtimeIni
{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
public static function IniFilesExist()
{
$configFiles = array(self::CONF_FILE_AIRTIME,
self::CONF_FILE_PYPO,
self::CONF_FILE_RECORDER,
self::CONF_FILE_LIQUIDSOAP,
self::CONF_FILE_MEDIAMONITOR);
$exist = false;
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Existing config file detected at $conf".PHP_EOL;
$exist = true;
}
}
return $exist;
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles()
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
if (!copy(AirtimeInstall::GetAirtimeSrcDir()."/build/airtime.conf", self::CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(self::CONF_FILE_AIRTIME, self::CONF_WWW_DATA_GRP)){
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
exit(1);
}
if (getenv("python_service") == "0"){
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", self::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(self::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", self::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(self::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/pypo/liquidsoap_scripts/liquidsoap.cfg", self::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(self::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", self::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(self::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
exit(1);
}
}
}
public static function ChangeFileOwnerGroupMod($filename, $user){
return (chown($filename, $user) &&
chgrp($filename, $user) &&
chmod($filename, 0640));
}
public static function RemoveMonitFile(){
@unlink("/etc/monit/conf.d/airtime-monit.cfg");
}
/**
* This function removes /etc/airtime and the configuration
* files present within it.
*/
public static function RemoveIniFiles()
{
if (file_exists(self::CONF_FILE_AIRTIME)){
unlink(self::CONF_FILE_AIRTIME);
}
if (file_exists(self::CONF_FILE_PYPO)){
unlink(self::CONF_FILE_PYPO);
}
if (file_exists(self::CONF_FILE_RECORDER)){
unlink(self::CONF_FILE_RECORDER);
}
if (file_exists(self::CONF_FILE_LIQUIDSOAP)){
unlink(self::CONF_FILE_LIQUIDSOAP);
}
//wait until Airtime 1.9.0
if (file_exists(self::CONF_FILE_MEDIAMONITOR)){
unlink(self::CONF_FILE_MEDIAMONITOR);
}
if (file_exists("etc/airtime")){
rmdir("/etc/airtime/");
}
}
/**
* This function generates a random string.
*
* The random string uses two parameters: $p_len and $p_chars. These
* parameters do not need to be provided, in which case defaults are
* used.
*
* @param string $p_len
* How long should the generated string be.
* @param string $p_chars
* String containing chars that should be used for generating.
* @return string
* The generated random string.
*/
public static function GenerateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
{
$string = '';
for ($i = 0; $i < $p_len; $i++)
{
$pos = mt_rand(0, strlen($p_chars)-1);
$string .= $p_chars{$pos};
}
return $string;
}
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
public static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
//stupid hack found on http://stackoverflow.com/a/1268642/276949
//with some modifications: 1) Spaces are inserted in between sections and
//2) values are not quoted.
public static function write_ini_file($assoc_arr, $path, $has_sections = false) {
$content = "";
if ($has_sections) {
$first_line = true;
foreach ($assoc_arr as $key=>$elem) {
if ($first_line) {
$content .= "[".$key."]\n";
$first_line = false;
} else {
$content .= "\n[".$key."]\n";
}
foreach ($elem as $key2=>$elem2) {
if(is_array($elem2))
{
for($i=0;$i<count($elem2);$i++)
{
$content .= $key2."[] = \"".$elem2[$i]."\"\n";
}
}
else if($elem2=="") $content .= $key2." = \n";
else $content .= $key2." = ".$elem2."\n";
}
}
} else {
foreach ($assoc_arr as $key=>$elem) {
if(is_array($elem))
{
for($i=0;$i<count($elem);$i++)
{
$content .= $key."[] = \"".$elem[$i]."\"\n";
}
}
else if($elem=="") $content .= $key." = \n";
else $content .= $key." = ".$elem."\n";
}
}
if (!$handle = fopen($path, 'w')) {
return false;
}
if (!fwrite($handle, $content)) {
return false;
}
fclose($handle);
return true;
}
/**
* After the configuration files have been copied to /etc/airtime,
* this function will update them to values unique to this
* particular installation.
*/
public static function UpdateIniFiles()
{
$api_key = self::GenerateRandomString();
if (getenv("web") == "t"){
//self::UpdateIniValue(self::CONF_FILE_AIRTIME, 'api_key', $api_key);
//self::UpdateIniValue(self::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
//self::UpdateIniValue(self::CONF_FILE_AIRTIME, 'password', self::GenerateRandomString());
$ini = parse_ini_file(self::CONF_FILE_AIRTIME, true);
$ini['general']['api_key'] = $api_key;
$ini['general']['airtime_dir'] = AirtimeInstall::CONF_DIR_WWW;
$ini['rabbitmq']['vhost'] = '/airtime';
$ini['rabbitmq']['user'] = 'airtime';
$ini['rabbitmq']['password'] = self::GenerateRandomString();
self::write_ini_file($ini, self::CONF_FILE_AIRTIME, true);
}
//self::UpdateIniValue(self::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'");
$ini = parse_ini_file(self::CONF_FILE_API_CLIENT);
$ini['api_key'] = "'$api_key'";
self::write_ini_file($ini, self::CONF_FILE_API_CLIENT);
}
public static function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i], 2);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
public static function MergeConfigFiles($configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = self::ReadPythonConfig($conf);
$oldSettings = self::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
if(isset($oldSettings[$section][$sectionKey])) {
self::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
else {
self::UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
}

View File

@ -1,500 +0,0 @@
<?php
set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
//Zend framework
if (file_exists('/usr/share/php/libzend-framework-php')){
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
}
#require_once('Zend/Loader/Autoloader.php');
class AirtimeInstall
{
const CONF_DIR_BINARIES = "/usr/lib/airtime";
const CONF_DIR_WWW = "/usr/share/airtime";
const CONF_DIR_LOG = "/var/log/airtime";
public static $databaseTablesCreated = false;
public static function GetAirtimeSrcDir()
{
return __DIR__."/../../airtime_mvc";
}
public static function GetUtilsSrcDir()
{
return __DIR__."/../../utils";
}
/**
* Ensures that the user is running this PHP script with root
* permissions. If not running with root permissions, causes the
* script to exit.
*/
public static function ExitIfNotRoot()
{
// Need to check that we are superuser before running this.
if(posix_geteuid() != 0){
echo "Must be root user.\n";
exit(1);
}
}
/**
* Return the version of Airtime currently installed.
* If not installed, return null.
*
* @return NULL|string
*/
public static function GetVersionInstalled()
{
try {
$con = Propel::getConnection();
} catch (PropelException $e) {
return null;
}
if (file_exists('/etc/airtime/airtime.conf')) {
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
}
else {
return null;
}
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
try {
$version = $con->query($sql)->fetchColumn(0);
} catch (PDOException $e){
// no pref table therefore Airtime is not installed.
//We only get here if airtime database exists, but the table doesn't
//This state sometimes happens if a previous Airtime uninstall couldn't remove
//the database because it was busy, so it just removed the tables instead.
return null;
}
//if version is empty string, then version is older than version 1.8.0
if ($version == '') {
try {
// If this table exists, then it's version 1.7.0
$sql = "SELECT * FROM cc_show_rebroadcast LIMIT 1";
$result = $con->query($sql)->fetchColumn(0);
$version = "1.7.0";
} catch (Exception $e) {
$version = null;
}
}
return $version;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
public static function InstallQuery($sql, $verbose = true)
{
$con = Propel::getConnection();
try {
$con->exec($sql);
if ($verbose) {
echo "done.\n";
}
} catch (Exception $e) {
echo "Error!\n".$e->getMessage()."\n";
echo " SQL statement was:\n";
echo " ".$sql."\n\n";
}
}
public static function DropSequence($p_sequenceName)
{
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName", false);
}
/**
* Try to connect to the database. Return true on success, false on failure.
* @param boolean $p_exitOnError
* Exit the program on failure.
* @return boolean
*/
public static function DbConnect($p_exitOnError = true)
{
$CC_CONFIG = Config::getConfig();
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.".PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
/* TODO: This function should be moved to the media-monitor
* install script. */
public static function InstallStorageDirectory()
{
$CC_CONFIG = Config::getConfig();
echo "* Storage directory setup".PHP_EOL;
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
$stor_dir = $ini["storage_dir"];
$dirs = array($stor_dir, $stor_dir."/organize");
foreach ($dirs as $dir){
if (!file_exists($dir)) {
if (mkdir($dir, 02775, true)){
$rp = realpath($dir);
echo "* Directory $rp created".PHP_EOL;
} else {
echo "* Failed creating {$dir}".PHP_EOL;
exit(1);
}
}
else if (is_writable($dir)) {
$rp = realpath($dir);
echo "* Skipping directory already exists: $rp".PHP_EOL;
}
else {
$rp = realpath($dir);
echo "* Error: Directory already exists, but is not writable: $rp".PHP_EOL;
exit(1);
}
echo "* Giving Apache permission to access $rp".PHP_EOL;
$success = chown($rp, $CC_CONFIG["webServerUser"]);
$success = chgrp($rp, $CC_CONFIG["webServerUser"]);
$success = chmod($rp, 0775);
}
}
public static function CreateDatabaseUser()
{
$CC_CONFIG = Config::getConfig();
echo " * Creating Airtime database user".PHP_EOL;
$username = $CC_CONFIG['dsn']['username'];
$password = $CC_CONFIG['dsn']['password'];
$command = "echo \"CREATE USER $username ENCRYPTED PASSWORD '$password' LOGIN CREATEDB NOCREATEUSER;\" | su postgres -c psql 2>/dev/null";
@exec($command, $output, $results);
if ($results == 0) {
echo " * Database user '{$CC_CONFIG['dsn']['username']}' created.".PHP_EOL;
} else {
if (count($output) > 0) {
echo " * Could not create user '{$CC_CONFIG['dsn']['username']}': ".PHP_EOL;
echo implode(PHP_EOL, $output);
}
else {
echo " * Database user '{$CC_CONFIG['dsn']['username']}' already exists.".PHP_EOL;
}
}
}
public static function CreateDatabase()
{
$CC_CONFIG = Config::getConfig();
$database = $CC_CONFIG['dsn']['database'];
$username = $CC_CONFIG['dsn']['username'];
#$command = "echo \"CREATE DATABASE $database OWNER $username\" | su postgres -c psql 2>/dev/null";
echo " * Creating Airtime database: " . $database . PHP_EOL;
putenv("LC_ALL=en_CA.UTF-8"); //Squash warnings when running unit tests
$command = "su postgres -c \"psql -l | cut -f2 -d' ' | grep -w '{$database}'\";";
exec($command, $output, $rv);
if ($rv == 0) {
//database already exists
echo "Database already exists." . PHP_EOL;
return true;
}
$command = "sudo -i -u postgres psql postgres -c \"CREATE DATABASE ".$database." WITH ENCODING 'UTF8' TEMPLATE template0 OWNER ".$username."\"";
@exec($command, $output, $results);
if ($results == 0) {
echo " * Database '{$CC_CONFIG['dsn']['database']}' created.".PHP_EOL;
} else {
if (count($output) > 0) {
echo " * Could not create database '{$CC_CONFIG['dsn']['database']}': ".PHP_EOL;
echo implode(PHP_EOL, $output);
}
else {
echo " * Database '{$CC_CONFIG['dsn']['database']}' already exists.".PHP_EOL;
}
}
$databaseExisted = ($results != 0);
return $databaseExisted;
}
public static function InstallPostgresScriptingLanguage()
{
$con = Propel::getConnection();
// Install postgres scripting language
$sql = 'SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'';
$langIsInstalled = $con->query($sql)->fetchColumn(0);
if ($langIsInstalled == '0') {
echo " * Installing Postgres scripting language".PHP_EOL;
$sql = "CREATE LANGUAGE 'plpgsql'";
AirtimeInstall::InstallQuery($sql, false);
} else {
echo " * Postgres scripting language already installed".PHP_EOL;
}
}
public static function CreateDatabaseTables($p_dbuser, $p_dbpasswd, $p_dbname, $p_dbhost)
{
echo " * Creating database tables".PHP_EOL;
// Put Propel sql files in Database
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
$dir = self::GetAirtimeSrcDir()."/build/sql/";
$files = array("schema.sql", "sequences.sql", "views.sql", "triggers.sql", "defaultdata.sql");
foreach ($files as $f){
$command = "export PGPASSWORD=$p_dbpasswd && psql --username $p_dbuser --dbname $p_dbname --host $p_dbhost --file $dir$f 2>/dev/null";
@exec($command, $output, $results);
}
AirtimeInstall::$databaseTablesCreated = true;
}
public static function BypassMigrations($dir, $version)
{
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function MigrateTablesToVersion($dir, $version)
{
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
}
public static function SetAirtimeVersion($p_version)
{
$con = Propel::getConnection();
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
$con->exec($sql);
Application_Model_Preference::SetAirtimeVersion($p_version);
}
public static function SetUniqueId()
{
$uniqueId = md5(uniqid("", true));
Application_Model_Preference::SetUniqueId($uniqueId);
}
public static function GetAirtimeVersion()
{
$con = Propel::getConnection();
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
$version = $con->query($sql)->fetchColumn(0);
return $version;
}
public static function DeleteFilesRecursive($p_path)
{
$command = "rm -rf \"$p_path\"";
exec($command);
}
public static function CreateSymlinksToUtils()
{
echo "* Creating /usr/bin symlinks".PHP_EOL;
AirtimeInstall::RemoveSymlinks();
echo "* Installing airtime-import".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-import/airtime-import";
exec("ln -s $dir /usr/bin/airtime-import");
echo "* Installing airtime-update-db-settings".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-update-db-settings";
exec("ln -s $dir /usr/bin/airtime-update-db-settings");
echo "* Installing airtime-check-system".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-check-system";
exec("ln -s $dir /usr/bin/airtime-check-system");
echo "* Installing airtime-user".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-user";
exec("ln -s $dir /usr/bin/airtime-user");
echo "* Installing airtime-log".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log";
exec("ln -s $dir /usr/bin/airtime-log");
}
public static function RemoveSymlinks()
{
exec("rm -f /usr/bin/airtime-import");
exec("rm -f /usr/bin/airtime-update-db-settings");
exec("rm -f /usr/bin/airtime-check-system");
exec("rm -f /usr/bin/airtime-user");
exec("rm -f /usr/bin/airtime-log");
exec("rm -f /usr/bin/airtime-clean-storage");
}
public static function InstallPhpCode()
{
$CC_CONFIG = Config::getConfig();
echo "* Installing PHP code to ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
exec("mkdir -p ".AirtimeInstall::CONF_DIR_WWW);
exec("cp -R ".AirtimeInstall::GetAirtimeSrcDir()."/* ".AirtimeInstall::CONF_DIR_WWW);
}
public static function UninstallPhpCode()
{
echo "* Removing PHP code from ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
exec('rm -rf "'.AirtimeInstall::CONF_DIR_WWW.'"');
}
public static function InstallBinaries()
{
echo "* Installing binaries to ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
exec("mkdir -p ".AirtimeInstall::CONF_DIR_BINARIES);
exec("cp -R ".AirtimeInstall::GetUtilsSrcDir()." ".AirtimeInstall::CONF_DIR_BINARIES);
}
public static function UninstallBinaries()
{
echo "* Removing Airtime binaries from ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
exec('rm -rf "'.AirtimeInstall::CONF_DIR_BINARIES.'"');
}
public static function DirCheck()
{
echo "Legend: \"+\" means the dir/file exists, \"-\" means that it does not.".PHP_EOL;
$dirs = array(AirtimeInstall::CONF_DIR_BINARIES,
AirtimeInstall::CONF_DIR_WWW,
AirtimeIni::CONF_FILE_AIRTIME,
AirtimeIni::CONF_FILE_LIQUIDSOAP,
AirtimeIni::CONF_FILE_PYPO,
AirtimeIni::CONF_FILE_RECORDER,
"/usr/lib/airtime/pypo",
"/var/log/airtime",
"/var/log/airtime/pypo",
"/var/tmp/airtime/pypo");
foreach ($dirs as $f) {
if (file_exists($f)) {
echo "+ $f".PHP_EOL;
} else {
echo "- $f".PHP_EOL;
}
}
}
public static function CreateZendPhpLogFile(){
$CC_CONFIG = Config::getConfig();
$path = AirtimeInstall::CONF_DIR_LOG;
$file = $path.'/zendphp.log';
if (!file_exists($path)){
mkdir($path, 0755, true);
}
touch($file);
chmod($file, 0644);
chown($file, $CC_CONFIG['webServerUser']);
chgrp($file, $CC_CONFIG['webServerUser']);
}
public static function RemoveLogDirectories(){
$path = AirtimeInstall::CONF_DIR_LOG;
echo "* Removing logs directory ".$path.PHP_EOL;
exec("rm -rf \"$path\"");
}
public static function CreateCronFile(){
echo "* Creating Cron File".PHP_EOL;
// Create CRON task to run every day. Time of day is initialized to a random time.
$hour = rand(0,23);
$minute = rand(0,59);
$fp = fopen('/etc/cron.d/airtime-crons','w');
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
fclose($fp);
}
public static function removeVirtualEnvDistributeFile(){
echo "* Removing distribute-0.6.10.tar.gz".PHP_EOL;
if(file_exists('/usr/share/python-virtualenv/distribute-0.6.10.tar.gz')){
exec("rm -f /usr/share/python-virtualenv/distribute-0.6.10.tar.gz");
}
}
public static function printUsage($opts)
{
$msg = $opts->getUsageMessage();
echo PHP_EOL."Usage: airtime-install [options]";
echo substr($msg, strpos($msg, "\n")).PHP_EOL;
}
public static function getOpts()
{
try {
$autoloader = Zend_Loader_Autoloader::getInstance();
$opts = new Zend_Console_Getopt(
array(
'help|h' => 'Displays usage information.',
'overwrite|o' => 'Overwrite any existing config files.',
'preserve|p' => 'Keep any existing config files.',
'no-db|n' => 'Turn off database install.',
'reinstall|r' => 'Force a fresh install of this Airtime Version',
'webonly|w' => 'Install only web files'
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
print $e->getMessage() .PHP_EOL;
AirtimeInstall::printUsage($opts);
return NULL;
}
return $opts;
}
public static function checkPHPVersion()
{
if (PHP_VERSION_ID < 50300)
{
echo "Error: Airtime requires PHP 5.3 or greater.";
return false;
}
return true;
}
}

View File

@ -1,3 +0,0 @@
<?php
define('AIRTIME_VERSION', '2.5.1');

View File

@ -1,111 +0,0 @@
#!/bin/bash -e
#-e Causes bash script to exit if any of the installers
#return with a non-zero return value.
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
#copy files to
## /etc/airtime
#+ /etc/apache2/sites-available/airtime
#+ /etc/apache2/sites-enabled/airtime
## /etc/cron.d/
## /etc/init.d/
## /etc/monit/conf.d/
# /usr/lib/airtime/airtime_virtualenv
## /usr/lib/airtime/api_clients
## /usr/lib/airtime/media-monitor
# /srv/airtime/stor
## /usr/lib/airtime/pypo
## /usr/lib/airtime/show-recorder
## /usr/lib/airtime/utils
## /usr/bin/airtime-*
## /usr/share/airtime
## /var/log/airtime
## /var/tmp/airtime
# 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
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
echo "* Creating /etc/airtime"
mkdir -p /etc/airtime
if [ ! -e /etc/airtime/airtime.conf ]; then
#config file airtime.conf exists, but Airtime is not installed
cp $AIRTIMEROOT/airtime_mvc/build/airtime.conf /etc/airtime
fi
#if [ -e /etc/airtime/airtime.conf -a "$DO_UPGRADE" -eq "0" ]; then
#config file airtime.conf exists, but Airtime is not installed
# mv /etc/airtime/airtime.conf airtime.conf.bak
# cp $AIRTIMEROOT/airtime_mvc/build/airtime.conf /etc/airtime
#fi
echo "* Creating /etc/monit/conf.d/monit-airtime-generic.cfg"
mkdir -p /etc/monit/conf.d/
if [ ! -e /etc/monit/conf.d/monit-airtime-generic.cfg ]; then
rm -f /etc/monit/conf.d/*airtime*
cp $AIRTIMEROOT/python_apps/monit/monit-airtime-generic.cfg /etc/monit/conf.d/
fi
echo "* Creating /etc/cron.d/airtime-crons"
HOUR=$(($RANDOM%24))
MIN=$(($RANDOM%60))
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons
echo "* Creating /usr/lib/airtime"
if [ "$python_service" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/api_clients/install/api_client_install.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
fi
cp -R $AIRTIMEROOT/utils /usr/lib/airtime
cp -R $AIRTIMEROOT/python_apps/std_err_override /usr/lib/airtime
echo "* Creating symbolic links in /usr/bin"
#create symbolic links
ln -sf /usr/lib/airtime/utils/airtime-import/airtime-import /usr/bin/airtime-import
ln -sf /usr/lib/airtime/utils/airtime-update-db-settings /usr/bin/airtime-update-db-settings
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-test-soundcard /usr/bin/airtime-test-soundcard
ln -sf /usr/lib/airtime/utils/airtime-test-stream /usr/bin/airtime-test-stream
ln -sf /usr/lib/airtime/utils/airtime-silan /usr/bin/airtime-silan
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime
chmod a+x /var/log/airtime
chown www-data:www-data /var/log/airtime/
chown pypo:pypo /var/log/airtime/pypo
chown pypo:pypo /var/log/airtime/pypo-liquidsoap
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/
rm -f /etc/logrotate.d/airtime-php
cp $AIRTIMEROOT/airtime_mvc/build/airtime-php.logrotate /etc/logrotate.d/airtime-php
fi
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime
echo "* Creating /var/tmp/airtime"
mkdir -p /var/tmp/airtime
#Finished copying files

View File

@ -1,84 +0,0 @@
<?php
/**
* This file is separated out so that it can be run separately for DEB package installation.
* When installing a DEB package, Postgresql may not be installed yet and thus the database
* cannot be created. So this script is run after all DEB packages have been installed.
*/
require_once(__DIR__.'/AirtimeIni.php');
require_once(__DIR__.'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
//Propel classes.
set_include_path(AirtimeInstall::GetAirtimeSrcDir().'/application/models' . PATH_SEPARATOR . get_include_path());
$CC_CONFIG = Config::getConfig();
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
//use this class to set new values in the cache as well.
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/common/Database.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/models/Preference.php');
echo PHP_EOL."* Database Installation".PHP_EOL;
AirtimeInstall::CreateDatabaseUser();
$databaseExisted = AirtimeInstall::CreateDatabase();
AirtimeInstall::DbConnect(true);
AirtimeInstall::InstallPostgresScriptingLanguage();
//Load Database parameters
$dbuser = $CC_CONFIG['dsn']['username'];
$dbpasswd = $CC_CONFIG['dsn']['password'];
$dbname = $CC_CONFIG['dsn']['database'];
$dbhost = $CC_CONFIG['dsn']['hostspec'];
if (isset($argv[1]) && $argv[1] == 'y') {
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
} else if ($databaseExisted) {
//Database already exists. Ask the user how they want to
//proceed. Warn them that creating the database tables again
//will cause them to lose their old ones.
$userAnswer = "x";
while (!in_array($userAnswer, array("y", "Y", "n", "N", ""))) {
echo PHP_EOL."Database already exists. Do you want to delete all tables and recreate? (y/N)";
$userAnswer = trim(fgets(STDIN));
}
if (in_array($userAnswer, array("y", "Y"))) {
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
}
} else {
//Database was just created, meaning the tables do not
//exist. Let's create them.
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
}
echo " * Setting Airtime version".PHP_EOL;
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
if (AirtimeInstall::$databaseTablesCreated) {
// set up some keys in DB
AirtimeInstall::SetUniqueId();
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
$stor_dir = realpath($ini["storage_dir"])."/";
echo " * Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
$con = Propel::getConnection();
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
try {
$con->exec($sql);
} catch (Exception $e) {
echo " * Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
echo " * Message {$e->getMessage()}".PHP_EOL;
exit(1);
}
}

View File

@ -1,67 +0,0 @@
#!/bin/bash -e
#-e Causes bash script to exit if any of the installers
#return with a non-zero return value.
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
set +e
dist=`lsb_release -is`
echo "Generating locales"
for i in `ls /usr/share/airtime/locale | grep ".._.."`; do
if [ "$dist" = "Debian" ]; then
grep -qi "^$i" /etc/locale.gen
if [ $? -ne 0 ]; then
echo "$i.UTF-8 UTF-8" >> /etc/locale.gen
fi
else
locale-gen "$i.utf8"
fi
done
set -e
if [ "$dist" = "Debian" ]; then
/usr/sbin/locale-gen
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
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
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
chmod 600 /etc/monit/conf.d/monit-airtime-generic.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-media-monitor.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-playout.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg
# 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.
# If monit is already running, this step is still useful as we need monit to
# reload its config files.
invoke-rc.d monit restart
#give monit some time to boot-up before issuing commands
sleep 1
set +e
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
fi
set -e

View File

@ -1 +0,0 @@
storage_dir = /srv/airtime/stor/

View File

@ -1,88 +0,0 @@
<?php
/**
* @package Airtime
* @copyright 2011 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
require_once(__DIR__.'/AirtimeIni.php');
require_once(__DIR__.'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
// -------------------------------------------------------------------------
// The only way we get here is if we are doing a new install or a reinstall.
// -------------------------------------------------------------------------
if (PHP_VERSION_ID < 50300) //PHP 5.3
{
echo("ERROR: Your PHP version is too old!\nAirtime requires PHP 5.3 or greater.\n");
exit(1);
}
$iniExists = file_exists("/etc/airtime/airtime.conf");
if ($iniExists) {
//reinstall, Will ask if we should rewrite config files.
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
$CC_CONFIG = Config::getConfig();
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
$version = AirtimeInstall::GetVersionInstalled();
$newInstall = is_null($version);
} else {
//create config files without asking
$newInstall = true;
}
$overwrite = false;
if (getenv("overwrite") == "t" || $newInstall == true) {
$overwrite = true;
} 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", ""))) {
echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) ";
$userAnswer = trim(fgets(STDIN));
}
if (in_array($userAnswer, array("o", "O"))) {
$overwrite = true;
}
} else {
$overwrite = true;
}
}
if ($overwrite) {
echo "* Creating INI files".PHP_EOL;
AirtimeIni::CreateIniFiles();
echo "* Initializing INI files".PHP_EOL;
AirtimeIni::UpdateIniFiles();
}
if (!$iniExists){
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
$CC_CONFIG = Config::getConfig();
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
}
echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
AirtimeInstall::InstallStorageDirectory();
$db_install = getenv("nodb")!="t";
if ($db_install) {
echo "* Checking database for correct encoding".PHP_EOL;
exec('su -c \'psql -t -c "SHOW SERVER_ENCODING"\' postgres | grep -i "UTF.*8"', $out, $return_code);
if ($return_code != 0){
echo " * Unfortunately your postgresql database has not been created using a UTF-8 encoding.".PHP_EOL;
echo " * As of Airtime 2.1, installs will fail unless the encoding has been set to UTF-8. Please verify this is the case".PHP_EOL;
echo " * and try the install again".PHP_EOL;
exit(1);
}
if($newInstall) {
//call external script. "y" argument means force creation of database tables.
passthru('php '.__DIR__.'/airtime-db-install.php y');
} else {
require_once('airtime-db-install.php');
}
}

View File

@ -1,48 +0,0 @@
<?php
/**
* Checks if a current version of Airtime is installed.
* If so, the user is presented with the help menu and can
* choose -r to reinstall.
*
* Returns 0 if Airtime is not installed
* 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(__DIR__.'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
AirtimeInstall::ExitIfNotRoot();
if (!file_exists('/etc/airtime/airtime.conf')) {
#airtime.conf doesn't exist, and we need it to connect to database
#Assume Airtime is not installed.
exit(0);
}
require_once(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/db-conf.php");
$CC_CONFIG = Config::getConfig();
require_once('propel/runtime/lib/Propel.php');
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
$version = AirtimeInstall::GetVersionInstalled();
// The current version is already installed.
echo "* Checking for existing Airtime installation...".PHP_EOL;
if (isset($version)){
if (is_null($version)){
//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 {
//no previous version of Airtime found
exit(0);
}

View File

@ -1,45 +0,0 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
########################################################################
# Complete list of files that we need to remove is available in
# airtime-copy-files.sh
#######################################################################
# 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
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
rm -f /etc/cron.d/airtime-crons
rm -f /etc/monit/conf.d/monit-airtime*
rm -f /etc/logrotate.d/airtime-php
echo "* API Client"
python $AIRTIMEROOT/python_apps/api_clients/install/api_client_uninstall.py
echo "* Pypo"
python $AIRTIMEROOT/python_apps/pypo/install/pypo-remove-files.py
echo "* Media-Monitor"
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-remove-files.py
#remove symlinks
rm -f /usr/bin/airtime-import
rm -f /usr/bin/airtime-update-db-settings
rm -f /usr/bin/airtime-check-system
rm -f /usr/bin/airtime-log
rm -f /usr/bin/airtime-test-soundcard
rm -f /usr/bin/airtime-test-stream
rm -f /usr/bin/airtime-silan
rm -rf /usr/lib/airtime
rm -rf /usr/share/airtime
rm -rf /var/log/airtime
rm -rf /var/tmp/airtime

View File

@ -1,31 +0,0 @@
#!/bin/bash
#-e Causes bash script to exit if any of the installers
#return with a non-zero return value.
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
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
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
#unmonitor services
echo "Unmonitoring Airtime Services"
set +e
monit unmonitor airtime-media-monitor >/dev/null 2>&1
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
monit unmonitor airtime-playout >/dev/null 2>&1
set -e
#uninitialize Airtime services
python $AIRTIMEROOT/python_apps/pypo/install/pypo-uninitialize.py
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-uninitialize.py
if [ "$purge" = "t" ]; then
#call Airtime uninstall script
php --php-ini ${SCRIPTPATH}/../airtime-php.ini ${SCRIPTPATH}/airtime-uninstall.php
fi

View File

@ -1,107 +0,0 @@
<?php
/**
* @package Airtime
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
require_once(dirname(__FILE__).'/AirtimeIni.php');
require_once(dirname(__FILE__).'/AirtimeInstall.php');
// Need to check that we are superuser before running this.
AirtimeInstall::ExitIfNotRoot();
if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) {
echo PHP_EOL."Airtime config file '".AirtimeIni::CONF_FILE_AIRTIME."' does not exist.".PHP_EOL;
echo "Most likely this means that Airtime is not installed, so there is nothing to do.".PHP_EOL.PHP_EOL;
exit();
}
require_once(__DIR__.'/airtime-constants.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
$CC_CONFIG = Config::getConfig();
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
echo PHP_EOL;
echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
//------------------------------------------------------------------------
// Delete the database
// Note: Do not put a call to AirtimeInstall::DbConnect()
// before this function, it will create a connection to the database
// and you wont be able to delete it.
//------------------------------------------------------------------------
//close connection for any process id using airtime database since we are about to drop the database.
$sql = "SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE datname = 'airtime';";
$command = "echo \"$sql\" | su postgres -c psql";
@exec($command, $output);
$CC_CONFIG = Config::getConfig();
echo " * Dropping the database '".$CC_CONFIG["dsn"]["database"]."'...".PHP_EOL;
//dropdb returns 1 if other sessions are using the database, otherwise returns 0
$command = "su postgres -c \"dropdb ".$CC_CONFIG["dsn"]["database"]."\"";
@exec($command, $output, $dbDeleteFailed);
//------------------------------------------------------------------------
// Delete DB tables
// We do this if dropping the database fails above.
//------------------------------------------------------------------------
if ($dbDeleteFailed) {
$connected = AirtimeInstall::DbConnect(false);
if ($connected) {
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
$con = Propel::getConnection();
$sql = "select * from pg_tables where tableowner = 'airtime'";
try {
$rows = $con->query($sql)->fetchAll();
} catch (Exception $e) {
$rows = array();
}
foreach ($rows as $row) {
$tablename = $row["tablename"];
echo " * Removing database table $tablename...";
$sql = "DROP TABLE $tablename CASCADE";
AirtimeInstall::InstallQuery($sql, false);
AirtimeInstall::DropSequence($tablename."_id");
echo "done.".PHP_EOL;
}
echo " * Deleting database sequences...".PHP_EOL;
$sql = "SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';";
try {
$rows = $con->query($sql)->fetchAll();
} catch (Exception $e) {
$rows = array();
}
foreach ($rows as $row) {
$sequence = $row["relname"];
echo " * Removing database sequence $sequence...";
$sql = "DROP SEQUENCE $sequence CASCADE";
AirtimeInstall::InstallQuery($sql, false);
echo "done.".PHP_EOL;
}
}
}
//------------------------------------------------------------------------
// Delete the user
//------------------------------------------------------------------------
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'...".PHP_EOL;
$command = "echo \"DROP USER IF EXISTS {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql >/dev/null 2>&1";
@exec($command, $output, $results);
if ($results == 0) {
echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.".PHP_EOL;
} else {
echo " * Nothing to delete.".PHP_EOL;
}

View File

@ -1,105 +0,0 @@
<?php
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
if (posix_geteuid() != 0) {
echo "Must be root user.\n";
exit(1);
}
require_once(__DIR__.'/airtime-constants.php');
require_once(__DIR__.'/AirtimeIni.php');
require_once(__DIR__.'/AirtimeInstall.php');
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/db-conf.php");
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
function pause()
{
/* Type "sudo -s" to change to root user then type "export AIRTIME_INSTALL_DEBUG=1" and then
* start airtime-install to enable this feature. Is used to pause between upgrade scripts
* to examine the state of the system and see if everything is as expected. */
if (getenv("AIRTIME_INSTALL_DEBUG") === "1") {
echo "Press Enter to Continue".PHP_EOL;
fgets(STDIN);
}
}
AirtimeInstall::DbConnect(true);
$con = Propel::getConnection();
$version = AirtimeInstall::GetVersionInstalled();
//Enforce a minimum PHP version
if (!AirtimeInstall::checkPHPVersion())
{
exit(1);
}
echo "******************************** Upgrade Begin *********************************".PHP_EOL;
$CC_CONFIG = Config::getConfig();
$user = $CC_CONFIG['dsn']['username'];
$password = $CC_CONFIG['dsn']['password'];
$host = $CC_CONFIG['dsn']['hostspec'];
$database = $CC_CONFIG['dsn']['database'];
$airtime_version = AIRTIME_VERSION;
$target_dir = trim(getenv("HOME"));
if (strlen($target_dir) == 0) {
$target_dir = "/tmp";
}
$target_file = "/airtime_$airtime_version.sql";
$target_path = $target_dir.$target_file;
echo "* Backing up current database to $target_path".PHP_EOL;
exec("export PGPASSWORD=$password && pg_dump -h $host -U $user -f $target_path $database", $arr, $return_code);
if ($return_code == 0) {
echo " * Success".PHP_EOL;
} else {
echo " * Failed".PHP_EOL;
exit(1);
}
//convert strings like 1.9.0-devel to 1.9.0
$version = substr($version, 0, 5);
$SCRIPTPATH = __DIR__;
if (strcmp($version, "2.2.0") < 0) {
echo "Unsupported Airtime version. You must upgrade from at least Airtime 2.2.0.".PHP_EOL;
exit(1);
}
if (strcmp($version, "2.2.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.2.1/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.3.0") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.3.0/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.3.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.3.1/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.4.0") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.4.0/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.4.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.4.1/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.5.0") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.0/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.5.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.1/airtime-upgrade.php");
pause();
}
echo "******************************* Upgrade Complete *******************************".PHP_EOL;

View File

@ -1,16 +0,0 @@
<?php
/* This class deals with any modifications to config files in /etc/airtime
* as well as backups. All functions other than start() should be marked
* as private. */
class AirtimeConfigFileUpgrade{
public static function start(){
echo "* Updating configFiles".PHP_EOL;
self::task0();
}
private static function task0(){
UpgradeCommon::upgradeConfigFiles();
}
}

View File

@ -1,24 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,9 +0,0 @@
need to install the following packages:
mp3gain
vorbisgain
flac
vorbis-tools
calculate Replay Gain dB on upgrade: the default value should be NULL.

View File

@ -1,11 +0,0 @@
<?php
require_once 'DbUpgrade.php';
require_once 'ConfFileUpgrade.php';
require_once 'common/UpgradeCommon.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeConfigFileUpgrade::start();
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,322 +0,0 @@
<?php
/* These are helper functions that are common to each upgrade such as
* creating connections to a database, backing up config files etc.
*/
class UpgradeCommon{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
const CONF_BACKUP_SUFFIX = "220";
const VERSION_NUMBER = "2.2.0";
public static function SetDefaultTimezone()
{
$sql = "SELECT valstr from cc_pref WHERE keystr = 'timezone'";
$result = self::queryDb($sql);
$timezone = $result->fetchColumn();
date_default_timezone_set($timezone);
}
public static function connectToDatabase($p_exitOnError = true)
{
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database exists with corresponding permissions.".PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
private static function GetAirtimeSrcDir()
{
return __DIR__."/../../../../airtime_mvc";
}
public static function MigrateTablesToVersion($dir, $version)
{
echo "Upgrading database, may take several minutes, please wait".PHP_EOL;
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
}
public static function BypassMigrations($dir, $version)
{
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function upgradeConfigFiles(){
$configFiles = array(UpgradeCommon::CONF_FILE_AIRTIME,
UpgradeCommon::CONF_FILE_PYPO,
//this is not necessary because liquidsoap configs
//are automatically generated
//UpgradeCommon::CONF_FILE_LIQUIDSOAP,
UpgradeCommon::CONF_FILE_MEDIAMONITOR,
UpgradeCommon::CONF_FILE_API_CLIENT);
// Backup the config files
$suffix = date("Ymdhis")."-".UpgradeCommon::VERSION_NUMBER;
foreach ($configFiles as $conf) {
// do not back up monit cfg -- ok?? not being done anyway
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
//copy($conf, $conf.$suffix.".bak");
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
}
}
self::CreateIniFiles(UpgradeCommon::CONF_BACKUP_SUFFIX);
self::MergeConfigFiles($configFiles, $suffix);
//HACK: This will fix a last minute bug we discovered with our upgrade scripts.
//Will be fixed properly in 2.3.0
$old = "list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%'";
$new = "list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%/all/%%all%%'";
exec("sed -i \"s#$old#$new#g\" /etc/airtime/api_client.cfg");
$old = "update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'";
$new = "update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/'";
exec("sed -i \"s#$old#$new#g\" /etc/airtime/api_client.cfg");
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles($suffix)
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
$config_copy = array(
"../etc/airtime.conf" => self::CONF_FILE_AIRTIME,
"../etc/pypo.cfg" => self::CONF_FILE_PYPO,
"../etc/media-monitor.cfg" => self::CONF_FILE_MEDIAMONITOR,
"../etc/api_client.cfg" => self::CONF_FILE_API_CLIENT
);
echo "Copying configs:\n";
foreach ($config_copy as $path_part => $destination) {
$full_path = OsPath::normpath(OsPath::join(__DIR__,
"$path_part.$suffix"));
echo "'$full_path' --> '$destination'\n";
if(!copy($full_path, $destination)) {
echo "Failed on the copying operation above\n";
exit(1);
}
}
}
private static function MergeConfigFiles(array $configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === self::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = self::ReadPythonConfig($conf);
$oldSettings = self::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
if(isset($oldSettings[$section][$sectionKey])) {
self::UpdateIniValue($conf, $sectionKey,
$oldSettings[$section][$sectionKey]);
}
}
} else {
self::UpdateIniValue($conf, $section,
$oldSettings[$section]);
}
}
}
}
}
}
private static function ReadPythonConfig($p_filename)
{
$values = array();
$fh = fopen($p_filename, 'r');
while(!feof($fh)){
$line = fgets($fh);
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
continue;
}else{
$info = explode('=', $line, 2);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
private static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n = count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
public static function queryDb($p_sql){
$con = Propel::getConnection();
try {
$result = $con->query($p_sql);
} catch (Exception $e) {
echo "Error executing $p_sql. Exiting.";
exit(1);
}
return $result;
}
}
class OsPath {
// this function is from http://stackoverflow.com/questions/2670299/is-there-a-php-equivalent-function-to-the-python-os-path-normpath
public static function normpath($path)
{
if (empty($path))
return '.';
if (strpos($path, '/') === 0)
$initial_slashes = true;
else
$initial_slashes = false;
if (
($initial_slashes) &&
(strpos($path, '//') === 0) &&
(strpos($path, '///') === false)
)
$initial_slashes = 2;
$initial_slashes = (int) $initial_slashes;
$comps = explode('/', $path);
$new_comps = array();
foreach ($comps as $comp)
{
if (in_array($comp, array('', '.')))
continue;
if (
($comp != '..') ||
(!$initial_slashes && !$new_comps) ||
($new_comps && (end($new_comps) == '..'))
)
array_push($new_comps, $comp);
elseif ($new_comps)
array_pop($new_comps);
}
$comps = $new_comps;
$path = implode('/', $comps);
if ($initial_slashes)
$path = str_repeat('/', $initial_slashes) . $path;
if ($path)
return $path;
else
return '.';
}
/* Similar to the os.path.join python method
* http://stackoverflow.com/a/1782990/276949 */
public static function join() {
$args = func_get_args();
$paths = array();
foreach($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
foreach($paths as &$path) {
$path = trim($path, DIRECTORY_SEPARATOR);
}
if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) {
$paths[0] = DIRECTORY_SEPARATOR . $paths[0];
}
return join(DIRECTORY_SEPARATOR, $paths);
}
}

View File

@ -1,227 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.2.0');
--DELETE user column order prefs, since the number of columns has increased in 2.2
DELETE FROM cc_pref where keystr = 'library_datatable';
DELETE FROM cc_pref where keystr = 'timeline_datatable';
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_name', 'Airtime!', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_name', '', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_name', '', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_channels', 'stereo', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_channels', 'stereo', 'string');
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_channels', 'stereo', 'string');
CREATE FUNCTION airtime_to_int(chartoconvert character varying) RETURNS integer
AS
'SELECT CASE WHEN trim($1) SIMILAR TO ''[0-9]+'' THEN CAST(trim($1) AS integer) ELSE NULL END;'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;
--clean up database of scheduled items that weren't properly deleted in 2.1.x
--due to a bug
DELETE
FROM cc_schedule
WHERE id IN
(SELECT s.id
FROM cc_schedule s
LEFT JOIN cc_show_instances si ON s.instance_id = si.id
WHERE si.modified_instance = 't');
ALTER TABLE cc_files
DROP CONSTRAINT cc_files_gunid_idx;
DROP INDEX cc_files_file_exists_idx;
DROP TABLE cc_access;
CREATE SEQUENCE cc_block_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_blockcontents_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_blockcriteria_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_webstream_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_webstream_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE cc_block (
id integer DEFAULT nextval('cc_block_id_seq'::regclass) NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL,
mtime timestamp(6) without time zone,
utime timestamp(6) without time zone,
creator_id integer,
description character varying(512),
length interval DEFAULT '00:00:00'::interval,
type character varying(7) DEFAULT 'static'::character varying
);
CREATE TABLE cc_blockcontents (
id integer DEFAULT nextval('cc_blockcontents_id_seq'::regclass) NOT NULL,
block_id integer,
file_id integer,
"position" integer,
cliplength interval DEFAULT '00:00:00'::interval,
cuein interval DEFAULT '00:00:00'::interval,
cueout interval DEFAULT '00:00:00'::interval,
fadein time without time zone DEFAULT '00:00:00'::time without time zone,
fadeout time without time zone DEFAULT '00:00:00'::time without time zone
);
CREATE TABLE cc_blockcriteria (
id integer DEFAULT nextval('cc_blockcriteria_id_seq'::regclass) NOT NULL,
criteria character varying(32) NOT NULL,
modifier character varying(16) NOT NULL,
"value" character varying(512) NOT NULL,
extra character varying(512),
block_id integer NOT NULL
);
CREATE TABLE cc_webstream (
id integer DEFAULT nextval('cc_webstream_id_seq'::regclass) NOT NULL,
name character varying(255) NOT NULL,
description character varying(255) NOT NULL,
url character varying(512) NOT NULL,
length interval DEFAULT '00:00:00'::interval NOT NULL,
creator_id integer NOT NULL,
mtime timestamp(6) without time zone NOT NULL,
utime timestamp(6) without time zone NOT NULL,
lptime timestamp(6) without time zone,
mime character varying(255)
);
CREATE TABLE cc_webstream_metadata (
id integer DEFAULT nextval('cc_webstream_metadata_id_seq'::regclass) NOT NULL,
instance_id integer NOT NULL,
start_time timestamp without time zone NOT NULL,
liquidsoap_data character varying(1024) NOT NULL
);
ALTER TABLE cc_files
DROP COLUMN gunid,
ADD COLUMN replay_gain numeric,
ADD COLUMN owner_id integer,
ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */;
ALTER TABLE cc_files
ADD CONSTRAINT cc_files_owner_fkey FOREIGN KEY (owner_id) REFERENCES cc_subjs(id);
ALTER TABLE cc_playlistcontents
ADD COLUMN block_id integer,
ADD COLUMN stream_id integer,
ADD COLUMN type smallint DEFAULT 0 NOT NULL;
ALTER TABLE cc_schedule
ADD COLUMN stream_id integer;
CREATE INDEX cc_schedule_instance_id_idx
ON cc_schedule
USING btree
(instance_id);
ALTER TABLE cc_subjs
ADD COLUMN cell_phone character varying(255);
ALTER TABLE cc_block
ADD CONSTRAINT cc_block_pkey PRIMARY KEY (id);
ALTER TABLE cc_blockcontents
ADD CONSTRAINT cc_blockcontents_pkey PRIMARY KEY (id);
ALTER TABLE cc_blockcriteria
ADD CONSTRAINT cc_blockcriteria_pkey PRIMARY KEY (id);
ALTER TABLE cc_webstream
ADD CONSTRAINT cc_webstream_pkey PRIMARY KEY (id);
ALTER TABLE cc_webstream_metadata
ADD CONSTRAINT cc_webstream_metadata_pkey PRIMARY KEY (id);
ALTER TABLE cc_block
ADD CONSTRAINT cc_block_createdby_fkey FOREIGN KEY (creator_id) REFERENCES cc_subjs(id);
ALTER TABLE cc_blockcontents
ADD CONSTRAINT cc_blockcontents_block_id_fkey FOREIGN KEY (block_id) REFERENCES cc_block(id) ON DELETE CASCADE;
ALTER TABLE cc_blockcontents
ADD CONSTRAINT cc_blockcontents_file_id_fkey FOREIGN KEY (file_id) REFERENCES cc_files(id) ON DELETE CASCADE;
ALTER TABLE cc_blockcriteria
ADD CONSTRAINT cc_blockcontents_block_id_fkey FOREIGN KEY (block_id) REFERENCES cc_block(id) ON DELETE CASCADE;
ALTER TABLE cc_playlistcontents
ADD CONSTRAINT cc_playlistcontents_block_id_fkey FOREIGN KEY (block_id) REFERENCES cc_block(id) ON DELETE CASCADE;
ALTER TABLE cc_schedule
ADD CONSTRAINT cc_show_stream_fkey FOREIGN KEY (stream_id) REFERENCES cc_webstream(id) ON DELETE CASCADE;
ALTER TABLE cc_webstream_metadata
ADD CONSTRAINT cc_schedule_inst_fkey FOREIGN KEY (instance_id) REFERENCES cc_schedule(id) ON DELETE CASCADE;
ALTER TABLE cc_playlist
DROP CONSTRAINT cc_playlist_createdby_fkey;
ALTER SEQUENCE cc_block_id_seq
OWNED BY cc_block.id;
ALTER SEQUENCE cc_blockcontents_id_seq
OWNED BY cc_blockcontents.id;
ALTER SEQUENCE cc_blockcriteria_id_seq
OWNED BY cc_blockcriteria.id;
ALTER SEQUENCE cc_webstream_id_seq
OWNED BY cc_webstream.id;
ALTER SEQUENCE cc_webstream_metadata_id_seq
OWNED BY cc_webstream_metadata.id;
ALTER TABLE cc_playlist
ADD CONSTRAINT cc_playlist_createdby_fkey FOREIGN KEY (creator_id) REFERENCES cc_subjs(id) ON DELETE CASCADE;
DROP FUNCTION airtime_to_int(chartoconvert character varying);
UPDATE cc_files
SET owner_id=(SELECT id FROM cc_subjs WHERE type='A' LIMIT 1)
WHERE owner_id is NULL;
UPDATE cc_files
SET mime='audio/ogg'
WHERE mime='audio/vorbis';

View File

@ -1,31 +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
;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

@ -1,121 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
#############################
## Common
#############################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
#URL to register a components IP Address with the central web server
register_component = 'register-component/format/json/api_key/%%api_key%%/component/%%component%%'
# Hostname
base_url = 'localhost'
base_port = 80
#############################
## Config for Media Monitor
#############################
# URL to setup the media monitor
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
# Tell Airtime the file id associated with a show instance.
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
# URL to tell Airtime to update file's meta data
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
# URL to tell Airtime we want a listing of all files it knows about
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%'
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
# URL to tell Airtime we want to add watched directory
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime about file system mount change
update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
reload_metadata_group = 'reload-metadata-group/format/json/api_key/%%api_key%%'
# URL to tell Airtime about file system mount change
handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%'
#############################
## Config for Recorder
#############################
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#############################
## Config for Pypo
#############################
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# URL to tell Airtime we want to get stream setting
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
#URL to update liquidsoap status
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to check live stream auth
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
#URL to update source status
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%'
get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%'
get_files_without_replay_gain = 'get-files-without-replay-gain/api_key/%%api_key%%/dir_id/%%dir_id%%'
update_replay_gain_value = 'update-replay-gain-value/api_key/%%api_key%%'
notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json'
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'

View File

@ -1,31 +0,0 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.
# MM2 only:
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'

View File

@ -1,85 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
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 #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/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'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# pypo preferences #
############################################
# 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.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
############################################
# Recorded Audio settings #
############################################
record_bitrate = 256
record_samplerate = 44100
record_channels = 2
record_sample_size = 16
#can be either ogg|mp3, mp3 recording requires installation of the package "lame"
record_file_type = 'ogg'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'

View File

@ -1,24 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,8 +0,0 @@
<?php
require_once 'DbUpgrade.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,9 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.2.1');
ALTER TABLE cc_block
DROP CONSTRAINT cc_block_createdby_fkey;
ALTER TABLE cc_block
ADD CONSTRAINT cc_block_createdby_fkey FOREIGN KEY (creator_id) REFERENCES cc_subjs(id) ON DELETE CASCADE;

View File

@ -1,16 +0,0 @@
<?php
/* This class deals with any modifications to config files in /etc/airtime
* as well as backups. All functions other than start() should be marked
* as private. */
class AirtimeConfigFileUpgrade{
public static function start(){
echo "* Updating configFiles".PHP_EOL;
self::task0();
}
private static function task0(){
UpgradeCommon::upgradeConfigFiles();
}
}

View File

@ -1,25 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/schema.sql $database 2>&1 | grep -v \"will create implicit index\"");
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,11 +0,0 @@
<?php
require_once 'DbUpgrade.php';
require_once 'ConfFileUpgrade.php';
require_once 'common/UpgradeCommon.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeConfigFileUpgrade::start();
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,322 +0,0 @@
<?php
/* These are helper functions that are common to each upgrade such as
* creating connections to a database, backing up config files etc.
*/
class UpgradeCommon{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
const CONF_BACKUP_SUFFIX = "230";
const VERSION_NUMBER = "2.3.0";
public static function SetDefaultTimezone()
{
$sql = "SELECT valstr from cc_pref WHERE keystr = 'timezone'";
$result = self::queryDb($sql);
$timezone = $result->fetchColumn();
date_default_timezone_set($timezone);
}
public static function connectToDatabase($p_exitOnError = true)
{
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database exists with corresponding permissions.".PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
private static function GetAirtimeSrcDir()
{
return __DIR__."/../../../../airtime_mvc";
}
public static function MigrateTablesToVersion($dir, $version)
{
echo "Upgrading database, may take several minutes, please wait".PHP_EOL;
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
}
public static function BypassMigrations($dir, $version)
{
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function upgradeConfigFiles(){
$configFiles = array(UpgradeCommon::CONF_FILE_AIRTIME,
UpgradeCommon::CONF_FILE_PYPO,
//this is not necessary because liquidsoap configs
//are automatically generated
//UpgradeCommon::CONF_FILE_LIQUIDSOAP,
UpgradeCommon::CONF_FILE_MEDIAMONITOR,
UpgradeCommon::CONF_FILE_API_CLIENT);
// Backup the config files
$suffix = date("Ymdhis")."-".UpgradeCommon::VERSION_NUMBER;
foreach ($configFiles as $conf) {
// do not back up monit cfg -- ok?? not being done anyway
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
//copy($conf, $conf.$suffix.".bak");
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
}
}
self::CreateIniFiles(UpgradeCommon::CONF_BACKUP_SUFFIX);
self::MergeConfigFiles($configFiles, $suffix);
//HACK: This will fix a last minute bug we discovered with our upgrade scripts.
//Will be fixed properly in 2.3.0
$old = "list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%'";
$new = "list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%/all/%%all%%'";
exec("sed -i \"s#$old#$new#g\" /etc/airtime/api_client.cfg");
$old = "update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'";
$new = "update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/'";
exec("sed -i \"s#$old#$new#g\" /etc/airtime/api_client.cfg");
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles($suffix)
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
$config_copy = array(
"../etc/airtime.conf" => self::CONF_FILE_AIRTIME,
"../etc/pypo.cfg" => self::CONF_FILE_PYPO,
"../etc/media-monitor.cfg" => self::CONF_FILE_MEDIAMONITOR,
"../etc/api_client.cfg" => self::CONF_FILE_API_CLIENT
);
echo "Copying configs:\n";
foreach ($config_copy as $path_part => $destination) {
$full_path = OsPath::normpath(OsPath::join(__DIR__,
"$path_part.$suffix"));
echo "'$full_path' --> '$destination'\n";
if(!copy($full_path, $destination)) {
echo "Failed on the copying operation above\n";
exit(1);
}
}
}
private static function MergeConfigFiles(array $configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === self::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = self::ReadPythonConfig($conf);
$oldSettings = self::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
if(isset($oldSettings[$section][$sectionKey])) {
self::UpdateIniValue($conf, $sectionKey,
$oldSettings[$section][$sectionKey]);
}
}
} else {
self::UpdateIniValue($conf, $section,
$oldSettings[$section]);
}
}
}
}
}
}
private static function ReadPythonConfig($p_filename)
{
$values = array();
$fh = fopen($p_filename, 'r');
while(!feof($fh)){
$line = fgets($fh);
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
continue;
}else{
$info = explode('=', $line, 2);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
private static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n = count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
public static function queryDb($p_sql){
$con = Propel::getConnection();
try {
$result = $con->query($p_sql);
} catch (Exception $e) {
echo "Error executing $p_sql. Exiting.";
exit(1);
}
return $result;
}
}
class OsPath {
// this function is from http://stackoverflow.com/questions/2670299/is-there-a-php-equivalent-function-to-the-python-os-path-normpath
public static function normpath($path)
{
if (empty($path))
return '.';
if (strpos($path, '/') === 0)
$initial_slashes = true;
else
$initial_slashes = false;
if (
($initial_slashes) &&
(strpos($path, '//') === 0) &&
(strpos($path, '///') === false)
)
$initial_slashes = 2;
$initial_slashes = (int) $initial_slashes;
$comps = explode('/', $path);
$new_comps = array();
foreach ($comps as $comp)
{
if (in_array($comp, array('', '.')))
continue;
if (
($comp != '..') ||
(!$initial_slashes && !$new_comps) ||
($new_comps && (end($new_comps) == '..'))
)
array_push($new_comps, $comp);
elseif ($new_comps)
array_pop($new_comps);
}
$comps = $new_comps;
$path = implode('/', $comps);
if ($initial_slashes)
$path = str_repeat('/', $initial_slashes) . $path;
if ($path)
return $path;
else
return '.';
}
/* Similar to the os.path.join python method
* http://stackoverflow.com/a/1782990/276949 */
public static function join() {
$args = func_get_args();
$paths = array();
foreach($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
foreach($paths as &$path) {
$path = trim($path, DIRECTORY_SEPARATOR);
}
if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) {
$paths[0] = DIRECTORY_SEPARATOR . $paths[0];
}
return join(DIRECTORY_SEPARATOR, $paths);
}
}

View File

@ -1,93 +0,0 @@
CREATE SEQUENCE cc_listener_count_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_locale_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_mount_name_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_timestamp_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE cc_listener_count (
id integer DEFAULT nextval('cc_listener_count_id_seq'::regclass) NOT NULL,
timestamp_id integer NOT NULL,
mount_name_id integer NOT NULL,
listener_count integer NOT NULL
);
CREATE TABLE cc_locale (
id integer DEFAULT nextval('cc_locale_id_seq'::regclass) NOT NULL,
locale_code character varying(16) NOT NULL,
locale_lang character varying(128) NOT NULL
);
CREATE TABLE cc_mount_name (
id integer DEFAULT nextval('cc_mount_name_id_seq'::regclass) NOT NULL,
mount_name character varying(255) NOT NULL
);
CREATE TABLE cc_timestamp (
id integer DEFAULT nextval('cc_timestamp_id_seq'::regclass) NOT NULL,
"timestamp" timestamp without time zone NOT NULL
);
ALTER TABLE cc_files
ADD COLUMN cuein interval DEFAULT '00:00:00'::interval,
ADD COLUMN cueout interval DEFAULT '00:00:00'::interval,
ADD COLUMN silan_check boolean DEFAULT false,
ADD COLUMN hidden boolean DEFAULT false;
ALTER TABLE cc_schedule
ALTER COLUMN cue_in DROP DEFAULT,
ALTER COLUMN cue_in SET NOT NULL,
ALTER COLUMN cue_out DROP DEFAULT,
ALTER COLUMN cue_out SET NOT NULL;
ALTER SEQUENCE cc_listener_count_id_seq
OWNED BY cc_listener_count.id;
ALTER SEQUENCE cc_locale_id_seq
OWNED BY cc_locale.id;
ALTER SEQUENCE cc_mount_name_id_seq
OWNED BY cc_mount_name.id;
ALTER SEQUENCE cc_timestamp_id_seq
OWNED BY cc_timestamp.id;
ALTER TABLE cc_listener_count
ADD CONSTRAINT cc_listener_count_pkey PRIMARY KEY (id);
ALTER TABLE cc_locale
ADD CONSTRAINT cc_locale_pkey PRIMARY KEY (id);
ALTER TABLE cc_mount_name
ADD CONSTRAINT cc_mount_name_pkey PRIMARY KEY (id);
ALTER TABLE cc_timestamp
ADD CONSTRAINT cc_timestamp_pkey PRIMARY KEY (id);
ALTER TABLE cc_listener_count
ADD CONSTRAINT cc_mount_name_inst_fkey FOREIGN KEY (mount_name_id) REFERENCES cc_mount_name(id) ON DELETE CASCADE;
ALTER TABLE cc_listener_count
ADD CONSTRAINT cc_timestamp_inst_fkey FOREIGN KEY (timestamp_id) REFERENCES cc_timestamp(id) ON DELETE CASCADE;

View File

@ -1,47 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.3.0');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('off_air_meta', 'Airtime - offline', 'string');
INSERT INTO cc_pref("keystr", "valstr") VALUES('enable_replay_gain', 1);
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_admin_user', '', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_admin_pass', '', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_admin_user', '', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_admin_pass', '', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_admin_user', '', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_admin_pass', '', 'string');
--Make sure that cc_music_dir has a trailing '/' and cc_files does not have a leading '/'
UPDATE cc_music_dirs SET directory = directory || '/' where id in (select id from cc_music_dirs where substr(directory, length(directory)) != '/');
UPDATE cc_files SET filepath = substring(filepath from 2) where id in (select id from cc_files where substring(filepath from 1 for 1) = '/');
UPDATE cc_files SET cueout = length where cueout = '00:00:00';
UPDATE cc_schedule SET cue_out = clip_length WHERE cue_out = '00:00:00';
UPDATE cc_schedule SET fade_out = '00:00:59.9' WHERE fade_out > '00:00:59.9';
UPDATE cc_schedule SET fade_in = '00:00:59.9' WHERE fade_in > '00:00:59.9';
UPDATE cc_playlistcontents SET fadeout = '00:00:59.9' WHERE fadeout > '00:00:59.9';
UPDATE cc_playlistcontents SET fadein = '00:00:59.9' WHERE fadein > '00:00:59.9';
UPDATE cc_blockcontents SET fadeout = '00:00:59.9' WHERE fadeout > '00:00:59.9';
UPDATE cc_blockcontents SET fadein = '00:00:59.9' WHERE fadein > '00:00:59.9';
INSERT INTO cc_pref("keystr", "valstr") VALUES('locale', 'en_CA');
INSERT INTO cc_pref("subjid", "keystr", "valstr") VALUES(1, 'user_locale', 'en_CA');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_CA', 'English (Canada)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_GB', 'English (Britain)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_US', 'English (USA)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('cs_CZ', 'Český');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_DE', 'Deutsch');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_AT', 'Österreichisches Deutsch');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('es_ES', 'Español');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('fr_FR', 'Français');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('it_IT', 'Italiano');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ko_KR', '한국어');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pl_PL', 'Polski');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pt_BR', 'Português Brasileiro');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ru_RU', 'Русский');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('zh_CN', '简体中文');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('el_GR', 'Ελληνικά');

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

@ -1,128 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
#############################
## Common
#############################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
#URL to register a components IP Address with the central web server
register_component = 'register-component/format/json/api_key/%%api_key%%/component/%%component%%'
# Hostname
host = 'localhost'
base_port = 80
base_dir = '/'
#############################
## Config for Media Monitor
#############################
# URL to setup the media monitor
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
# Tell Airtime the file id associated with a show instance.
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
# URL to tell Airtime to update file's meta data
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
# URL to tell Airtime we want a listing of all files it knows about
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%/all/%%all%%'
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
# URL to tell Airtime we want to add watched directory
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime about file system mount change
update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
reload_metadata_group = 'reload-metadata-group/format/json/api_key/%%api_key%%'
# URL to tell Airtime about file system mount change
handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%'
#############################
## Config for Recorder
#############################
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#############################
## Config for Pypo
#############################
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/'
# URL to tell Airtime we want to get stream setting
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
#URL to update liquidsoap status
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to check live stream auth
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
#URL to update source status
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%'
get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%'
get_files_without_replay_gain = 'get-files-without-replay-gain/api_key/%%api_key%%/dir_id/%%dir_id%%'
update_replay_gain_value = 'update-replay-gain-value/api_key/%%api_key%%'
notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json'
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'
get_stream_parameters = 'get-stream-parameters/api_key/%%api_key%%/format/json'
push_stream_stats = 'push-stream-stats/api_key/%%api_key%%/format/json'
update_stream_setting_table = 'update-stream-setting-table/api_key/%%api_key%%/format/json'

View File

@ -1,31 +0,0 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.
# MM2 only:
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'

View File

@ -1,85 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
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 #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/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'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# pypo preferences #
############################################
# 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.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
############################################
# Recorded Audio settings #
############################################
record_bitrate = 256
record_samplerate = 44100
record_channels = 2
record_sample_size = 16
#can be either ogg|mp3, mp3 recording requires installation of the package "lame"
record_file_type = 'ogg'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'

View File

@ -1,25 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade {
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
//passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/schema.sql $database 2>&1 | grep -v \"will create implicit index\"");
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,15 +0,0 @@
<?php
require_once 'DbUpgrade.php';
require_once 'common/UpgradeCommon.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
//CC-5001: remove /etc/monit/conf.d/monit-airtime-rabbitmq-server.cfg on 2.3.1 upgrade
$file = "/etc/monit/conf.d/monit-airtime-rabbitmq-server.cfg";
if (file_exists($file)) {
unlink($file);
}
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,312 +0,0 @@
<?php
/* These are helper functions that are common to each upgrade such as
* creating connections to a database, backing up config files etc.
*/
class UpgradeCommon{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
const CONF_BACKUP_SUFFIX = "231";
const VERSION_NUMBER = "2.3.1";
public static function SetDefaultTimezone()
{
$sql = "SELECT valstr from cc_pref WHERE keystr = 'timezone'";
$result = self::queryDb($sql);
$timezone = $result->fetchColumn();
date_default_timezone_set($timezone);
}
public static function connectToDatabase($p_exitOnError = true)
{
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database exists with corresponding permissions.".PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
private static function GetAirtimeSrcDir()
{
return __DIR__."/../../../../airtime_mvc";
}
public static function MigrateTablesToVersion($dir, $version)
{
echo "Upgrading database, may take several minutes, please wait".PHP_EOL;
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
}
public static function BypassMigrations($dir, $version)
{
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/common/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function upgradeConfigFiles(){
$configFiles = array(UpgradeCommon::CONF_FILE_AIRTIME,
UpgradeCommon::CONF_FILE_PYPO,
//this is not necessary because liquidsoap configs
//are automatically generated
//UpgradeCommon::CONF_FILE_LIQUIDSOAP,
UpgradeCommon::CONF_FILE_MEDIAMONITOR,
UpgradeCommon::CONF_FILE_API_CLIENT);
// Backup the config files
$suffix = date("Ymdhis")."-".UpgradeCommon::VERSION_NUMBER;
foreach ($configFiles as $conf) {
// do not back up monit cfg -- ok?? not being done anyway
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
//copy($conf, $conf.$suffix.".bak");
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
}
}
self::CreateIniFiles(UpgradeCommon::CONF_BACKUP_SUFFIX);
self::MergeConfigFiles($configFiles, $suffix);
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles($suffix)
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
$config_copy = array(
"../etc/airtime.conf" => self::CONF_FILE_AIRTIME,
"../etc/pypo.cfg" => self::CONF_FILE_PYPO,
"../etc/media-monitor.cfg" => self::CONF_FILE_MEDIAMONITOR,
"../etc/api_client.cfg" => self::CONF_FILE_API_CLIENT
);
echo "Copying configs:\n";
foreach ($config_copy as $path_part => $destination) {
$full_path = OsPath::normpath(OsPath::join(__DIR__,
"$path_part.$suffix"));
echo "'$full_path' --> '$destination'\n";
if(!copy($full_path, $destination)) {
echo "Failed on the copying operation above\n";
exit(1);
}
}
}
private static function MergeConfigFiles(array $configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === self::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = self::ReadPythonConfig($conf);
$oldSettings = self::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
if(isset($oldSettings[$section][$sectionKey])) {
self::UpdateIniValue($conf, $sectionKey,
$oldSettings[$section][$sectionKey]);
}
}
} else {
self::UpdateIniValue($conf, $section,
$oldSettings[$section]);
}
}
}
}
}
}
private static function ReadPythonConfig($p_filename)
{
$values = array();
$fh = fopen($p_filename, 'r');
while(!feof($fh)){
$line = fgets($fh);
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
continue;
}else{
$info = explode('=', $line, 2);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
private static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n = count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
public static function queryDb($p_sql){
$con = Propel::getConnection();
try {
$result = $con->query($p_sql);
} catch (Exception $e) {
echo "Error executing $p_sql. Exiting.";
exit(1);
}
return $result;
}
}
class OsPath {
// this function is from http://stackoverflow.com/questions/2670299/is-there-a-php-equivalent-function-to-the-python-os-path-normpath
public static function normpath($path)
{
if (empty($path))
return '.';
if (strpos($path, '/') === 0)
$initial_slashes = true;
else
$initial_slashes = false;
if (
($initial_slashes) &&
(strpos($path, '//') === 0) &&
(strpos($path, '///') === false)
)
$initial_slashes = 2;
$initial_slashes = (int) $initial_slashes;
$comps = explode('/', $path);
$new_comps = array();
foreach ($comps as $comp)
{
if (in_array($comp, array('', '.')))
continue;
if (
($comp != '..') ||
(!$initial_slashes && !$new_comps) ||
($new_comps && (end($new_comps) == '..'))
)
array_push($new_comps, $comp);
elseif ($new_comps)
array_pop($new_comps);
}
$comps = $new_comps;
$path = implode('/', $comps);
if ($initial_slashes)
$path = str_repeat('/', $initial_slashes) . $path;
if ($path)
return $path;
else
return '.';
}
/* Similar to the os.path.join python method
* http://stackoverflow.com/a/1782990/276949 */
public static function join() {
$args = func_get_args();
$paths = array();
foreach($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
foreach($paths as &$path) {
$path = trim($path, DIRECTORY_SEPARATOR);
}
if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) {
$paths[0] = DIRECTORY_SEPARATOR . $paths[0];
}
return join(DIRECTORY_SEPARATOR, $paths);
}
}

View File

@ -1,2 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.3.1');

View File

@ -1,28 +0,0 @@
<?php
/* This class deals with any modifications to config files in /etc/airtime
* as well as backups. All functions other than start() should be marked
* as private. */
class AirtimeConfigFileUpgrade{
public static function start(){
echo "* Updating configFiles".PHP_EOL;
self::UpdateIniFiles();
}
/**
* After the configuration files have been copied to /etc/airtime,
* this function will update them to values unique to this
* particular installation.
*/
private static function UpdateIniFiles()
{
$ini = parse_ini_file(UpgradeCommon::CONF_FILE_AIRTIME, true);
$ini['rabbitmq']['vhost'] = '/airtime';
$ini['rabbitmq']['user'] = 'airtime';
$ini['rabbitmq']['password'] = UpgradeCommon::GenerateRandomString();
UpgradeCommon::write_ini_file($ini, UpgradeCommon::CONF_FILE_AIRTIME, true);
}
}

View File

@ -1,25 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/schema.sql $database 2>&1 | grep -v \"will create implicit index\"");
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,11 +0,0 @@
<?php
require_once 'DbUpgrade.php';
require_once 'ConfFileUpgrade.php';
require_once 'common/UpgradeCommon.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeConfigFileUpgrade::start();
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,98 +0,0 @@
<?php
/* These are helper functions that are common to each upgrade such as
* creating connections to a database, backing up config files etc.
*/
class UpgradeCommon{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
const CONF_BACKUP_SUFFIX = "240";
const VERSION_NUMBER = "2.4.0";
private static function GetAirtimeSrcDir()
{
return __DIR__."/../../../../airtime_mvc";
}
/**
* This function generates a random string.
*
* The random string uses two parameters: $p_len and $p_chars. These
* parameters do not need to be provided, in which case defaults are
* used.
*
* @param string $p_len
* How long should the generated string be.
* @param string $p_chars
* String containing chars that should be used for generating.
* @return string
* The generated random string.
*/
public static function GenerateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
{
$string = '';
for ($i = 0; $i < $p_len; $i++)
{
$pos = mt_rand(0, strlen($p_chars)-1);
$string .= $p_chars{$pos};
}
return $string;
}
//stupid hack found on http://stackoverflow.com/a/1268642/276949
//with some modifications: 1) Spaces are inserted in between sections and
//2) values are not quoted.
public static function write_ini_file($assoc_arr, $path, $has_sections = false)
{
$content = "";
if ($has_sections) {
$first_line = true;
foreach ($assoc_arr as $key=>$elem) {
if ($first_line) {
$content .= "[".$key."]\n";
$first_line = false;
} else {
$content .= "\n[".$key."]\n";
}
foreach ($elem as $key2=>$elem2) {
if(is_array($elem2))
{
for($i=0;$i<count($elem2);$i++)
{
$content .= $key2."[] = \"".$elem2[$i]."\"\n";
}
}
else if($elem2=="") $content .= $key2." = \n";
else $content .= $key2." = ".$elem2."\n";
}
}
} else {
foreach ($assoc_arr as $key=>$elem) {
if(is_array($elem))
{
for($i=0;$i<count($elem);$i++)
{
$content .= $key."[] = \"".$elem[$i]."\"\n";
}
}
else if($elem=="") $content .= $key." = \n";
else $content .= $key." = ".$elem."\n";
}
}
if (!$handle = fopen($path, 'w')) {
return false;
}
if (!fwrite($handle, $content)) {
return false;
}
fclose($handle);
return true;
}
}

View File

@ -1,17 +0,0 @@
ALTER TABLE cc_blockcontents
ADD COLUMN trackoffset double precision DEFAULT 0 NOT NULL;
ALTER TABLE cc_files
ADD COLUMN is_scheduled boolean DEFAULT false,
ADD COLUMN is_playlist boolean DEFAULT false;
ALTER TABLE cc_playlistcontents
ADD COLUMN trackoffset double precision DEFAULT 0 NOT NULL;
ALTER TABLE cc_schedule
ADD COLUMN "position" integer DEFAULT 0 NOT NULL;
ALTER TABLE cc_show
ADD COLUMN linked boolean DEFAULT false NOT NULL,
ADD COLUMN is_linkable boolean DEFAULT true NOT NULL;

View File

@ -1,32 +0,0 @@
DELETE FROM cc_pref WHERE id IN (
SELECT cc_pref.id
FROM cc_pref
LEFT OUTER JOIN (
SELECT MAX(id) as id, keystr, subjid
FROM cc_pref
GROUP BY keystr, subjid
) as KeepRows ON
cc_pref.id = KeepRows.id
WHERE
KeepRows.id IS NULL
);
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.4.0');
DELETE FROM cc_pref WHERE keystr = 'stream_type';
INSERT INTO cc_pref (keystr, valstr) VALUES ('stream_type', 'ogg, mp3, opus, aac');
UPDATE cc_files
SET is_scheduled = true
WHERE id IN (SELECT DISTINCT(file_id) FROM cc_schedule WHERE playout_status != -1);
UPDATE cc_files
SET is_playlist = true
WHERE id IN (SELECT DISTINCT(file_id) FROM cc_playlistcontents);
UPDATE cc_files
SET is_playlist = true
WHERE id IN (SELECT DISTINCT(file_id) FROM cc_blockcontents);
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hu_HU', 'Magyar');

View File

@ -1,12 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# Hostname
host = 'localhost'
base_port = 80
base_dir = '/'

View File

@ -1,24 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,8 +0,0 @@
<?php
require_once 'DbUpgrade.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,3 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.4.1');

View File

@ -1,25 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/schema.sql $database 2>&1 | grep -v \"will create implicit index\"");
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,8 +0,0 @@
<?php
require_once 'DbUpgrade.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,83 +0,0 @@
CREATE SEQUENCE cc_playout_history_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_playout_history_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_playout_history_template_field_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE SEQUENCE cc_playout_history_template_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE cc_playout_history (
id integer DEFAULT nextval('cc_playout_history_id_seq'::regclass) NOT NULL,
file_id integer,
starts timestamp without time zone NOT NULL,
ends timestamp without time zone,
instance_id integer
);
CREATE TABLE cc_playout_history_metadata (
id integer DEFAULT nextval('cc_playout_history_metadata_id_seq'::regclass) NOT NULL,
history_id integer NOT NULL,
"key" character varying(128) NOT NULL,
"value" character varying(128) NOT NULL
);
CREATE TABLE cc_playout_history_template (
id integer DEFAULT nextval('cc_playout_history_template_id_seq'::regclass) NOT NULL,
name character varying(128) NOT NULL,
type character varying(35) NOT NULL
);
CREATE TABLE cc_playout_history_template_field (
id integer DEFAULT nextval('cc_playout_history_template_field_id_seq'::regclass) NOT NULL,
template_id integer NOT NULL,
name character varying(128) NOT NULL,
label character varying(128) NOT NULL,
type character varying(128) NOT NULL,
is_file_md boolean DEFAULT false NOT NULL,
"position" integer NOT NULL
);
ALTER TABLE cc_playout_history
ADD CONSTRAINT cc_playout_history_pkey PRIMARY KEY (id);
ALTER TABLE cc_playout_history_metadata
ADD CONSTRAINT cc_playout_history_metadata_pkey PRIMARY KEY (id);
ALTER TABLE cc_playout_history_template
ADD CONSTRAINT cc_playout_history_template_pkey PRIMARY KEY (id);
ALTER TABLE cc_playout_history_template_field
ADD CONSTRAINT cc_playout_history_template_field_pkey PRIMARY KEY (id);
ALTER TABLE cc_playout_history
ADD CONSTRAINT cc_his_item_inst_fkey FOREIGN KEY (instance_id) REFERENCES cc_show_instances(id) ON DELETE SET NULL;
ALTER TABLE cc_playout_history
ADD CONSTRAINT cc_playout_history_file_tag_fkey FOREIGN KEY (file_id) REFERENCES cc_files(id) ON DELETE CASCADE;
ALTER TABLE cc_playout_history_metadata
ADD CONSTRAINT cc_playout_history_metadata_entry_fkey FOREIGN KEY (history_id) REFERENCES cc_playout_history(id) ON DELETE CASCADE;
ALTER TABLE cc_playout_history_template_field
ADD CONSTRAINT cc_playout_history_template_template_fkey FOREIGN KEY (template_id) REFERENCES cc_playout_history_template(id) ON DELETE CASCADE;

View File

@ -1,69 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.0');
INSERT INTO cc_playout_history (file_id, starts, ends, instance_id)
SELECT file_id, starts, ends, instance_id
FROM cc_schedule
WHERE file_id IS NOT NULL AND media_item_played = true;
CREATE VIEW ws_history AS
SELECT
wm.start_time as starts,
ws.name as creator,
wm.liquidsoap_data as title,
sched.instance_id as instance_id,
show.name as showname
FROM cc_webstream_metadata AS wm
LEFT JOIN cc_schedule AS sched
ON sched.id = wm.instance_id
LEFT JOIN cc_webstream AS ws
ON sched.stream_id = ws.id
LEFT JOIN cc_show_instances as showinstances
ON sched.instance_id = showinstances.id
LEFT JOIN cc_show AS show
ON showinstances.show_id = show.id;
CREATE OR REPLACE FUNCTION migrateWebstreamHistory() RETURNS int4 AS $$
DECLARE r RECORD;
DECLARE hisid integer;
BEGIN
FOR r IN SELECT * from ws_history LOOP
insert into cc_playout_history (starts, instance_id)
values (r.starts, r.instance_id)
returning id into hisid;
insert into cc_playout_history_metadata (history_id, key, value)
values (hisid, 'track_title', substring(r.title from 1 for 128));
insert into cc_playout_history_metadata (history_id, key, value)
values (hisid, 'artist_name', substring(r.creator from 1 for 128));
insert into cc_playout_history_metadata (history_id, key, value)
values (hisid, 'showname', substring(r.showname from 1 for 128));
END LOOP;
return 1;
END;
$$
LANGUAGE plpgsql;
SELECT migrateWebstreamHistory() as output;
DROP FUNCTION migrateWebstreamHistory();
DROP VIEW ws_history;
DELETE from cc_show_instances AS ins
WHERE (ins.starts,ins.ends,ins.show_id)
IN (SELECT starts,ends,show_id FROM cc_show_instances GROUP BY starts,ends,show_id HAVING count(*) >1 )
AND ins.id NOT IN (SELECT min(id) FROM cc_show_instances GROUP BY starts,ends,show_id HAVING count(*) >1 );
DELETE FROM cc_schedule
WHERE id
IN (SELECT sc.id FROM cc_schedule AS sc LEFT JOIN cc_show_instances AS i ON sc.instance_id=i.id LEFT JOIN cc_show AS s ON i.show_id=s.id WHERE sc.starts<i.starts ORDER BY sc.starts);

View File

@ -1,24 +0,0 @@
<?php
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start($p_dbValues){
echo "* Updating Database".PHP_EOL;
self::task0($p_dbValues);
echo " * Complete".PHP_EOL;
}
private static function task0($p_dbValues){
$username = $p_dbValues['database']['dbuser'];
$password = $p_dbValues['database']['dbpass'];
$host = $p_dbValues['database']['host'];
$database = $p_dbValues['database']['dbname'];
$dir = __DIR__;
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
}
}

View File

@ -1,8 +0,0 @@
<?php
require_once 'DbUpgrade.php';
$filename = "/etc/airtime/airtime.conf";
$values = parse_ini_file($filename, true);
AirtimeDatabaseUpgrade::start($values);

View File

@ -1,2 +0,0 @@
DELETE FROM cc_pref WHERE keystr = 'system_version';
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.1');

View File

@ -1,8 +0,0 @@
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hr_HR', 'Hrvatski');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS', 'Српски (Ћирилица)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski (Latinica)');
UPDATE cc_locale SET locale_lang='Deutsch (Österreich)' WHERE locale_code='de_AT';
UPDATE cc_locale SET locale_lang='Português Brasileiro' WHERE locale_code='pt_BR';
-- NOTE BECAUSE OF CACHING NOW ANY UPGRADES TO cc_pref MUST NOT BE DONE HERE.

View File

@ -1,235 +0,0 @@
<?php
/*
* These are helper functions that are common to each upgrade such as
* creating connections to a database, backing up config files etc.
*/
class UpgradeCommon {
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_PYPO_GRP = "pypo";
const CONF_WWW_DATA_GRP = "www-data";
const CONF_BACKUP_SUFFIX = "200";
const VERSION_NUMBER = "2.0.0";
/**
* Check if the connection to the database is working.
* Return true if it is working, false if not.
*
* @param boolean $p_exitOnError
* $return boolean
*/
public static function connectToDatabase($p_exitOnError = true)
{
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database exists with corresponding permissions.".PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
private static function GetAirtimeSrcDir()
{
return __DIR__."/../../../airtime_mvc";
}
public static function MigrateTablesToVersion($dir, $version)
{
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
}
public static function BypassMigrations($dir, $version)
{
$appDir = self::GetAirtimeSrcDir();
$command = "php --php-ini $dir/../../airtime-php.ini ".
"$appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function upgradeConfigFiles(){
$configFiles = array(UpgradeCommon::CONF_FILE_AIRTIME,
UpgradeCommon::CONF_FILE_PYPO,
UpgradeCommon::CONF_FILE_RECORDER,
UpgradeCommon::CONF_FILE_LIQUIDSOAP,
UpgradeCommon::CONF_FILE_MEDIAMONITOR,
UpgradeCommon::CONF_FILE_API_CLIENT);
// Backup the config files
$suffix = date("Ymdhis")."-".UpgradeCommon::VERSION_NUMBER;
foreach ($configFiles as $conf) {
// do not back up monit cfg
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
//copy($conf, $conf.$suffix.".bak");
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
}
}
self::CreateIniFiles(UpgradeCommon::CONF_BACKUP_SUFFIX);
self::MergeConfigFiles($configFiles, $suffix);
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles($suffix)
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
if (!copy(__DIR__."/airtime.conf.$suffix", self::CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", self::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", self::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/api_client.cfg.$suffix", self::CONF_FILE_API_CLIENT)){
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
exit(1);
}
}
private static function MergeConfigFiles($configFiles, $suffix) {
foreach ($configFiles as $conf) {
// we want to use new liquidsoap.cfg so don't merge
// also for monit
if( $conf == self::CONF_FILE_LIQUIDSOAP){
continue;
}
if (file_exists("$conf$suffix.bak")) {
if($conf === self::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = self::ReadPythonConfig($conf);
$oldSettings = self::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
// skip airtim_dir as we want to use new value
if($sectionKey != "airtime_dir"){
if(isset($oldSettings[$section][$sectionKey])) {
self::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
}
else {
self::UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
private static function ReadPythonConfig($p_filename)
{
$values = array();
$fh = fopen($p_filename, 'r');
while(!feof($fh)){
$line = fgets($fh);
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
continue;
}else{
$info = explode('=', $line, 2);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
private static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
}

View File

@ -1,82 +0,0 @@
<?php
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
/*
* In the future, most Airtime upgrades will involve just mutating the
* data that is stored on the system. For example, The only data
* we need to preserve between versions is the database, /etc/airtime, and
* /srv/airtime. Everything else is just binary files that can be removed/replaced
* with the new version of Airtime. Of course, the data may need to be in a new
* format, and that's what this upgrade script will be for.
*/
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
set_include_path(__DIR__.'/../../../airtime_mvc/application/models' . PATH_SEPARATOR . get_include_path());
set_include_path(__DIR__.'/../../../airtime_mvc/application/configs' . PATH_SEPARATOR . get_include_path());
require_once 'conf.php';
require_once 'propel/runtime/lib/Propel.php';
Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php");
require_once 'UpgradeCommon.php';
$bypassMigrations=array('20110312121200', '20110331111708', '20110402164819', '20110406182005', '20110629143017', '20110711161043', '20110713161043');
$targetMigration='20110925171256';
/* All functions other than start() should be marked as
* private.
*/
class AirtimeDatabaseUpgrade{
public static function start(){
//self::doDbMigration();
}
private static function doDbMigration(){
global $bypassMigrations, $targetMigration;
if(UpgradeCommon::DbTableExists('doctrine_migration_versions') === false) {
foreach($bypassMigrations as $migration) {
UpgradeCommon::BypassMigrations(__DIR__, $migration);
}
}
UpgradeCommon::MigrateTablesToVersion(__DIR__, $targetMigration);
}
}
class AirtimeStorWatchedDirsUpgrade{
public static function start(){
}
}
/* This class deals with any modifications to config files in /etc/airtime
* as well as backups. All functions other than start() should be marked
* as private. */
class AirtimeConfigFileUpgrade{
public static function start(){
UpgradeCommon::upgradeConfigFiles();
}
}
/* Into this class put operations that don't fit into any of the other
* 3 classes. For example, there may be stray files scattered throughout
* the filesystem that we don't need anymore. Put the functions to clean
* those out into this class. */
class AirtimeMiscUpgrade{
public static function start(){
}
}
UpgradeCommon::connectToDatabase();
AirtimeDatabaseUpgrade::start();
AirtimeStorWatchedDirsUpgrade::start();
AirtimeConfigFileUpgrade::start();
AirtimeMiscUpgrade::start();

View File

@ -8,7 +8,7 @@ if [[ $EUID -ne 0 ]]; then
fi
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
AIRTIMEROOT="$( cd "${SCRIPT_DIR}/.." && pwd )"
AIRTIMEROOT="$( cd "$( dirname ${SCRIPT_DIR} )" && pwd )"
showhelp () {
echo "Usage: sudo bash install [options]
@ -329,11 +329,11 @@ chmod 755 /run/airtime
chown -R ${web_user}:${web_user} /run/airtime
verbose "...Done"
verbose "\n * Cpoying logging files..."
verbose "\n * Copying logging files..."
cp -R ${AIRTIMEROOT}/python_apps/std_err_override /usr/lib/airtime/std_err_override
verbose "...Done"
verbose "\n * Cpoying API client files..."
verbose "\n * Copying API client files..."
cp -R ${AIRTIMEROOT}/python_apps/api_clients /usr/lib/airtime/api_clients
verbose "...Done"
@ -351,7 +351,7 @@ echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-media-monitor, \
verbose "\n * Copying pypo files..."
mkdir -p /usr/lib/airtime/pypo
cp -R ${AIRTIMEROOT}/python_apps/pypo /usr/lib/airtime/pypo/bin/
cp -R ${AIRTIMEROOT}/python_apps/pypo/pypo /usr/lib/airtime/pypo/bin/
verbose "...Done"
verbose "\n * Creating init files..."
@ -365,7 +365,7 @@ echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-playout, \
ln -sf /usr/bin/liquidsoap /usr/bin/airtime-liquidsoap
sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/pypo/bin/airtime-liquidsoap-init-d > /etc/init.d/airtime-liquidsoap
touch /etc/sudoers.d/airtime-liquidsoap_${web_user}
echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-liquidsoap, \
echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-liquidsoap, \
/sbin/stop airtime-liquidsoap, \
/sbin/restart airtime-liquidsoap, \
/sbin/status airtime-liquidsoap" > /etc/sudoers.d/airtime-liquidsoap_${web_user}
@ -374,8 +374,6 @@ verbose "...Done"
chmod 755 /etc/init.d/airtime-*
initctl reload-configuration
# Do we need to run the init scripts for media-monitor and pypo here?
if [ ! -d /var/log/airtime ]; then
loud "\n-----------------------------------------------------"
loud " * Installing Log Files * "

View File

@ -1,12 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# Hostname
host = 'localhost'
base_port = 80
base_dir = '/'

View File

@ -1,31 +0,0 @@
import os
import shutil
import sys
from configobj import ConfigObj
def get_current_script_dir():
return os.path.dirname(os.path.realpath(__file__))
def copy_dir(src_dir, dest_dir):
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
shutil.rmtree(dest_dir)
if not (os.path.exists(dest_dir)):
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
shutil.copytree(src_dir, dest_dir)
PATH_INI_FILE = '/etc/airtime/api_client.cfg'
current_script_dir = get_current_script_dir()
if not os.path.exists(PATH_INI_FILE):
shutil.copy('%s/../api_client.cfg'%current_script_dir, PATH_INI_FILE)
"""load config file"""
try:
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
#copy python files
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])

View File

@ -1,21 +0,0 @@
import os
import sys
from configobj import ConfigObj
def remove_path(path):
os.system('rm -rf "%s"' % path)
def get_current_script_dir():
return os.path.dirname(os.path.realpath(__file__))
current_script_dir = get_current_script_dir()
"""load config file"""
try:
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
print " * Removing API Client files"
remove_path(config["bin_dir"])

View File

@ -1,32 +0,0 @@
import os
import sys
from subprocess import Popen, PIPE, STDOUT
def create_user(username):
print "* Checking for user "+username
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
if (output[0:3] != "uid"):
# Make the pypo user
print " * Creating user "+username
os.system("adduser --system --quiet --group "+username)
else:
print "User already exists."
#add pypo to audio group
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
#add pypo to www-data group
os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
#add pypo to pulse group
os.system("adduser " + username + " pulse 1>/dev/null 2>&1")
#add pypo to pulse-access group
os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
if __name__ == "__main__":
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
create_user("pypo")

View File

@ -1,70 +0,0 @@
import os
import shutil
import sys
import subprocess
import random
import string
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
def get_current_script_dir():
current_script_dir = os.path.realpath(__file__)
index = current_script_dir.rindex('/')
return current_script_dir[0:index]
def copy_dir(src_dir, dest_dir):
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
shutil.rmtree(dest_dir)
if not (os.path.exists(dest_dir)):
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
shutil.copytree(src_dir, dest_dir)
def create_dir(path):
try:
os.makedirs(path)
# TODO : fix this, at least print the error
except Exception, e:
pass
def get_rand_string(length=10):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
try:
# Absolute path this script is in
current_script_dir = get_current_script_dir()
if not os.path.exists(PATH_INI_FILE):
shutil.copy('%s/../media-monitor.cfg'%current_script_dir, PATH_INI_FILE)
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
#copy monit files
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True, close_fds=True)
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create log dir
create_dir(config['log_dir'])
#copy python files
copy_dir("%s/.."%current_script_dir, config["bin_dir"])
# mm2
mm2_source = os.path.realpath(os.path.join(current_script_dir,
"../../media-monitor2"))
copy_dir(mm2_source, os.path.join( config["bin_dir"], "mm2" ))
#copy init.d script
shutil.copy(config["bin_dir"]+"/airtime-media-monitor-init-d", "/etc/init.d/airtime-media-monitor")
except Exception, e:
print e

View File

@ -1,21 +0,0 @@
import subprocess
import os
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
try:
#create media-monitor dir under /var/tmp/airtime
if not os.path.exists("/var/tmp/airtime/media-monitor"):
os.makedirs("/var/tmp/airtime/media-monitor")
#update-rc.d init script
subprocess.call("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
#Start media-monitor daemon
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
print "* Waiting for media-monitor processes to start..."
subprocess.call("invoke-rc.d airtime-media-monitor start", shell=True)
except Exception, e:
print e

View File

@ -1,44 +0,0 @@
import os
import shutil
import sys
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
def remove_file(path):
try:
os.remove(path)
except Exception, e:
pass
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
try:
#remove init.d script
print " * Removing Media-Monitor init.d Script"
remove_file("/etc/init.d/airtime-media-monitor")
#remove bin dir
print " * Removing Media-Monitor Program Directory"
shutil.rmtree(config['bin_dir'], ignore_errors=True)
#remove log dir
print " * Removing Media-Monitor Log Directory"
shutil.rmtree(config['log_dir'], ignore_errors=True)
#remove monit files
print " * Removing Media-Monitor Monit Files"
remove_file("/etc/monit/conf.d/monit-airtime-media-monitor.cfg")
remove_file("/etc/monit/conf.d/monit-airtime-generic.cfg")
except Exception, e:
print e

View File

@ -1,19 +0,0 @@
import subprocess
import os
import sys
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
try:
print "Waiting for media-monitor processes to stop...",
if (os.path.exists('/etc/init.d/airtime-media-monitor')):
subprocess.call("invoke-rc.d airtime-media-monitor stop", shell=True)
print "OK"
else:
print "Wasn't running"
subprocess.call("update-rc.d -f airtime-media-monitor remove".split(" "))
except Exception, e:
print e

View File

@ -1,50 +0,0 @@
# -*- coding: utf-8 -*-
import os
import sys
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
def remove_path(path):
os.system('rm -rf "%s"' % path)
def get_current_script_dir():
current_script_dir = os.path.realpath(__file__)
index = current_script_dir.rindex('/')
return current_script_dir[0:index]
def remove_monit_file():
os.system("rm -f /etc/monit/conf.d/monit-airtime-media-monitor.cfg")
try:
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
os.system("invoke-rc.d airtime-media-monitor stop")
os.system("rm -f /etc/init.d/airtime-media-monitor")
os.system("update-rc.d -f airtime-media-monitor remove >/dev/null 2>&1")
print "Removing monit file"
remove_monit_file()
print "Removing log directories"
remove_path(config["log_dir"])
print "Removing symlinks"
os.system("rm -f /usr/bin/airtime-media-monitor")
print "Removing application files"
remove_path(config["bin_dir"])
print "Uninstall complete."
except Exception, e:
print "exception:" + str(e)

View File

@ -1,9 +0,0 @@
set daemon 10 # Poll at 5 second intervals
set logfile /var/log/monit.log
set httpd port 2812
check process airtime-media-monitor
with pidfile "/var/run/airtime/airtime-media-monitor.pid"
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-media-monitor stop"

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 = I6EUOJM0D1EIGSMZ9T70
web_server_user = www-data
airtime_dir = /usr/share/airtime
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

Some files were not shown because too many files have changed in this diff Show More