Update installer to work with saas branch
This commit is contained in:
parent
d48e594dcd
commit
4c797cf100
|
@ -7,17 +7,17 @@
|
||||||
* along with steps to fix them if they're not found or misconfigured.
|
* along with steps to fix them if they're not found or misconfigured.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$phpDependencies = checkPhpDependencies();
|
$phpDependencies = checkPhpDependencies();
|
||||||
$externalServices = checkExternalServices();
|
$externalServices = checkExternalServices();
|
||||||
$zend = $phpDependencies["zend"];
|
$zend = $phpDependencies["zend"];
|
||||||
$postgres = $phpDependencies["postgres"];
|
$postgres = $phpDependencies["postgres"];
|
||||||
|
|
||||||
$database = $externalServices["database"];
|
$database = $externalServices["database"];
|
||||||
$rabbitmq = $externalServices["rabbitmq"];
|
$rabbitmq = $externalServices["rabbitmq"];
|
||||||
|
|
||||||
$pypo = $externalServices["pypo"];
|
$pypo = $externalServices["pypo"];
|
||||||
$liquidsoap = $externalServices["liquidsoap"];
|
$liquidsoap = $externalServices["liquidsoap"];
|
||||||
$mediamonitor = $externalServices["media-monitor"];
|
$analyzer = $externalServices["analyzer"];
|
||||||
|
|
||||||
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
|
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
|
||||||
$r2 = array_reduce($externalServices, "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
|
Make sure RabbitMQ is installed correctly, and that your settings in /etc/airtime/airtime.conf
|
||||||
are correct. Try using <code>sudo rabbitmqctl list_users</code> and <code>sudo rabbitmqctl list_vhosts</code>
|
are correct. Try using <code>sudo rabbitmqctl list_users</code> and <code>sudo rabbitmqctl list_vhosts</code>
|
||||||
to see if the airtime user (or your custom RabbitMQ user) exists, then checking that
|
to see if the airtime user (or your custom RabbitMQ user) exists, then checking that
|
||||||
<code>sudo rabbitmqctl list_exchanges</code> contains entries for airtime-media-monitor, airtime-pypo,
|
<code>sudo rabbitmqctl list_exchanges</code> contains entries for airtime-pypo and airtime-uploads.
|
||||||
and airtime-uploads.
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="<?=$mediamonitor ? 'success' : 'danger';?>">
|
<tr class="<?=$analyzer ? 'success' : 'danger';?>">
|
||||||
<td class="component">
|
<td class="component">
|
||||||
Media Monitor
|
Airtime Analyzer
|
||||||
</td>
|
</td>
|
||||||
<td class="description">
|
<td class="description">
|
||||||
Airtime media-monitor service
|
Airtime Upload and File Analysis service
|
||||||
</td>
|
</td>
|
||||||
<td class="solution <?php if ($mediamonitor) {echo 'check';?>">
|
<td class="solution <?php if ($analyzer) {echo 'check';?>">
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>">
|
?>">
|
||||||
Check that the airtime-media-monitor service is installed correctly in <code>/etc/init</code>,
|
Check that the airtime_analyzer service is installed correctly in <code>/etc/init.d</code>,
|
||||||
and ensure that it's running with
|
and ensure that it's running with
|
||||||
<br/><code>initctl list | grep airtime-media-monitor</code><br/>
|
<br/><code>initctl list | grep airtime_analyzer</code><br/>
|
||||||
If not, try running <code>sudo service airtime-media-monitor start</code>
|
If not, try running <code>sudo service airtime_analyzer start</code>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -212,7 +211,7 @@ $result = $r1 && $r2;
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>">
|
?>">
|
||||||
Check that the airtime-playout service is installed correctly in <code>/etc/init</code>,
|
Check that the airtime-playout service is installed correctly in <code>/etc/init.d</code>,
|
||||||
and ensure that it's running with
|
and ensure that it's running with
|
||||||
<br/><code>initctl list | grep airtime-playout</code><br/>
|
<br/><code>initctl list | grep airtime-playout</code><br/>
|
||||||
If not, try running <code>sudo service airtime-playout restart</code>
|
If not, try running <code>sudo service airtime-playout restart</code>
|
||||||
|
@ -232,7 +231,7 @@ $result = $r1 && $r2;
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>">
|
?>">
|
||||||
Check that the airtime-liquidsoap service is installed correctly in <code>/etc/init</code>,
|
Check that the airtime-liquidsoap service is installed correctly in <code>/etc/init.d</code>,
|
||||||
and ensure that it's running with
|
and ensure that it's running with
|
||||||
<br/><code>initctl list | grep airtime-liquidsoap</code><br/>
|
<br/><code>initctl list | grep airtime-liquidsoap</code><br/>
|
||||||
If not, try running <code>sudo service airtime-liquidsoap restart</code>
|
If not, try running <code>sudo service airtime-liquidsoap restart</code>
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
</p>
|
</p>
|
||||||
<pre style="text-align: left">sudo service airtime-playout start
|
<pre style="text-align: left">sudo service airtime-playout start
|
||||||
sudo service airtime-liquidsoap start
|
sudo service airtime-liquidsoap start
|
||||||
sudo service airtime-media-monitor start</pre>
|
sudo service airtime_analyzer start
|
||||||
|
sudo service airtime-celery start</pre>
|
||||||
<p>
|
<p>
|
||||||
Click "Done!" to bring up the Airtime configuration checklist; if your configuration is all green,
|
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!
|
you're ready to get started with your personal Airtime station!
|
||||||
|
|
|
@ -63,7 +63,7 @@ function checkDatabaseDependencies() {
|
||||||
function checkExternalServices() {
|
function checkExternalServices() {
|
||||||
return array(
|
return array(
|
||||||
"database" => checkDatabaseConfiguration(),
|
"database" => checkDatabaseConfiguration(),
|
||||||
"media-monitor" => checkMediaMonitorService(),
|
"analyzer" => checkAnalyzerService(),
|
||||||
"pypo" => checkPlayoutService(),
|
"pypo" => checkPlayoutService(),
|
||||||
"liquidsoap" => checkLiquidsoapService(),
|
"liquidsoap" => checkLiquidsoapService(),
|
||||||
"rabbitmq" => checkRMQConnection()
|
"rabbitmq" => checkRMQConnection()
|
||||||
|
@ -123,8 +123,8 @@ function checkRMQConnection() {
|
||||||
*
|
*
|
||||||
* @return boolean true if airtime-media-monitor is running
|
* @return boolean true if airtime-media-monitor is running
|
||||||
*/
|
*/
|
||||||
function checkMediaMonitorService() {
|
function checkAnalyzerService() {
|
||||||
exec("pgrep -f -u www-data airtime-media-monitor", $out, $status);
|
exec("pgrep -f -u www-data airtime_analyzer", $out, $status);
|
||||||
if (array_key_exists(0, $out) && $status == 0) {
|
if (array_key_exists(0, $out) && $status == 0) {
|
||||||
return posix_kill(rtrim($out[0]), 0);
|
return posix_kill(rtrim($out[0]), 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class DatabaseSetup extends Setup {
|
class DatabaseSetup extends Setup {
|
||||||
|
|
||||||
// airtime.conf section header
|
// airtime.conf section header
|
||||||
const SECTION = "[database]";
|
protected static $_settings = "[database]";
|
||||||
|
|
||||||
// Constant form field names for passing errors back to the front-end
|
// Constant form field names for passing errors back to the front-end
|
||||||
const DB_USER = "dbUser",
|
const DB_USER = "dbUser",
|
||||||
|
@ -17,31 +17,26 @@ class DatabaseSetup extends Setup {
|
||||||
DB_NAME = "dbName",
|
DB_NAME = "dbName",
|
||||||
DB_HOST = "dbHost";
|
DB_HOST = "dbHost";
|
||||||
|
|
||||||
// Form field values
|
|
||||||
private $user, $pass, $name, $host;
|
|
||||||
|
|
||||||
// Array of key->value pairs for airtime.conf
|
// Array of key->value pairs for airtime.conf
|
||||||
static $properties;
|
protected static $_properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PDO
|
||||||
|
*/
|
||||||
static $dbh = null;
|
static $dbh = null;
|
||||||
|
|
||||||
public function __construct($settings) {
|
public function __construct($settings) {
|
||||||
$this->user = $settings[self::DB_USER];
|
static::$_properties = array(
|
||||||
$this->pass = $settings[self::DB_PASS];
|
"host" => $settings[self::DB_HOST],
|
||||||
$this->name = $settings[self::DB_NAME];
|
"dbname" => $settings[self::DB_NAME],
|
||||||
$this->host = $settings[self::DB_HOST];
|
"dbuser" => $settings[self::DB_USER],
|
||||||
|
"dbpass" => $settings[self::DB_PASS],
|
||||||
self::$properties = array(
|
|
||||||
"host" => $this->host,
|
|
||||||
"dbname" => $this->name,
|
|
||||||
"dbuser" => $this->user,
|
|
||||||
"dbpass" => $this->pass,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setNewDatabaseConnection($dbName) {
|
private function setNewDatabaseConnection($dbName) {
|
||||||
self::$dbh = new PDO("pgsql:host=" . $this->host . ";dbname=" . $dbName . ";port=5432"
|
self::$dbh = new PDO("pgsql:host=" . self::$_properties["host"] . ";dbname=" . $dbName . ";port=5432"
|
||||||
. ";user=" . $this->user . ";password=" . $this->pass);
|
. ";user=" . self::$_properties["dbuser"] . ";password=" . self::$_properties["dbpass"]);
|
||||||
$err = self::$dbh->errorInfo();
|
$err = self::$dbh->errorInfo();
|
||||||
if ($err[1] != null) {
|
if ($err[1] != null) {
|
||||||
throw new PDOException();
|
throw new PDOException();
|
||||||
|
@ -69,11 +64,7 @@ class DatabaseSetup extends Setup {
|
||||||
throw new AirtimeDatabaseException("Couldn't establish a connection to the database! "
|
throw new AirtimeDatabaseException("Couldn't establish a connection to the database! "
|
||||||
. "Please check your credentials and try again. "
|
. "Please check your credentials and try again. "
|
||||||
. "PDO Exception: " . $e->getMessage(),
|
. "PDO Exception: " . $e->getMessage(),
|
||||||
array(
|
array(self::DB_NAME, self::DB_USER, self::DB_PASS));
|
||||||
self::DB_NAME,
|
|
||||||
self::DB_USER,
|
|
||||||
self::DB_PASS,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->writeToTemp();
|
$this->writeToTemp();
|
||||||
|
@ -85,13 +76,9 @@ class DatabaseSetup extends Setup {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function writeToTemp() {
|
|
||||||
parent::writeToTemp(self::SECTION, self::$properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function installDatabaseTables() {
|
private function installDatabaseTables() {
|
||||||
$this->checkDatabaseEncoding();
|
$this->checkDatabaseEncoding();
|
||||||
$this->setNewDatabaseConnection($this->name);
|
$this->setNewDatabaseConnection(self::$_properties["dbname"]);
|
||||||
$this->checkSchemaExists();
|
$this->checkSchemaExists();
|
||||||
$this->createDatabaseTables();
|
$this->createDatabaseTables();
|
||||||
}
|
}
|
||||||
|
@ -102,7 +89,7 @@ class DatabaseSetup extends Setup {
|
||||||
*/
|
*/
|
||||||
private function checkDatabaseExists() {
|
private function checkDatabaseExists() {
|
||||||
$statement = self::$dbh->prepare("SELECT datname FROM pg_database WHERE datname = :dbname");
|
$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();
|
$result = $statement->fetch();
|
||||||
return isset($result[0]);
|
return isset($result[0]);
|
||||||
}
|
}
|
||||||
|
@ -126,16 +113,13 @@ class DatabaseSetup extends Setup {
|
||||||
*/
|
*/
|
||||||
private function checkUserCanCreateDb() {
|
private function checkUserCanCreateDb() {
|
||||||
$statement = self::$dbh->prepare("SELECT 1 FROM pg_roles WHERE rolname=:dbuser AND rolcreatedb='t'");
|
$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();
|
$result = $statement->fetch();
|
||||||
if (!isset($result[0])) {
|
if (!isset($result[0])) {
|
||||||
throw new AirtimeDatabaseException("No database " . $this->name . " exists; user '" . $this->user
|
throw new AirtimeDatabaseException("No database " . self::$_properties["dbname"] . " exists; user '"
|
||||||
. "' does not have permission to create databases on " . $this->host,
|
. self::$_properties["dbuser"] . "' does not have permission to "
|
||||||
array(
|
. "create databases on " . self::$_properties["host"],
|
||||||
self::DB_NAME,
|
array(self::DB_NAME, self::DB_USER, self::DB_PASS));
|
||||||
self::DB_USER,
|
|
||||||
self::DB_PASS,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +128,9 @@ class DatabaseSetup extends Setup {
|
||||||
* @throws AirtimeDatabaseException
|
* @throws AirtimeDatabaseException
|
||||||
*/
|
*/
|
||||||
private function createDatabase() {
|
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"
|
. " WITH ENCODING 'UTF8' TEMPLATE template0"
|
||||||
. " OWNER " . pg_escape_string($this->user));
|
. " OWNER " . pg_escape_string(self::$_properties["dbuser"]));
|
||||||
if (!$statement->execute()) {
|
if (!$statement->execute()) {
|
||||||
throw new AirtimeDatabaseException("There was an error creating the database!",
|
throw new AirtimeDatabaseException("There was an error creating the database!",
|
||||||
array(self::DB_NAME,));
|
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
|
* have multiple issues; they similarly die on any SQL errors, fail to read in multi-line
|
||||||
* commands, and fail on any unescaped ? or $ characters.
|
* commands, and fail on any unescaped ? or $ characters.
|
||||||
*/
|
*/
|
||||||
exec("export PGPASSWORD=" . $this->pass . " && psql -U " . $this->user . " --dbname "
|
exec("export PGPASSWORD=" . self::$_properties["dbpass"] . " && psql -U " . self::$_properties["dbuser"]
|
||||||
. $this->name . " -h " . $this->host . " -f $sqlDir$f 2>/dev/null", $out, $status);
|
. " --dbname " . self::$_properties["dbname"] . " -h " . self::$_properties["host"]
|
||||||
|
. " -f $sqlDir$f 2>/dev/null", $out, $status);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new AirtimeDatabaseException("There was an error setting up the Airtime schema!",
|
throw new AirtimeDatabaseException("There was an error setting up the Airtime schema!",
|
||||||
array(self::DB_NAME,));
|
array(self::DB_NAME,));
|
||||||
|
@ -185,7 +170,7 @@ class DatabaseSetup extends Setup {
|
||||||
private function checkDatabaseEncoding() {
|
private function checkDatabaseEncoding() {
|
||||||
$statement = self::$dbh->prepare("SELECT pg_encoding_to_char(encoding) "
|
$statement = self::$dbh->prepare("SELECT pg_encoding_to_char(encoding) "
|
||||||
. "FROM pg_database WHERE datname = :dbname");
|
. "FROM pg_database WHERE datname = :dbname");
|
||||||
$statement->execute(array(":dbname" => $this->name));
|
$statement->execute(array(":dbname" => self::$_properties["dbname"]));
|
||||||
$encoding = $statement->fetch();
|
$encoding = $statement->fetch();
|
||||||
if (!($encoding && $encoding[0] == "UTF8")) {
|
if (!($encoding && $encoding[0] == "UTF8")) {
|
||||||
throw new AirtimeDatabaseException("The database was installed with an incorrect encoding type!",
|
throw new AirtimeDatabaseException("The database was installed with an incorrect encoding type!",
|
||||||
|
|
|
@ -11,37 +11,28 @@
|
||||||
class GeneralSetup extends Setup {
|
class GeneralSetup extends Setup {
|
||||||
|
|
||||||
// airtime.conf section header
|
// airtime.conf section header
|
||||||
const SECTION = "[general]";
|
protected static $_section = "[general]";
|
||||||
|
|
||||||
// Constant form field names for passing errors back to the front-end
|
// Constant form field names for passing errors back to the front-end
|
||||||
const GENERAL_PORT = "generalPort",
|
const GENERAL_PORT = "generalPort",
|
||||||
GENERAL_HOST = "generalHost";
|
GENERAL_HOST = "generalHost";
|
||||||
|
|
||||||
// Form field values
|
|
||||||
static $user, $host, $port, $root;
|
|
||||||
|
|
||||||
// Array of key->value pairs for airtime.conf
|
// Array of key->value pairs for airtime.conf
|
||||||
static $properties;
|
protected static $_properties;
|
||||||
|
|
||||||
// Message and error fields to return to the front-end
|
// Message and error fields to return to the front-end
|
||||||
static $message = null;
|
static $message = null;
|
||||||
static $errors = array();
|
static $errors = array();
|
||||||
|
|
||||||
function __construct($settings) {
|
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(),
|
"api_key" => $this->generateRandomString(),
|
||||||
"base_url" => self::$host,
|
"base_url" => $settings[self::GENERAL_HOST],
|
||||||
"base_port" => self::$port,
|
"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
|
* @return array associative array containing a display message and fields with errors
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,7 +26,9 @@ class MediaSetup extends Setup {
|
||||||
|
|
||||||
const MEDIA_FOLDER = "mediaFolder";
|
const MEDIA_FOLDER = "mediaFolder";
|
||||||
const AIRTIME_CONF_PATH = "/etc/airtime/airtime.conf";
|
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 $path;
|
||||||
static $message = null;
|
static $message = null;
|
||||||
static $errors = array();
|
static $errors = array();
|
||||||
|
@ -62,10 +64,14 @@ class MediaSetup extends Setup {
|
||||||
// Finalize and move airtime.conf.temp
|
// Finalize and move airtime.conf.temp
|
||||||
if (file_exists("/etc/airtime/")) {
|
if (file_exists("/etc/airtime/")) {
|
||||||
if (!$this->moveAirtimeConfig()) {
|
if (!$this->moveAirtimeConfig()) {
|
||||||
$message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!";
|
self::$message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!";
|
||||||
$errors[] = "ERR";
|
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
|
* 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,
|
* 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");
|
rename(self::AIRTIME_CONF_PATH . ".tmp", self::AIRTIME_CONF_PATH . ".bak");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = "Failed to move airtime.conf; /etc/airtime doesn't exist!";
|
self::$message = "Failed to move airtime.conf; /etc/airtime doesn't exist!";
|
||||||
$errors[] = "ERR";
|
self::$errors[] = "ERR";
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -84,7 +90,7 @@ class MediaSetup extends Setup {
|
||||||
"errors" => self::$errors
|
"errors" => self::$errors
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves /tmp/airtime.conf.temp to /etc/airtime.conf and then removes it to complete setup
|
* 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
|
* @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);
|
&& 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
|
* Add the given directory to cc_music_dirs
|
||||||
* TODO Should we check for an existing entry in cc_music_dirs?
|
* TODO Should we check for an existing entry in cc_music_dirs?
|
||||||
|
|
|
@ -13,7 +13,10 @@ require_once dirname(dirname( __DIR__)) . '/library/php-amqplib/amqp.inc';
|
||||||
class RabbitMQSetup extends Setup {
|
class RabbitMQSetup extends Setup {
|
||||||
|
|
||||||
// airtime.conf section header
|
// 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
|
// Constant form field names for passing errors back to the front-end
|
||||||
const RMQ_USER = "rmqUser",
|
const RMQ_USER = "rmqUser",
|
||||||
|
@ -22,29 +25,17 @@ class RabbitMQSetup extends Setup {
|
||||||
RMQ_HOST = "rmqHost",
|
RMQ_HOST = "rmqHost",
|
||||||
RMQ_VHOST = "rmqVHost";
|
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
|
// Message and error fields to return to the front-end
|
||||||
static $message = null;
|
static $message = null;
|
||||||
static $errors = array();
|
static $errors = array();
|
||||||
|
|
||||||
function __construct($settings) {
|
function __construct($settings) {
|
||||||
self::$user = $settings[self::RMQ_USER];
|
static::$_properties = array(
|
||||||
self::$pass = $settings[self::RMQ_PASS];
|
"host" => $settings[self::RMQ_HOST],
|
||||||
self::$port = $settings[self::RMQ_PORT];
|
"port" => $settings[self::RMQ_PORT],
|
||||||
self::$host = $settings[self::RMQ_HOST];
|
"user" => $settings[self::RMQ_USER],
|
||||||
self::$vhost = $settings[self::RMQ_VHOST];
|
"password" => $settings[self::RMQ_PASS],
|
||||||
|
"vhost" => $settings[self::RMQ_VHOST],
|
||||||
self::$properties = array(
|
|
||||||
"host" => self::$host,
|
|
||||||
"port" => self::$port,
|
|
||||||
"user" => self::$user,
|
|
||||||
"password" => self::$pass,
|
|
||||||
"vhost" => self::$vhost,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,24 +63,20 @@ class RabbitMQSetup extends Setup {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeToTemp() {
|
|
||||||
parent::writeToTemp(self::SECTION, self::$properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkRMQConnection() {
|
function checkRMQConnection() {
|
||||||
$conn = new AMQPConnection(self::$host,
|
$conn = new AMQPConnection(self::$_properties["host"],
|
||||||
self::$port,
|
self::$_properties["port"],
|
||||||
self::$user,
|
self::$_properties["user"],
|
||||||
self::$pass,
|
self::$_properties["password"],
|
||||||
self::$vhost);
|
self::$_properties["vhost"]);
|
||||||
return isset($conn);
|
return isset($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function identifyRMQConnectionError() {
|
function identifyRMQConnectionError() {
|
||||||
// It's impossible to identify errors coming out of amqp.inc without a major
|
// 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
|
// 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 "
|
self::$message = _("Couldn't connect to RabbitMQ server! Please check if the server "
|
||||||
. "is running and your credentials are correct.";
|
. "is running and your credentials are correct.");
|
||||||
self::$errors[] = self::RMQ_USER;
|
self::$errors[] = self::RMQ_USER;
|
||||||
self::$errors[] = self::RMQ_PASS;
|
self::$errors[] = self::RMQ_PASS;
|
||||||
self::$errors[] = self::RMQ_HOST;
|
self::$errors[] = self::RMQ_HOST;
|
||||||
|
@ -97,4 +84,12 @@ class RabbitMQSetup extends Setup {
|
||||||
self::$errors[] = self::RMQ_VHOST;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
define("BUILD_PATH", dirname(dirname(__DIR__)) . "/build/");
|
define("BUILD_PATH", dirname(dirname(__DIR__)) . "/build/");
|
||||||
define("AIRTIME_CONF_TEMP_PATH", "/tmp/airtime.conf.temp");
|
define("AIRTIME_CONF_TEMP_PATH", "/tmp/airtime.conf.temp");
|
||||||
|
define("RMQ_INI_TEMP_PATH", "/tmp/rabbitmq.ini.tmp");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Setup
|
* Class Setup
|
||||||
|
@ -11,50 +12,59 @@ define("AIRTIME_CONF_TEMP_PATH", "/tmp/airtime.conf.temp");
|
||||||
*/
|
*/
|
||||||
abstract class Setup {
|
abstract class Setup {
|
||||||
|
|
||||||
|
protected static $_section;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of key->value pairs for airtime.conf
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $_properties;
|
||||||
|
|
||||||
abstract function __construct($settings);
|
abstract function __construct($settings);
|
||||||
|
|
||||||
abstract function runSetup();
|
abstract function runSetup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write new property values to a given section in airtime.conf.temp
|
* 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)) {
|
if (!file_exists(AIRTIME_CONF_TEMP_PATH)) {
|
||||||
copy(BUILD_PATH . "airtime.example.conf", 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 = "";
|
$fileOutput = "";
|
||||||
|
|
||||||
$inSection = false;
|
$inSection = false;
|
||||||
|
|
||||||
foreach ($file as $line) {
|
foreach ($file as $line) {
|
||||||
if (strpos($line, $section) !== false) {
|
if (strpos($line, static::$_section) !== false) {
|
||||||
$inSection = true;
|
$inSection = true;
|
||||||
} else if (strpos($line, "[") !== false) {
|
} else if (strpos($line, "[") !== false) {
|
||||||
$inSection = false;
|
$inSection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr(trim($line), 0, 1) == "#") {
|
if (substr(trim($line), 0, 1) == "#") {
|
||||||
/* Workaround to strip comments from airtime.conf.
|
/* Workaround to strip comments from airtime.conf.
|
||||||
* We need to do this because python's ConfigObj and PHP
|
* 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.
|
* characters in configuration files.
|
||||||
*/
|
*/
|
||||||
} else if ($inSection) {
|
} else if ($inSection) {
|
||||||
$key = trim(@substr($line, 0, strpos($line, "=")));
|
$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 {
|
} else {
|
||||||
$fileOutput .= $line;
|
$fileOutput .= $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(AIRTIME_CONF_TEMP_PATH, $fileOutput);
|
file_put_contents($filePath, $fileOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
35
install
35
install
|
@ -320,9 +320,10 @@ if [ -f /etc/airtime/airtime.conf ]; then
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
verbose "Stopping airtime services..."
|
verbose "Stopping airtime services..."
|
||||||
loudCmd "service airtime-playout stop-with-monit"
|
loudCmd "service airtime-playout stop"
|
||||||
loudCmd "service airtime-media-monitor stop-with-monit"
|
loudCmd "service airtime-media-monitor stop"
|
||||||
loudCmd "service airtime-liquidsoap stop-with-monit"
|
loudCmd "service airtime_analyzer stop"
|
||||||
|
loudCmd "service airtime-liquidsoap stop"
|
||||||
verbose "...Done"
|
verbose "...Done"
|
||||||
|
|
||||||
echo "Looks like you have an old version of Airtime. Your current /etc/airtime/airtime.conf \
|
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
|
if [ -d /usr/lib/airtime/ ]; then
|
||||||
rm -rf /usr/lib/airtime/
|
rm -rf /usr/lib/airtime/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm /etc/init.d/airtime-*
|
rm /etc/init.d/airtime-*
|
||||||
|
|
||||||
if [ "$apache" = "t" ]; then
|
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"
|
loudCmd "python ${AIRTIMEROOT}/python_apps/api_clients/setup.py install --install-scripts=/usr/bin"
|
||||||
verbose "...Done"
|
verbose "...Done"
|
||||||
|
|
||||||
verbose "\n * Installing media-monitor..."
|
verbose "\n * Installing pypo and liquidsoap..."
|
||||||
loudCmd "python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install --install-scripts=/usr/bin"
|
loudCmd "python ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin"
|
||||||
verbose "...Done"
|
verbose "...Done"
|
||||||
|
|
||||||
verbose "\n * Installing pypo..."
|
verbose "\n * Installing airtime-celery..."
|
||||||
loudCmd "python ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin"
|
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"
|
verbose "...Done"
|
||||||
|
|
||||||
#for i in /etc/init/airtime*.template; do
|
#for i in /etc/init/airtime*.template; do
|
||||||
|
@ -476,9 +481,10 @@ verbose "...Done"
|
||||||
set +e
|
set +e
|
||||||
loudCmd "initctl reload-configuration"
|
loudCmd "initctl reload-configuration"
|
||||||
loudCmd "systemctl daemon-reload" #systemd hipsters
|
loudCmd "systemctl daemon-reload" #systemd hipsters
|
||||||
loudCmd "update-rc.d airtime-playout defaults" # Start at bootup, on Debian
|
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-celery defaults" # Start at bootup, on Debian
|
||||||
loudCmd "update-rc.d airtime-liquidsoap 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
|
set -e
|
||||||
|
|
||||||
if [ ! -d /var/log/airtime ]; then
|
if [ ! -d /var/log/airtime ]; then
|
||||||
|
@ -566,7 +572,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
verbose "\n * Setting RabbitMQ user permissions..."
|
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
|
if [ ! -d "/etc/airtime" ]; then
|
||||||
loud "\n-----------------------------------------------------"
|
loud "\n-----------------------------------------------------"
|
||||||
|
@ -575,8 +582,12 @@ if [ ! -d "/etc/airtime" ]; then
|
||||||
|
|
||||||
verbose "\n * Creating /etc/airtime/ directory..."
|
verbose "\n * Creating /etc/airtime/ directory..."
|
||||||
mkdir /etc/airtime
|
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
|
fi
|
||||||
chown -R ${web_user}:${web_user} /etc/airtime
|
chown -R ${web_user}:${web_user} /etc/airtime
|
||||||
|
chown -R ${web_user}:${web_user} /etc/airtime-saas
|
||||||
|
|
||||||
if [ ! -d "/srv/airtime" ]; then
|
if [ ! -d "/srv/airtime" ]; then
|
||||||
mkdir -p /srv/airtime
|
mkdir -p /srv/airtime
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
include README.rst
|
|
@ -3,6 +3,11 @@ from subprocess import call
|
||||||
import os
|
import os
|
||||||
import sys
|
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']
|
install_args = ['install', 'install_data', 'develop']
|
||||||
run_postinst = False
|
run_postinst = False
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import sys
|
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
|
# Allows us to avoid installing the upstart init script when deploying airtime_analyzer
|
||||||
# on Airtime Pro:
|
# on Airtime Pro:
|
||||||
|
|
|
@ -23,6 +23,7 @@ dropAirtimeDatabase() {
|
||||||
su postgres <<'EOF'
|
su postgres <<'EOF'
|
||||||
set +e
|
set +e
|
||||||
# DROP DATABASE cannot be executed from a function or multi-command string
|
# 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 DATABASE IF EXISTS airtime"
|
||||||
psql -d postgres -tAc "DROP USER IF EXISTS airtime"
|
psql -d postgres -tAc "DROP USER IF EXISTS airtime"
|
||||||
set -e
|
set -e
|
||||||
|
@ -87,7 +88,10 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\nUninstalling Airtime..."
|
echo -e "\nUninstalling Airtime..."
|
||||||
|
service airtime-celery stop
|
||||||
|
set +e
|
||||||
removeRabbitmqAirtimeSettings
|
removeRabbitmqAirtimeSettings
|
||||||
|
set -e
|
||||||
|
|
||||||
for i in ${FILES[*]}; do
|
for i in ${FILES[*]}; do
|
||||||
rm -rf $i
|
rm -rf $i
|
||||||
|
|
Loading…
Reference in New Issue