From 791466b02362557a6af2a05c05b2d432b9b4f9e4 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Thu, 15 Jan 2015 16:33:33 -0500 Subject: [PATCH] Fixes for code review https://github.com/sourcefabric/Airtime/pull/84 --- airtime_mvc/application/Bootstrap.php | 9 + airtime_mvc/application/configs/conf.php | 3 - .../controllers/UpgradeController.php | 34 +- airtime_mvc/application/models/Cache.php | 6 + .../application/models/Systemstatus.php | 6 +- airtime_mvc/application/upgrade/Upgrades.php | 27 ++ .../airtime-setup/forms/database-settings.php | 8 +- .../airtime-setup/forms/finish-settings.php | 4 - .../airtime-setup/forms/rabbitmq-settings.php | 10 +- airtime_mvc/build/airtime.example.conf | 424 +++++++++--------- airtime_mvc/public/setup/media-setup.php | 11 +- dev_tools/toggle-pypo-debug.sh | 4 +- install | 11 +- installer/lib/requirements-debian-wheezy.apt | 3 - installer/lib/requirements-ubuntu-saucy.apt | 3 - installer/lib/requirements-ubuntu-trusty.apt | 3 - ...nf => airtime-media-monitor.conf.template} | 0 .../media/saas/airtimeinstance.py | 2 +- python_apps/media-monitor/setup.py | 15 +- ....conf => airtime-liquidsoap.conf.template} | 0 ...out.conf => airtime-playout.conf.template} | 0 .../liquidsoap_prepare_terminate.py | 8 +- python_apps/pypo/pypo/pyponotify.py | 2 +- python_apps/pypo/pypo/recorder.py | 14 +- python_apps/pypo/setup.py | 16 +- uninstall | 28 +- 26 files changed, 347 insertions(+), 304 deletions(-) rename python_apps/media-monitor/install/{airtime-media-monitor.conf => airtime-media-monitor.conf.template} (100%) rename python_apps/pypo/install/{airtime-liquidsoap.conf => airtime-liquidsoap.conf.template} (100%) rename python_apps/pypo/install/{airtime-playout.conf => airtime-playout.conf.template} (100%) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 9acf6f7f6e..ee49b73a89 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -21,6 +21,7 @@ require_once "Auth.php"; require_once __DIR__ . '/forms/helpers/ValidationTypes.php'; require_once __DIR__ . '/controllers/plugins/RabbitMqPlugin.php'; +require_once __DIR__ . '/upgrade/Upgrades.php'; require_once (APPLICATION_PATH . "logging/Logging.php"); Logging::setLogPath('/var/log/airtime/zendphp.log'); @@ -76,6 +77,14 @@ private function _initTranslationGlobals($view) { $view->headScript()->appendScript("var USER_MANUAL_URL = '" . USER_MANUAL_URL . "';"); $view->headScript()->appendScript("var COMPANY_NAME = '" . COMPANY_NAME . "';"); } + + protected function _initUpgrade() { + Logging::info("Checking if upgrade is needed..."); + if (AIRTIME_CODE_VERSION > Application_Model_Preference::GetAirtimeVersion()) { + $upgradeManager = new UpgradeManager(); + $upgradeManager->runUpgrades(array(new AirtimeUpgrader252()), (__DIR__ . "/controllers")); + } + } protected function _initHeadLink() { diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 132605179d..58515e236d 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -38,9 +38,6 @@ public static function loadConfig() { $CC_CONFIG['cache_ahead_hours'] = $values['general']['cache_ahead_hours']; - $CC_CONFIG['monit_user'] = $values['monit']['monit_user']; - $CC_CONFIG['monit_password'] = $values['monit']['monit_password']; - // Database config $CC_CONFIG['dsn']['username'] = $values['database']['dbuser']; $CC_CONFIG['dsn']['password'] = $values['database']['dbpass']; diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index 2691f270fc..7ff511dee0 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -20,35 +20,25 @@ public function indexAction() array_push($upgraders, new AirtimeUpgrader254()); */ $didWePerformAnUpgrade = false; - try - { - for ($i = 0; $i < count($upgraders); $i++) - { - $upgrader = $upgraders[$i]; - if ($upgrader->checkIfUpgradeSupported()) - { - // pass __DIR__ to the upgrades, since __DIR__ returns parent dir of file, not executor - $upgrader->upgrade(__DIR__); //This will throw an exception if the upgrade fails. - $didWePerformAnUpgrade = true; - $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK
"); - $i = 0; //Start over, in case the upgrade handlers are not in ascending order. - } - } + try { + $upgradeManager = new UpgradeManager(); + $didWePerformAnUpgrade = $upgradeManager->runUpgrades($upgraders, __DIR__); - if (!$didWePerformAnUpgrade) - { + if (!$didWePerformAnUpgrade) { + $this->getResponse() + ->setHttpResponseCode(200) + ->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".
"); + } else { $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".
"); + ->setHttpResponseCode(200) + ->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK
"); } } catch (Exception $e) { $this->getResponse() - ->setHttpResponseCode(400) - ->appendBody($e->getMessage()); + ->setHttpResponseCode(400) + ->appendBody($e->getMessage()); } } diff --git a/airtime_mvc/application/models/Cache.php b/airtime_mvc/application/models/Cache.php index af4e6417bc..eccc9d4b9b 100644 --- a/airtime_mvc/application/models/Cache.php +++ b/airtime_mvc/application/models/Cache.php @@ -28,4 +28,10 @@ public function fetch($key, $isUserValue, $userId = null) { //$cacheKey = self::createCacheKey($key, $isUserValue, $userId); return false; //apc_fetch($cacheKey); } + + public static function clear() { + // Disabled on SaaS + // apc_clear_cache('user'); + // apc_clear_cache(); + } } diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php index 4a0480a048..3872526481 100644 --- a/airtime_mvc/application/models/Systemstatus.php +++ b/airtime_mvc/application/models/Systemstatus.php @@ -6,15 +6,15 @@ class Application_Model_Systemstatus public static function GetMonitStatus($p_ip) { $CC_CONFIG = Config::getConfig(); - $monit_user = $CC_CONFIG['monit_user']; - $monit_password = $CC_CONFIG['monit_password']; +// $monit_user = $CC_CONFIG['monit_user']; +// $monit_password = $CC_CONFIG['monit_password']; $url = "http://$p_ip:2812/_status?format=xml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_USERPWD, "$monit_user:$monit_password"); +// curl_setopt($ch, CURLOPT_USERPWD, "$monit_user:$monit_password"); //wait a max of 3 seconds before aborting connection attempt curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); $result = curl_exec($ch); diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index f95216bd0f..fe083d1aee 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -1,5 +1,32 @@ checkIfUpgradeSupported()) { + // pass the given directory to the upgrades, since __DIR__ returns parent dir of file, not executor + $upgrader->upgrade($dir); // This will throw an exception if the upgrade fails. + $upgradePerformed = true; + $i = 0; // Start over, in case the upgrade handlers are not in ascending order. + } + } + + return $upgradePerformed; + } + +} + abstract class AirtimeUpgrader { /** Versions that this upgrader class can upgrade from (an array of version strings). */ diff --git a/airtime_mvc/build/airtime-setup/forms/database-settings.php b/airtime_mvc/build/airtime-setup/forms/database-settings.php index 6a32dcacfe..d9df0e42e5 100644 --- a/airtime_mvc/build/airtime-setup/forms/database-settings.php +++ b/airtime_mvc/build/airtime-setup/forms/database-settings.php @@ -16,25 +16,25 @@
/> + value="" />
/> + value="" />
/> + value="" />
/> + value="" />
diff --git a/airtime_mvc/build/airtime-setup/forms/finish-settings.php b/airtime_mvc/build/airtime-setup/forms/finish-settings.php index 4e7b7ff1d5..3bd33d7958 100644 --- a/airtime_mvc/build/airtime-setup/forms/finish-settings.php +++ b/airtime_mvc/build/airtime-setup/forms/finish-settings.php @@ -1,8 +1,4 @@
diff --git a/airtime_mvc/build/airtime-setup/forms/rabbitmq-settings.php b/airtime_mvc/build/airtime-setup/forms/rabbitmq-settings.php index 4f1ac17231..052956b0ff 100644 --- a/airtime_mvc/build/airtime-setup/forms/rabbitmq-settings.php +++ b/airtime_mvc/build/airtime-setup/forms/rabbitmq-settings.php @@ -25,13 +25,13 @@
/> + value="" />
/> + value="" /> You probably want to change this! @@ -40,19 +40,19 @@
/> + value="" />
/> + value="" />
/> + value="" />
diff --git a/airtime_mvc/build/airtime.example.conf b/airtime_mvc/build/airtime.example.conf index 98c5c78875..65369e0c5e 100644 --- a/airtime_mvc/build/airtime.example.conf +++ b/airtime_mvc/build/airtime.example.conf @@ -1,42 +1,42 @@ -# ---------------------------------------------------------------------- -# A I R T I M E C O N F I G U R A T I O N -# ---------------------------------------------------------------------- -# -# This is an example configuration for Airtime. If you just want to -# get started with a basic Airtime setup, or don't know if you should -# be reconfiguring any of the following values, just rename this file -# to 'airtime.conf'. -# -# ---------------------------------------------------------------------- +; ---------------------------------------------------------------------- +; A I R T I M E C O N F I G U R A T I O N +; ---------------------------------------------------------------------- +; +; This is an example configuration for Airtime. If you just want to +; get started with a basic Airtime setup, or don't know if you should +; be reconfiguring any of the following values, just rename this file +; to 'airtime.conf'. +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# G E N E R A L S E T T I N G S -# ---------------------------------------------------------------------- -# -# These settings are used for Airtime's webserver configuration, and -# for general-purpose properties. -# -# api_key: The API key for your Airtime installation. -# The value is generated the first time you use Airtime. -# -# web_server_user: The default webserver user. -# The default is www-data. -# -# base_url: The host name for your webserver. -# The default is localhost. -# -# base_port: The port for your webserver. -# The default is 80. -# -# base_dir: The root directory for your Airtime installation -# on your webserver, relative to the base_url. -# The default is /. -# -# cache_ahead_hours: How many hours ahead of time the Airtime playout -# engine (pypo) should cache scheduled media files. -# The default is 1. -# +; ---------------------------------------------------------------------- +; G E N E R A L S E T T I N G S +; ---------------------------------------------------------------------- +; +; These settings are used for Airtime's webserver configuration, and +; for general-purpose properties. +; +; api_key: The API key for your Airtime installation. +; The value is generated the first time you use Airtime. +; +; web_server_user: The default webserver user. +; The default is www-data. +; +; base_url: The host name for your webserver. +; The default is localhost. +; +; base_port: The port for your webserver. +; The default is 80. +; +; base_dir: The root directory for your Airtime installation +; on your webserver, relative to the base_url. +; The default is /. +; +; cache_ahead_hours: How many hours ahead of time the Airtime playout +; engine (pypo) should cache scheduled media files. +; The default is 1. +; [general] api_key = web_server_user = www-data @@ -44,99 +44,99 @@ base_url = localhost base_port = 80 base_dir = / cache_ahead_hours = 1 -# -# ---------------------------------------------------------------------- +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# D A T A B A S E -# ---------------------------------------------------------------------- -# -# These settings are used to configure your database connection. -# -# host: The hostname of the database server. -# On a default Airtime installation, set this to localhost. -# -# dbname: The name of the Airtime database. -# The default is airtime. -# -# dbuser: The username for the Airtime database user. -# The default is airtime. -# -# dbpass: The password for the Airtime database user. -# The default is airtime. -# +; ---------------------------------------------------------------------- +; D A T A B A S E +; ---------------------------------------------------------------------- +; +; These settings are used to configure your database connection. +; +; host: The hostname of the database server. +; On a default Airtime installation, set this to localhost. +; +; dbname: The name of the Airtime database. +; The default is airtime. +; +; dbuser: The username for the Airtime database user. +; The default is airtime. +; +; dbpass: The password for the Airtime database user. +; The default is airtime. +; [database] host = localhost dbname = airtime dbuser = airtime dbpass = airtime -# -# ---------------------------------------------------------------------- +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# R A B B I T M Q -# ---------------------------------------------------------------------- -# -# These settings are used to configure the RabbitMQ messaging -# configuration for your Airtime installation. -# -# host: The IP address for the RabbitMQ service. -# The default is 127.0.0.1. -# -# port: The port for the RabbitMQ service. -# The default is 5672. -# -# user: The username for the RabbitMQ user. -# The default is airtime. -# -# password: The password for the RabbitMQ user. -# The default is airtime. -# -# vhost: The virtual host for the RabbitMQ service database. -# The default is /airtime. -# +; ---------------------------------------------------------------------- +; R A B B I T M Q +; ---------------------------------------------------------------------- +; +; These settings are used to configure the RabbitMQ messaging +; configuration for your Airtime installation. +; +; host: The IP address for the RabbitMQ service. +; The default is 127.0.0.1. +; +; port: The port for the RabbitMQ service. +; The default is 5672. +; +; user: The username for the RabbitMQ user. +; The default is airtime. +; +; password: The password for the RabbitMQ user. +; The default is airtime. +; +; vhost: The virtual host for the RabbitMQ service database. +; The default is /airtime. +; [rabbitmq] host = 127.0.0.1 port = 5672 user = airtime password = airtime vhost = /airtime -# -# ---------------------------------------------------------------------- +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# M E D I A M O N I T O R -# ---------------------------------------------------------------------- -# -# check_filesystem_events: How long to queue up events performed on the -# files themselves, in seconds -# The default is 5 -# -# check_airtime_events: How long to queue metadata input from airtime, -# in seconds -# The default is 30 -# -# touch_interval: -# The default is 5 -# -# chunking_number: -# The default is 450 -# -# request_max_wait: The maximum request wait time, in seconds -# The default is 3.0 -# -# rmq_event_wait: The RabbitMQ event wait time, in seconds -# The default is 0.1 -# -# logpath: The media monitor log file path -# The default is '/var/log/airtime/media-monitor/media-monitor.log' -# -# index_path: The media monitor index path -# The default is '/var/tmp/airtime/media-monitor/last_index' -# +; ---------------------------------------------------------------------- +; M E D I A M O N I T O R +; ---------------------------------------------------------------------- +; +; check_filesystem_events: How long to queue up events performed on the +; files themselves, in seconds +; The default is 5 +; +; check_airtime_events: How long to queue metadata input from airtime, +; in seconds +; The default is 30 +; +; touch_interval: +; The default is 5 +; +; chunking_number: +; The default is 450 +; +; request_max_wait: The maximum request wait time, in seconds +; The default is 3.0 +; +; rmq_event_wait: The RabbitMQ event wait time, in seconds +; The default is 0.1 +; +; logpath: The media monitor log file path +; The default is '/var/log/airtime/media-monitor/media-monitor.log' +; +; index_path: The media monitor index path +; The default is '/var/tmp/airtime/media-monitor/last_index' +; [media-monitor] check_filesystem_events = 5 check_airtime_events = 30 @@ -146,129 +146,129 @@ request_max_wait = 3.0 rmq_event_wait = 0.1 logpath = '/var/log/airtime/media-monitor/media-monitor.log' index_path = '/var/tmp/airtime/media-monitor/last_index' -# -# ---------------------------------------------------------------------- +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# P Y P O -# ---------------------------------------------------------------------- -# -# api_client: Set the type of client you are using. -# Currently supported types: -# 1) 'obp' = Open Broadcast Platform -# 2) 'airtime' -# The default is 'airtime' -# -# cache_dir: The directory for pypo cache files -# The default is '/var/tmp/airtime/pypo/cache/' -# -# file_dir: The directory for pypo media files -# The default is '/var/tmp/airtime/pypo/files/' -# -# tmp_dir: The directory for pypo temp files -# The default is '/var/tmp/airtime/pypo/tmp/' -# -# cache_base_dir: The pypo base cache directory -# The default is '/var/tmp/airtime/pypo/' -# -# log_base_dir: The base directory for Airtime log files -# The default is '/var/log/airtime' -# -# pypo_log_dir: The directory for pypo log files -# The default is '/var/log/airtime/pypo' -# -# liquidsoap_log_dir: The directory for liquidsoap log files -# The default is '/var/log/airtime/pypo-liquidsoap' -# -# ls_host: Liquidsoap connection host -# The default is '127.0.0.1' -# -# ls_port: Liquidsoap connection port -# The default is '1234' -# -# poll_interval: Poll interval in seconds -# -# This will rarely need to be changed because any schedule -# changes are automatically sent to pypo immediately -# This is how often the poll script downloads new schedules -# and files from the server in the event that no changes -# are made to the schedule -# The default is 3600 -# -# push_interval: Push interval in seconds -# -# This is how often the push script checks whether it has -# something new to push to liquidsoap -# The default is 1 -# -# cue_style: Can be set to 'pre' or 'otf' -# 'pre' cues while playlist preparation -# 'otf' (on the fly) cues while loading into ls -# (needs the post_processor patch) -# The default is 'pre' -# -# record_bitrate: The bitrate for recordings -# The default is 256 -# -# record_samplerate: The samplerate for recordings -# The default is 44100 -# -# record_channels: The number of channels for recordings -# The default is 2 -# -# record_sample_size: The sample size for recordings -# The default is 16 -# -# record_file_type: Can be either ogg|mp3, mp3 recording requires -# installation of the package "lame" -# The default is ogg -# -# base_recorded_files: Base path to store recordered shows at -# The default is '/var/tmp/airtime/show-recorder/' -# +; ---------------------------------------------------------------------- +; P Y P O +; ---------------------------------------------------------------------- +; +; api_client: Set the type of client you are using. +; Currently supported types: +; 1) 'obp' = Open Broadcast Platform +; 2) 'airtime' +; The default is 'airtime' +; +; cache_dir: The directory for pypo cache files +; The default is '/var/tmp/airtime/pypo/cache/' +; +; file_dir: The directory for pypo media files +; The default is '/var/tmp/airtime/pypo/files/' +; +; tmp_dir: The directory for pypo temp files +; The default is '/var/tmp/airtime/pypo/tmp/' +; +; cache_base_dir: The pypo base cache directory +; The default is '/var/tmp/airtime/pypo/' +; +; log_base_dir: The base directory for Airtime log files +; The default is '/var/log/airtime' +; +; pypo_log_dir: The directory for pypo log files +; The default is '/var/log/airtime/pypo' +; +; liquidsoap_log_dir: The directory for liquidsoap log files +; The default is '/var/log/airtime/pypo-liquidsoap' +; +; ls_host: Liquidsoap connection host +; The default is '127.0.0.1' +; +; ls_port: Liquidsoap connection port +; The default is '1234' +; +; poll_interval: Poll interval in seconds +; +; This will rarely need to be changed because any schedule +; changes are automatically sent to pypo immediately +; This is how often the poll script downloads new schedules +; and files from the server in the event that no changes +; are made to the schedule +; The default is 3600 +; +; push_interval: Push interval in seconds +; +; This is how often the push script checks whether it has +; something new to push to liquidsoap +; The default is 1 +; +; cue_style: Can be set to 'pre' or 'otf' +; 'pre' cues while playlist preparation +; 'otf' (on the fly) cues while loading into ls +; (needs the post_processor patch) +; The default is 'pre' +; +; record_bitrate: The bitrate for recordings +; The default is 256 +; +; record_samplerate: The samplerate for recordings +; The default is 44100 +; +; record_channels: The number of channels for recordings +; The default is 2 +; +; record_sample_size: The sample size for recordings +; The default is 16 +; +; record_file_type: Can be either ogg|mp3, mp3 recording requires +; installation of the package "lame" +; The default is ogg +; +; base_recorded_files: Base path to store recordered shows at +; The default is '/var/tmp/airtime/show-recorder/' +; [pypo] api_client = 'airtime' -# ---------- Cache directories - !! Include trailing slash !! ---------- +; ---------- Cache directories - !! Include trailing slash !! ---------- cache_dir = '/var/tmp/airtime/pypo/cache/' file_dir = '/var/tmp/airtime/pypo/files/' tmp_dir = '/var/tmp/airtime/pypo/tmp/' -# ------- Setup directories - !! Don't include trailing slash !! ------- +; ------- Setup directories - !! Don't include trailing slash !! ------- cache_base_dir = '/var/tmp/airtime/pypo' log_base_dir = '/var/log/airtime' pypo_log_dir = '/var/log/airtime/pypo' liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap' -# ------------------------ Liquidsoap Settings ------------------------- +; ------------------------ Liquidsoap Settings ------------------------- ls_host = '127.0.0.1' ls_port = '1234' -# -------------------------- Pypo Preferences -------------------------- +; -------------------------- Pypo Preferences -------------------------- poll_interval = 3600 push_interval = 1 cue_style = 'pre' -# ---------------------- Recorded Audio Settings ----------------------- +; ---------------------- Recorded Audio Settings ----------------------- record_bitrate = 256 record_samplerate = 44100 record_channels = 2 record_sample_size = 16 record_file_type = 'ogg' base_recorded_files = '/var/tmp/airtime/show-recorder/' -# -# ---------------------------------------------------------------------- +; +; ---------------------------------------------------------------------- -# ---------------------------------------------------------------------- -# S O U N D C L O U D -# ---------------------------------------------------------------------- -# -# connection_retries: The number of times to retry the connection to -# Soundcloud. -# The default is 3. -# -# time_between_retries: The time between connection retries, in seconds. -# The default is 60. -# +; ---------------------------------------------------------------------- +; S O U N D C L O U D +; ---------------------------------------------------------------------- +; +; connection_retries: The number of times to retry the connection to +; Soundcloud. +; The default is 3. +; +; time_between_retries: The time between connection retries, in seconds. +; The default is 60. +; [soundcloud] connection_retries = 3 time_between_retries = 60 -# -# ---------------------------------------------------------------------- \ No newline at end of file +; +; ---------------------------------------------------------------------- \ No newline at end of file diff --git a/airtime_mvc/public/setup/media-setup.php b/airtime_mvc/public/setup/media-setup.php index 7d5eb2dae9..40c0f63127 100644 --- a/airtime_mvc/public/setup/media-setup.php +++ b/airtime_mvc/public/setup/media-setup.php @@ -15,7 +15,7 @@ require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcMusicDirsPeer.php"); /** - * User: sourcefabric + * Author: sourcefabric * Date: 08/12/14 * * Class MediaSetup @@ -65,6 +65,15 @@ function runSetup() { $message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!"; $errors[] = "ERR"; } + + /* + * If we're upgrading from an old Airtime instance (pre-2.5.2) we rename their old + * airtime.conf to airtime.conf.tmp during the setup process. Now that we're done, + * we can rename it to airtime.conf.bak to avoid confusion. + */ + if (file_exists(self::AIRTIME_CONF_PATH . ".tmp")) { + rename(self::AIRTIME_CONF_PATH . ".tmp", self::AIRTIME_CONF_PATH . ".bak"); + } } else { $message = "Failed to move airtime.conf; /etc/airtime doesn't exist!"; $errors[] = "ERR"; diff --git a/dev_tools/toggle-pypo-debug.sh b/dev_tools/toggle-pypo-debug.sh index d8f6a3e968..6468066a18 100755 --- a/dev_tools/toggle-pypo-debug.sh +++ b/dev_tools/toggle-pypo-debug.sh @@ -18,7 +18,7 @@ if [ "$1" = "--enable" ]; then echo "Changing ownership to user $1" chmod -R a+rw /var/log/airtime/pypo - chmod a+r /etc/airtime/pypo.cfg + chmod a+r /etc/airtime/airtime.conf chown -Rv $user:$user /var/tmp/airtime/pypo/ chmod -v a+r /etc/airtime/api_client.cfg elif [ "$1" = "--disable" ]; then @@ -26,7 +26,7 @@ elif [ "$1" = "--disable" ]; then user="pypo" echo "Changing ownership to user $1" - chmod 644 /etc/airtime/pypo.cfg + chmod 644 /etc/airtime/airtime.conf chown -Rv $user:$user /var/tmp/airtime/pypo/ chmod -v a+r /etc/airtime/api_client.cfg diff --git a/install b/install index 3cddb90d9f..27df41902e 100755 --- a/install +++ b/install @@ -406,6 +406,7 @@ verbose "...Done" for i in /etc/init/airtime*; do chmod 644 $i sed -i "s/WEB_USER/${web_user}/g" $i + mv $i ${i%.template} done initctl reload-configuration @@ -414,18 +415,8 @@ if [ ! -d /var/log/airtime ]; then loud "\n-----------------------------------------------------" loud " * Installing Log Files * " loud "-----------------------------------------------------" - - verbose "\n * Creating /var/log/airtime..." - mkdir -p /var/log/airtime - mkdir -p /var/log/airtime/media-monitor - mkdir -p /var/log/airtime/pypo - mkdir -p /var/log/airtime/pypo-liquidsoap verbose "\n * Creating /var/tmp/airtime..." - mkdir -p /var/tmp/airtime/media-monitor - mkdir -p /var/tmp/airtime/pypo/cache/ - mkdir -p /var/tmp/airtime/pypo/files/ - mkdir -p /var/tmp/airtime/pypo/tmp/ mkdir -p /var/tmp/airtime/show-recorder/ verbose "\n * Copying logrotate files..." diff --git a/installer/lib/requirements-debian-wheezy.apt b/installer/lib/requirements-debian-wheezy.apt index 30df184f19..c2afc1f5d5 100644 --- a/installer/lib/requirements-debian-wheezy.apt +++ b/installer/lib/requirements-debian-wheezy.apt @@ -11,7 +11,6 @@ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound -libesd0 libportaudio2 libsamplerate0 libvo-aacenc0 @@ -34,11 +33,9 @@ pwgen libfaad2 php-apc -libmp3lame-dev lame coreutils -sourcefabric-keyring silan libopus0 \ No newline at end of file diff --git a/installer/lib/requirements-ubuntu-saucy.apt b/installer/lib/requirements-ubuntu-saucy.apt index 2bec0a3c00..9c681d7a3e 100644 --- a/installer/lib/requirements-ubuntu-saucy.apt +++ b/installer/lib/requirements-ubuntu-saucy.apt @@ -11,7 +11,6 @@ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound -libesd0 libportaudio2 libsamplerate0 @@ -33,7 +32,6 @@ pwgen libfaad2 php-apc -libmp3lame-dev lame libzend-framework-php @@ -56,6 +54,5 @@ liquidsoap-plugin-taglib liquidsoap-plugin-voaacenc liquidsoap-plugin-vorbis -sourcefabric-keyring silan libopus0 \ No newline at end of file diff --git a/installer/lib/requirements-ubuntu-trusty.apt b/installer/lib/requirements-ubuntu-trusty.apt index f5be8df10d..656d4e99d9 100755 --- a/installer/lib/requirements-ubuntu-trusty.apt +++ b/installer/lib/requirements-ubuntu-trusty.apt @@ -11,7 +11,6 @@ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound -libesd0 libportaudio2 libsamplerate0 @@ -33,7 +32,6 @@ pwgen libfaad2 php-apc -libmp3lame-dev lame libzend-framework-php @@ -54,6 +52,5 @@ liquidsoap-plugin-taglib liquidsoap-plugin-voaacenc liquidsoap-plugin-vorbis -sourcefabric-keyring silan libopus0 \ No newline at end of file diff --git a/python_apps/media-monitor/install/airtime-media-monitor.conf b/python_apps/media-monitor/install/airtime-media-monitor.conf.template similarity index 100% rename from python_apps/media-monitor/install/airtime-media-monitor.conf rename to python_apps/media-monitor/install/airtime-media-monitor.conf.template diff --git a/python_apps/media-monitor/media-monitor2/media/saas/airtimeinstance.py b/python_apps/media-monitor/media-monitor2/media/saas/airtimeinstance.py index b2fdf2f602..b661eb1524 100644 --- a/python_apps/media-monitor/media-monitor2/media/saas/airtimeinstance.py +++ b/python_apps/media-monitor/media-monitor2/media/saas/airtimeinstance.py @@ -21,7 +21,7 @@ class AirtimeInstance(object): def root_make(cls, name, root): cfg = { 'api_client' : join(root, 'etc/airtime/api_client.cfg'), - 'media_monitor' : join(root, 'etc/airtime/media-monitor.cfg'), + 'media_monitor' : join(root, 'etc/airtime/airtime.conf'), } return cls(name, root, cfg) diff --git a/python_apps/media-monitor/setup.py b/python_apps/media-monitor/setup.py index c35c361314..a39b1958a5 100644 --- a/python_apps/media-monitor/setup.py +++ b/python_apps/media-monitor/setup.py @@ -12,7 +12,20 @@ data_files = [] sys.argv.remove('--no-init-script') # super hax else: - data_files = [('/etc/init', ['install/airtime-media-monitor.conf'])] + media_monitor_files = [] + mm2_files = [] + for root, dirnames, filenames in os.walk('media-monitor'): + for filename in filenames: + media_monitor_files.append(os.path.join(root, filename)) + for root, dirnames, filenames in os.walk('media-monitor2'): + for filename in filenames: + mm2_files.append(os.path.join(root, filename)) + + data_files = [ + ('/etc/init', ['install/airtime-media-monitor.conf.template']), + ('/var/log/airtime/media-monitor', []), + ('/var/tmp/airtime/media-monitor', []), + ] print data_files setup(name='airtime-media-monitor', diff --git a/python_apps/pypo/install/airtime-liquidsoap.conf b/python_apps/pypo/install/airtime-liquidsoap.conf.template similarity index 100% rename from python_apps/pypo/install/airtime-liquidsoap.conf rename to python_apps/pypo/install/airtime-liquidsoap.conf.template diff --git a/python_apps/pypo/install/airtime-playout.conf b/python_apps/pypo/install/airtime-playout.conf.template similarity index 100% rename from python_apps/pypo/install/airtime-playout.conf rename to python_apps/pypo/install/airtime-playout.conf.template diff --git a/python_apps/pypo/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py b/python_apps/pypo/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py index 4a2ddc08a3..230b7c9358 100644 --- a/python_apps/pypo/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py +++ b/python_apps/pypo/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py @@ -3,9 +3,9 @@ import sys try: - config = ConfigObj('/etc/airtime/pypo.cfg') - LS_HOST = config['ls_host'] - LS_PORT = config['ls_port'] + config = ConfigObj('/etc/airtime/airtime.conf') + LS_HOST = config['pypo']['ls_host'] + LS_PORT = config['pypo']['ls_port'] tn = telnetlib.Telnet(LS_HOST, LS_PORT) tn.write("master_harbor.stop\n") @@ -14,6 +14,6 @@ tn.read_all() except Exception, e: - print 'Error loading config file: %s' % e + print('Error loading config file: %s', e) sys.exit() diff --git a/python_apps/pypo/pypo/pyponotify.py b/python_apps/pypo/pypo/pyponotify.py index 797d1ce9b3..32d56270d8 100644 --- a/python_apps/pypo/pypo/pyponotify.py +++ b/python_apps/pypo/pypo/pyponotify.py @@ -59,7 +59,7 @@ # loading config file try: - config = ConfigObj('/etc/airtime/pypo.cfg') + config = ConfigObj('/etc/airtime/airtime.conf') except Exception, e: logger.error('Error loading config file: %s', e) diff --git a/python_apps/pypo/pypo/recorder.py b/python_apps/pypo/pypo/recorder.py index 003e76176f..82797a3668 100644 --- a/python_apps/pypo/pypo/recorder.py +++ b/python_apps/pypo/pypo/recorder.py @@ -34,7 +34,7 @@ def api_client(logger): # loading config file try: - config = ConfigObj('/etc/airtime/pypo.cfg') + config = ConfigObj('/etc/airtime/airtime.conf') except Exception, e: print ('Error loading config file: %s', e) sys.exit() @@ -73,18 +73,18 @@ def record_show(self): filename = self.start_time filename = filename.replace(" ", "-") - if config["record_file_type"] in ["mp3", "ogg"]: - filetype = config["record_file_type"] + if config["pypo"]["record_file_type"] in ["mp3", "ogg"]: + filetype = config["pypo"]["record_file_type"] else: filetype = "ogg"; joined_path = os.path.join(config["base_recorded_files"], filename) filepath = "%s.%s" % (joined_path, filetype) - br = config["record_bitrate"] - sr = config["record_samplerate"] - c = config["record_channels"] - ss = config["record_sample_size"] + br = config["pypo"]["record_bitrate"] + sr = config["pypo"]["record_samplerate"] + c = config["pypo"]["record_channels"] + ss = config["pypo"]["record_sample_size"] #-f:16,2,44100 #-b:256 diff --git a/python_apps/pypo/setup.py b/python_apps/pypo/setup.py index 955e75ccef..fd57676b5d 100644 --- a/python_apps/pypo/setup.py +++ b/python_apps/pypo/setup.py @@ -12,7 +12,21 @@ data_files = [] sys.argv.remove('--no-init-script') # super hax else: - data_files = [('/etc/init', ['install/airtime-playout.conf', 'install/airtime-liquidsoap.conf'])] + pypo_files = [] + for root, dirnames, filenames in os.walk('pypo'): + for filename in filenames: + pypo_files.append(os.path.join(root, filename)) + + data_files = [ + ('/etc/init', ['install/airtime-playout.conf.template']), + ('/etc/init', ['install/airtime-liquidsoap.conf.template']), + ('/var/log/airtime/pypo', []), + ('/var/log/airtime/pypo/liquidsoap', []), + ('/var/tmp/airtime/pypo', []), + ('/var/tmp/airtime/pypo/cache', []), + ('/var/tmp/airtime/pypo/files', []), + ('/var/tmp/airtime/pypo/tmp', []), + ] print data_files setup(name='airtime-playout', diff --git a/uninstall b/uninstall index 12cd87dab7..de957b8159 100755 --- a/uninstall +++ b/uninstall @@ -52,14 +52,16 @@ FILES=( "/etc/init/airtime*" "/usr/bin/airtime*" "/etc/apache2/sites-available/airtime*" - "pip airtime-playout" - "pip airtime-media-monitor" + "/etc/apache2/sites-enabled/airtime*" ) echo -e "The following files, directories, and services will be removed:\n" for i in ${FILES[*]}; do echo $i done +echo "pip airtime-playout" +echo "pip airtime-media-monitor" + echo -e "\nIf your web root is not listed, you will need to manually remove it." echo -e "\nThis will *permanently* remove Airtime and all related files from your computer. \ @@ -84,19 +86,17 @@ if [ -f /etc/airtime/airtime.conf ]; then removeRabbitmqAirtimeSettings fi -rm -rf /etc/airtime -rm -rf /var/log/airtime/ -rm -rf /usr/lib/airtime/ - -rm -rf /usr/share/airtime - -rm -f /etc/init/airtime* -rm -f /usr/bin/airtime* - -rm -f /etc/apache2/sites-enabled/airtime* -rm -f /etc/apache2/sites-available/airtime* +for i in ${FILES[*]}; do + rm -rf $i +done -dropAirtimeDatabase +echo -e "\Do you want to drop your current Airtime database? (Y/n): \c" +read IN +if [[ "$IN" = "y" || "$IN" = "Y" ]]; then + echo -e "\nDropping Airtime database..." + dropAirtimeDatabase +fi pip uninstall -y airtime-playout airtime-media-monitor +service apache2 restart echo "...Done" \ No newline at end of file