From 4c797cf10053ed89183249a7881026f24d07121f Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Tue, 23 Jun 2015 19:02:55 -0400 Subject: [PATCH] Update installer to work with saas branch --- .../application/configs/config-check.php | 39 ++++++----- .../airtime-setup/forms/finish-settings.php | 3 +- airtime_mvc/build/airtime-setup/load.php | 6 +- airtime_mvc/public/setup/database-setup.php | 67 +++++++------------ airtime_mvc/public/setup/general-setup.php | 19 ++---- airtime_mvc/public/setup/media-setup.php | 30 +++++++-- airtime_mvc/public/setup/rabbitmq-setup.php | 55 +++++++-------- airtime_mvc/public/setup/setup-functions.php | 42 +++++++----- install | 35 ++++++---- python_apps/airtime-celery/MANIFEST.in | 1 + python_apps/airtime-celery/setup.py | 5 ++ python_apps/airtime_analyzer/setup.py | 6 ++ uninstall | 4 ++ 13 files changed, 168 insertions(+), 144 deletions(-) create mode 100644 python_apps/airtime-celery/MANIFEST.in diff --git a/airtime_mvc/application/configs/config-check.php b/airtime_mvc/application/configs/config-check.php index 9cfb9927b..5ddf73295 100644 --- a/airtime_mvc/application/configs/config-check.php +++ b/airtime_mvc/application/configs/config-check.php @@ -7,17 +7,17 @@ * along with steps to fix them if they're not found or misconfigured. */ -$phpDependencies = checkPhpDependencies(); -$externalServices = checkExternalServices(); -$zend = $phpDependencies["zend"]; -$postgres = $phpDependencies["postgres"]; +$phpDependencies = checkPhpDependencies(); +$externalServices = checkExternalServices(); +$zend = $phpDependencies["zend"]; +$postgres = $phpDependencies["postgres"]; -$database = $externalServices["database"]; -$rabbitmq = $externalServices["rabbitmq"]; +$database = $externalServices["database"]; +$rabbitmq = $externalServices["rabbitmq"]; -$pypo = $externalServices["pypo"]; -$liquidsoap = $externalServices["liquidsoap"]; -$mediamonitor = $externalServices["media-monitor"]; +$pypo = $externalServices["pypo"]; +$liquidsoap = $externalServices["liquidsoap"]; +$analyzer = $externalServices["analyzer"]; $r1 = array_reduce($phpDependencies, "booleanReduce", true); $r2 = array_reduce($externalServices, "booleanReduce", true); @@ -174,28 +174,27 @@ $result = $r1 && $r2; Make sure RabbitMQ is installed correctly, and that your settings in /etc/airtime/airtime.conf are correct. Try using sudo rabbitmqctl list_users and sudo rabbitmqctl list_vhosts to see if the airtime user (or your custom RabbitMQ user) exists, then checking that - sudo rabbitmqctl list_exchanges contains entries for airtime-media-monitor, airtime-pypo, - and airtime-uploads. + sudo rabbitmqctl list_exchanges contains entries for airtime-pypo and airtime-uploads. - + - Media Monitor + Airtime Analyzer - Airtime media-monitor service + Airtime Upload and File Analysis service - + "> - Check that the airtime-media-monitor service is installed correctly in /etc/init, + Check that the airtime_analyzer service is installed correctly in /etc/init.d, and ensure that it's running with -
initctl list | grep airtime-media-monitor
- If not, try running sudo service airtime-media-monitor start +
initctl list | grep airtime_analyzer
+ If not, try running sudo service airtime_analyzer start @@ -212,7 +211,7 @@ $result = $r1 && $r2; "> - Check that the airtime-playout service is installed correctly in /etc/init, + Check that the airtime-playout service is installed correctly in /etc/init.d, and ensure that it's running with
initctl list | grep airtime-playout
If not, try running sudo service airtime-playout restart @@ -232,7 +231,7 @@ $result = $r1 && $r2; "> - Check that the airtime-liquidsoap service is installed correctly in /etc/init, + Check that the airtime-liquidsoap service is installed correctly in /etc/init.d, and ensure that it's running with
initctl list | grep airtime-liquidsoap
If not, try running sudo service airtime-liquidsoap restart diff --git a/airtime_mvc/build/airtime-setup/forms/finish-settings.php b/airtime_mvc/build/airtime-setup/forms/finish-settings.php index d6b298c34..e08afe4fc 100644 --- a/airtime_mvc/build/airtime-setup/forms/finish-settings.php +++ b/airtime_mvc/build/airtime-setup/forms/finish-settings.php @@ -9,7 +9,8 @@

sudo service airtime-playout start
 sudo service airtime-liquidsoap start
-sudo service airtime-media-monitor start
+sudo service airtime_analyzer start +sudo service airtime-celery start

Click "Done!" to bring up the Airtime configuration checklist; if your configuration is all green, you're ready to get started with your personal Airtime station! diff --git a/airtime_mvc/build/airtime-setup/load.php b/airtime_mvc/build/airtime-setup/load.php index 722d6aec8..107b02b35 100644 --- a/airtime_mvc/build/airtime-setup/load.php +++ b/airtime_mvc/build/airtime-setup/load.php @@ -63,7 +63,7 @@ function checkDatabaseDependencies() { function checkExternalServices() { return array( "database" => checkDatabaseConfiguration(), - "media-monitor" => checkMediaMonitorService(), + "analyzer" => checkAnalyzerService(), "pypo" => checkPlayoutService(), "liquidsoap" => checkLiquidsoapService(), "rabbitmq" => checkRMQConnection() @@ -123,8 +123,8 @@ function checkRMQConnection() { * * @return boolean true if airtime-media-monitor is running */ -function checkMediaMonitorService() { - exec("pgrep -f -u www-data airtime-media-monitor", $out, $status); +function checkAnalyzerService() { + exec("pgrep -f -u www-data airtime_analyzer", $out, $status); if (array_key_exists(0, $out) && $status == 0) { return posix_kill(rtrim($out[0]), 0); } diff --git a/airtime_mvc/public/setup/database-setup.php b/airtime_mvc/public/setup/database-setup.php index 821f549cf..f09b3a7ed 100644 --- a/airtime_mvc/public/setup/database-setup.php +++ b/airtime_mvc/public/setup/database-setup.php @@ -9,7 +9,7 @@ class DatabaseSetup extends Setup { // airtime.conf section header - const SECTION = "[database]"; + protected static $_settings = "[database]"; // Constant form field names for passing errors back to the front-end const DB_USER = "dbUser", @@ -17,31 +17,26 @@ class DatabaseSetup extends Setup { DB_NAME = "dbName", DB_HOST = "dbHost"; - // Form field values - private $user, $pass, $name, $host; - // Array of key->value pairs for airtime.conf - static $properties; + protected static $_properties; + /** + * @var PDO + */ static $dbh = null; public function __construct($settings) { - $this->user = $settings[self::DB_USER]; - $this->pass = $settings[self::DB_PASS]; - $this->name = $settings[self::DB_NAME]; - $this->host = $settings[self::DB_HOST]; - - self::$properties = array( - "host" => $this->host, - "dbname" => $this->name, - "dbuser" => $this->user, - "dbpass" => $this->pass, + static::$_properties = array( + "host" => $settings[self::DB_HOST], + "dbname" => $settings[self::DB_NAME], + "dbuser" => $settings[self::DB_USER], + "dbpass" => $settings[self::DB_PASS], ); } private function setNewDatabaseConnection($dbName) { - self::$dbh = new PDO("pgsql:host=" . $this->host . ";dbname=" . $dbName . ";port=5432" - . ";user=" . $this->user . ";password=" . $this->pass); + self::$dbh = new PDO("pgsql:host=" . self::$_properties["host"] . ";dbname=" . $dbName . ";port=5432" + . ";user=" . self::$_properties["dbuser"] . ";password=" . self::$_properties["dbpass"]); $err = self::$dbh->errorInfo(); if ($err[1] != null) { throw new PDOException(); @@ -69,11 +64,7 @@ class DatabaseSetup extends Setup { throw new AirtimeDatabaseException("Couldn't establish a connection to the database! " . "Please check your credentials and try again. " . "PDO Exception: " . $e->getMessage(), - array( - self::DB_NAME, - self::DB_USER, - self::DB_PASS, - )); + array(self::DB_NAME, self::DB_USER, self::DB_PASS)); } $this->writeToTemp(); @@ -85,13 +76,9 @@ class DatabaseSetup extends Setup { ); } - protected function writeToTemp() { - parent::writeToTemp(self::SECTION, self::$properties); - } - private function installDatabaseTables() { $this->checkDatabaseEncoding(); - $this->setNewDatabaseConnection($this->name); + $this->setNewDatabaseConnection(self::$_properties["dbname"]); $this->checkSchemaExists(); $this->createDatabaseTables(); } @@ -102,7 +89,7 @@ class DatabaseSetup extends Setup { */ private function checkDatabaseExists() { $statement = self::$dbh->prepare("SELECT datname FROM pg_database WHERE datname = :dbname"); - $statement->execute(array(":dbname" => $this->name)); + $statement->execute(array(":dbname" => self::$_properties["dbname"])); $result = $statement->fetch(); return isset($result[0]); } @@ -126,16 +113,13 @@ class DatabaseSetup extends Setup { */ private function checkUserCanCreateDb() { $statement = self::$dbh->prepare("SELECT 1 FROM pg_roles WHERE rolname=:dbuser AND rolcreatedb='t'"); - $statement->execute(array(":dbuser" => $this->user)); + $statement->execute(array(":dbuser" => self::$_properties["dbuser"])); $result = $statement->fetch(); if (!isset($result[0])) { - throw new AirtimeDatabaseException("No database " . $this->name . " exists; user '" . $this->user - . "' does not have permission to create databases on " . $this->host, - array( - self::DB_NAME, - self::DB_USER, - self::DB_PASS, - )); + throw new AirtimeDatabaseException("No database " . self::$_properties["dbname"] . " exists; user '" + . self::$_properties["dbuser"] . "' does not have permission to " + . "create databases on " . self::$_properties["host"], + array(self::DB_NAME, self::DB_USER, self::DB_PASS)); } } @@ -144,9 +128,9 @@ class DatabaseSetup extends Setup { * @throws AirtimeDatabaseException */ private function createDatabase() { - $statement = self::$dbh->prepare("CREATE DATABASE " . pg_escape_string($this->name) + $statement = self::$dbh->prepare("CREATE DATABASE " . pg_escape_string(self::$_properties["dbname"]) . " WITH ENCODING 'UTF8' TEMPLATE template0" - . " OWNER " . pg_escape_string($this->user)); + . " OWNER " . pg_escape_string(self::$_properties["dbuser"])); if (!$statement->execute()) { throw new AirtimeDatabaseException("There was an error creating the database!", array(self::DB_NAME,)); @@ -169,8 +153,9 @@ class DatabaseSetup extends Setup { * have multiple issues; they similarly die on any SQL errors, fail to read in multi-line * commands, and fail on any unescaped ? or $ characters. */ - exec("export PGPASSWORD=" . $this->pass . " && psql -U " . $this->user . " --dbname " - . $this->name . " -h " . $this->host . " -f $sqlDir$f 2>/dev/null", $out, $status); + exec("export PGPASSWORD=" . self::$_properties["dbpass"] . " && psql -U " . self::$_properties["dbuser"] + . " --dbname " . self::$_properties["dbname"] . " -h " . self::$_properties["host"] + . " -f $sqlDir$f 2>/dev/null", $out, $status); } catch (Exception $e) { throw new AirtimeDatabaseException("There was an error setting up the Airtime schema!", array(self::DB_NAME,)); @@ -185,7 +170,7 @@ class DatabaseSetup extends Setup { private function checkDatabaseEncoding() { $statement = self::$dbh->prepare("SELECT pg_encoding_to_char(encoding) " . "FROM pg_database WHERE datname = :dbname"); - $statement->execute(array(":dbname" => $this->name)); + $statement->execute(array(":dbname" => self::$_properties["dbname"])); $encoding = $statement->fetch(); if (!($encoding && $encoding[0] == "UTF8")) { throw new AirtimeDatabaseException("The database was installed with an incorrect encoding type!", diff --git a/airtime_mvc/public/setup/general-setup.php b/airtime_mvc/public/setup/general-setup.php index f63a84f90..7e86bdb69 100644 --- a/airtime_mvc/public/setup/general-setup.php +++ b/airtime_mvc/public/setup/general-setup.php @@ -11,37 +11,28 @@ class GeneralSetup extends Setup { // airtime.conf section header - const SECTION = "[general]"; + protected static $_section = "[general]"; // Constant form field names for passing errors back to the front-end const GENERAL_PORT = "generalPort", GENERAL_HOST = "generalHost"; - // Form field values - static $user, $host, $port, $root; - // Array of key->value pairs for airtime.conf - static $properties; + protected static $_properties; // Message and error fields to return to the front-end static $message = null; static $errors = array(); function __construct($settings) { - self::$host = $settings[self::GENERAL_HOST]; - self::$port = $settings[self::GENERAL_PORT]; - self::$properties = array( + self::$_properties = array( "api_key" => $this->generateRandomString(), - "base_url" => self::$host, - "base_port" => self::$port, + "base_url" => $settings[self::GENERAL_HOST], + "base_port" => $settings[self::GENERAL_PORT], ); } - function writeToTemp() { - parent::writeToTemp(self::SECTION, self::$properties); - } - /** * @return array associative array containing a display message and fields with errors */ diff --git a/airtime_mvc/public/setup/media-setup.php b/airtime_mvc/public/setup/media-setup.php index d2cb99edc..701ba0749 100644 --- a/airtime_mvc/public/setup/media-setup.php +++ b/airtime_mvc/public/setup/media-setup.php @@ -26,7 +26,9 @@ class MediaSetup extends Setup { const MEDIA_FOLDER = "mediaFolder"; const AIRTIME_CONF_PATH = "/etc/airtime/airtime.conf"; - + const RMQ_INI_BASE_PATH = "/etc/airtime-saas/"; + const RMQ_INI_FILE_NAME = "rabbitmq-analyzer.ini"; + static $path; static $message = null; static $errors = array(); @@ -62,10 +64,14 @@ class MediaSetup extends Setup { // Finalize and move airtime.conf.temp if (file_exists("/etc/airtime/")) { if (!$this->moveAirtimeConfig()) { - $message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!"; - $errors[] = "ERR"; + self::$message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!"; + self::$errors[] = "ERR"; } - + if (!$this->moveRmqConfig()) { + self::$message = "Error moving rabbitmq-analyzer.ini or deleting /tmp/rabbitmq.ini.tmp!"; + self::$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, @@ -75,8 +81,8 @@ class MediaSetup extends Setup { 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"; + self::$message = "Failed to move airtime.conf; /etc/airtime doesn't exist!"; + self::$errors[] = "ERR"; } return array( @@ -84,7 +90,7 @@ class MediaSetup extends Setup { "errors" => self::$errors ); } - + /** * Moves /tmp/airtime.conf.temp to /etc/airtime.conf and then removes it to complete setup * @return boolean false if either of the copy or removal operations fail @@ -94,6 +100,16 @@ class MediaSetup extends Setup { && unlink(AIRTIME_CONF_TEMP_PATH); } + /** + * Moves /tmp/airtime.conf.temp to /etc/airtime.conf and then removes it to complete setup + * @return boolean false if either of the copy or removal operations fail + */ + function moveRmqConfig() { + return copy(RMQ_INI_TEMP_PATH, self::RMQ_INI_BASE_PATH . self::RMQ_INI_FILE_NAME) + && copy(RMQ_INI_TEMP_PATH, self::RMQ_INI_BASE_PATH . "production/" . self::RMQ_INI_FILE_NAME) + && unlink(RMQ_INI_TEMP_PATH); + } + /** * Add the given directory to cc_music_dirs * TODO Should we check for an existing entry in cc_music_dirs? diff --git a/airtime_mvc/public/setup/rabbitmq-setup.php b/airtime_mvc/public/setup/rabbitmq-setup.php index 817b51742..e8d210fec 100644 --- a/airtime_mvc/public/setup/rabbitmq-setup.php +++ b/airtime_mvc/public/setup/rabbitmq-setup.php @@ -13,7 +13,10 @@ require_once dirname(dirname( __DIR__)) . '/library/php-amqplib/amqp.inc'; class RabbitMQSetup extends Setup { // airtime.conf section header - const SECTION = "[rabbitmq]"; + protected static $_section = "[rabbitmq]"; + + // Array of key->value pairs for airtime.conf + protected static $_properties; // Constant form field names for passing errors back to the front-end const RMQ_USER = "rmqUser", @@ -22,29 +25,17 @@ class RabbitMQSetup extends Setup { RMQ_HOST = "rmqHost", RMQ_VHOST = "rmqVHost"; - // Form field values - static $user, $pass, $host, $port, $vhost; - - // Array of key->value pairs for airtime.conf - static $properties; - // Message and error fields to return to the front-end static $message = null; static $errors = array(); function __construct($settings) { - self::$user = $settings[self::RMQ_USER]; - self::$pass = $settings[self::RMQ_PASS]; - self::$port = $settings[self::RMQ_PORT]; - self::$host = $settings[self::RMQ_HOST]; - self::$vhost = $settings[self::RMQ_VHOST]; - - self::$properties = array( - "host" => self::$host, - "port" => self::$port, - "user" => self::$user, - "password" => self::$pass, - "vhost" => self::$vhost, + static::$_properties = array( + "host" => $settings[self::RMQ_HOST], + "port" => $settings[self::RMQ_PORT], + "user" => $settings[self::RMQ_USER], + "password" => $settings[self::RMQ_PASS], + "vhost" => $settings[self::RMQ_VHOST], ); } @@ -72,24 +63,20 @@ class RabbitMQSetup extends Setup { ); } - function writeToTemp() { - parent::writeToTemp(self::SECTION, self::$properties); - } - function checkRMQConnection() { - $conn = new AMQPConnection(self::$host, - self::$port, - self::$user, - self::$pass, - self::$vhost); + $conn = new AMQPConnection(self::$_properties["host"], + self::$_properties["port"], + self::$_properties["user"], + self::$_properties["password"], + self::$_properties["vhost"]); return isset($conn); } function identifyRMQConnectionError() { // It's impossible to identify errors coming out of amqp.inc without a major // rewrite, so for now just tell the user ALL THE THINGS went wrong - self::$message = "Couldn't connect to RabbitMQ server! Please check if the server " - . "is running and your credentials are correct."; + self::$message = _("Couldn't connect to RabbitMQ server! Please check if the server " + . "is running and your credentials are correct."); self::$errors[] = self::RMQ_USER; self::$errors[] = self::RMQ_PASS; self::$errors[] = self::RMQ_HOST; @@ -97,4 +84,12 @@ class RabbitMQSetup extends Setup { self::$errors[] = self::RMQ_VHOST; } + protected function writeToTemp() { + if (!file_exists(RMQ_INI_TEMP_PATH)) { + copy(BUILD_PATH . "rabbitmq-analyzer.ini", RMQ_INI_TEMP_PATH); + } + $this->_write(RMQ_INI_TEMP_PATH); + parent::writeToTemp(); + } + } \ No newline at end of file diff --git a/airtime_mvc/public/setup/setup-functions.php b/airtime_mvc/public/setup/setup-functions.php index 36d96265e..3e226b848 100644 --- a/airtime_mvc/public/setup/setup-functions.php +++ b/airtime_mvc/public/setup/setup-functions.php @@ -1,6 +1,7 @@ value pairs for airtime.conf + * + * @var array + */ + protected static $_properties; + abstract function __construct($settings); abstract function runSetup(); /** * Write new property values to a given section in airtime.conf.temp - * - * @param string $section - * the configuration section to write to - * @param array $properties - * the configuration properties and values to overwrite */ - protected function writeToTemp($section, $properties) { + protected function writeToTemp() { if (!file_exists(AIRTIME_CONF_TEMP_PATH)) { copy(BUILD_PATH . "airtime.example.conf", AIRTIME_CONF_TEMP_PATH); } - - $file = file(AIRTIME_CONF_TEMP_PATH); + + $this->_write(AIRTIME_CONF_TEMP_PATH); + } + + protected function _write($filePath) { + $file = file($filePath); $fileOutput = ""; - + $inSection = false; - + foreach ($file as $line) { - if (strpos($line, $section) !== false) { + if (strpos($line, static::$_section) !== false) { $inSection = true; } else if (strpos($line, "[") !== false) { $inSection = false; } - + if (substr(trim($line), 0, 1) == "#") { /* Workaround to strip comments from airtime.conf. * We need to do this because python's ConfigObj and PHP - * have different (and equally strict) rules about comment + * have different (and equally strict) rules about comment * characters in configuration files. */ } else if ($inSection) { $key = trim(@substr($line, 0, strpos($line, "="))); - $fileOutput .= $key && isset($properties[$key]) ? $key . " = " . $properties[$key] . "\n" : $line; + $fileOutput .= $key && isset(static::$_properties[$key]) ? + $key . " = " . static::$_properties[$key] . "\n" : $line; } else { $fileOutput .= $line; } } - - file_put_contents(AIRTIME_CONF_TEMP_PATH, $fileOutput); + + file_put_contents($filePath, $fileOutput); } /** diff --git a/install b/install index 0cae36632..999501670 100755 --- a/install +++ b/install @@ -320,9 +320,10 @@ if [ -f /etc/airtime/airtime.conf ]; then set +e verbose "Stopping airtime services..." - loudCmd "service airtime-playout stop-with-monit" - loudCmd "service airtime-media-monitor stop-with-monit" - loudCmd "service airtime-liquidsoap stop-with-monit" + loudCmd "service airtime-playout stop" + loudCmd "service airtime-media-monitor stop" + loudCmd "service airtime_analyzer stop" + loudCmd "service airtime-liquidsoap stop" verbose "...Done" echo "Looks like you have an old version of Airtime. Your current /etc/airtime/airtime.conf \ @@ -332,7 +333,7 @@ will be moved to /etc/airtime/airtime.conf.tmp" if [ -d /usr/lib/airtime/ ]; then rm -rf /usr/lib/airtime/ fi - + rm /etc/init.d/airtime-* if [ "$apache" = "t" ]; then @@ -459,12 +460,16 @@ verbose "\n * Installing API client..." loudCmd "python ${AIRTIMEROOT}/python_apps/api_clients/setup.py install --install-scripts=/usr/bin" verbose "...Done" -verbose "\n * Installing media-monitor..." -loudCmd "python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install --install-scripts=/usr/bin" +verbose "\n * Installing pypo and liquidsoap..." +loudCmd "python ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin" verbose "...Done" -verbose "\n * Installing pypo..." -loudCmd "python ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin" +verbose "\n * Installing airtime-celery..." +loudCmd "python ${AIRTIMEROOT}/python_apps/airtime-celery/setup.py install" +verbose "...Done" + +verbose "\n * Installing airtime_analyzer..." +loudCmd "python ${AIRTIMEROOT}/python_apps/airtime_analyzer/setup.py install --install-scripts=/usr/bin" verbose "...Done" #for i in /etc/init/airtime*.template; do @@ -476,9 +481,10 @@ verbose "...Done" set +e loudCmd "initctl reload-configuration" loudCmd "systemctl daemon-reload" #systemd hipsters -loudCmd "update-rc.d airtime-playout defaults" # Start at bootup, on Debian -loudCmd "update-rc.d airtime-media-monitor defaults" # Start at bootup, on Debian -loudCmd "update-rc.d airtime-liquidsoap defaults" # Start at bootup, on Debian +loudCmd "update-rc.d airtime-playout defaults" # Start at bootup, on Debian +loudCmd "update-rc.d airtime-celery defaults" # Start at bootup, on Debian +loudCmd "update-rc.d airtime-liquidsoap defaults" # Start at bootup, on Debian +loudCmd "update-rc.d airtime_analyzer defaults" # Start at bootup, on Debian set -e if [ ! -d /var/log/airtime ]; then @@ -566,7 +572,8 @@ else fi verbose "\n * Setting RabbitMQ user permissions..." -loudCmd "rabbitmqctl set_permissions -p ${RABBITMQ_VHOST} ${RABBITMQ_USER} \"$EXCHANGES\" \"$EXCHANGES\" \"$EXCHANGES\"" +#loudCmd "rabbitmqctl set_permissions -p ${RABBITMQ_VHOST} ${RABBITMQ_USER} \"$EXCHANGES\" \"$EXCHANGES\" \"$EXCHANGES\"" +loudCmd "rabbitmqctl set_permissions -p ${RABBITMQ_VHOST} ${RABBITMQ_USER} .\* .\* .\*" if [ ! -d "/etc/airtime" ]; then loud "\n-----------------------------------------------------" @@ -575,8 +582,12 @@ if [ ! -d "/etc/airtime" ]; then verbose "\n * Creating /etc/airtime/ directory..." mkdir /etc/airtime + verbose "\n * Creating /etc/airtime-saas/ directory..." + # Default saas directory for the analyzer, cloud storage, and celery + mkdir -p /etc/airtime-saas/production fi chown -R ${web_user}:${web_user} /etc/airtime +chown -R ${web_user}:${web_user} /etc/airtime-saas if [ ! -d "/srv/airtime" ]; then mkdir -p /srv/airtime diff --git a/python_apps/airtime-celery/MANIFEST.in b/python_apps/airtime-celery/MANIFEST.in new file mode 100644 index 000000000..9561fb106 --- /dev/null +++ b/python_apps/airtime-celery/MANIFEST.in @@ -0,0 +1 @@ +include README.rst diff --git a/python_apps/airtime-celery/setup.py b/python_apps/airtime-celery/setup.py index 8832ac2a8..3285aa785 100644 --- a/python_apps/airtime-celery/setup.py +++ b/python_apps/airtime-celery/setup.py @@ -3,6 +3,11 @@ from subprocess import call import os import sys +# Change directory since setuptools uses relative paths +script_path = os.path.dirname(os.path.realpath(__file__)) +print script_path +os.chdir(script_path) + install_args = ['install', 'install_data', 'develop'] run_postinst = False diff --git a/python_apps/airtime_analyzer/setup.py b/python_apps/airtime_analyzer/setup.py index 0e57ac076..47e231123 100644 --- a/python_apps/airtime_analyzer/setup.py +++ b/python_apps/airtime_analyzer/setup.py @@ -1,6 +1,12 @@ from setuptools import setup from subprocess import call import sys +import os + +# Change directory since setuptools uses relative paths +script_path = os.path.dirname(os.path.realpath(__file__)) +print script_path +os.chdir(script_path) # Allows us to avoid installing the upstart init script when deploying airtime_analyzer # on Airtime Pro: diff --git a/uninstall b/uninstall index 1f3c20fc3..b0933aac3 100755 --- a/uninstall +++ b/uninstall @@ -23,6 +23,7 @@ dropAirtimeDatabase() { su postgres <<'EOF' set +e # DROP DATABASE cannot be executed from a function or multi-command string + psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test" psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime" psql -d postgres -tAc "DROP USER IF EXISTS airtime" set -e @@ -87,7 +88,10 @@ else fi echo -e "\nUninstalling Airtime..." +service airtime-celery stop +set +e removeRabbitmqAirtimeSettings +set -e for i in ${FILES[*]}; do rm -rf $i