Work on new WordPress style install process

This commit is contained in:
Duncan Sommerville 2014-11-27 18:47:05 -05:00
parent 85d965055d
commit 4a1354c45f
6 changed files with 233 additions and 117 deletions

View File

@ -0,0 +1,2 @@
<?php

View File

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

View File

@ -0,0 +1,82 @@
<?php
// Only enable cookie secure if we are supporting https.
// Ideally, this would always be on and we would force https,
// but the default installation configs are likely to be installed by
// amature users on the setup that does not have https. Forcing
// cookie_secure on non https would result in confusing login problems.
if(!empty($_SERVER['HTTPS'])) {
ini_set('session.cookie_secure', '1');
}
ini_set('session.cookie_httponly', '1');
error_reporting(E_ALL|E_STRICT);
function exception_error_handler($errno, $errstr, $errfile, $errline) {
//Check if the statement that threw this error wanted its errors to be
//suppressed. If so then return without with throwing exception.
if (0 === error_reporting()) return;
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
return false;
}
set_error_handler("exception_error_handler");
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
defined('VERBOSE_STACK_TRACE')
|| define('VERBOSE_STACK_TRACE', (getenv('VERBOSE_STACK_TRACE') ? getenv('VERBOSE_STACK_TRACE') : true));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
realpath(APPLICATION_PATH . '/../library')
)));
set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path());
//Propel classes.
set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path());
//Controller plugins.
set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . get_include_path());
//Zend framework
if (file_exists('/usr/share/php/libzend-framework-php')) {
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
}
/** Zend_Application */
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
require_once(APPLICATION_PATH . "/logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
// Create application, bootstrap, and run
try {
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cli') {
set_include_path(APPLICATION_PATH . PATH_SEPARATOR . get_include_path());
require_once("Bootstrap.php");
} else {
$application->bootstrap()->run();
}
} catch (Exception $e) {
echo $e->getMessage();
echo "<pre>";
echo $e->getTraceAsString();
echo "</pre>";
Logging::info($e->getMessage());
if (VERBOSE_STACK_TRACE) {
Logging::info($e->getTraceAsString());
} else {
Logging::info($e->getTrace());
}
}

View File

@ -0,0 +1,107 @@
<?php
/*
* We only get here after setup, or if there's an error in the configuration.
*
* Display a table to the user showing the necessary dependencies
* (both PHP and binary) and the status of any application services,
* along with steps to fix them if they're not found or misconfigured.
*/
$phpDependencies = airtimeCheckDependencies();
$zend = $phpDependencies["zend"];
$database = airtimeCheckDatabase();
$result = $database;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.3.3.1.min.css">
</head>
<body style="padding: 2em 0; min-width: 500px; width: 50%; text-align: center; margin: 0 auto;">
<h1>
Airtime Configuration Checklist
</h1>
<table class="table table-striped" style="text-align: center">
<caption>
Airtime Configuration
</caption>
<thead>
<tr>
<td>
Component
</td>
<td>
Description
</td>
<td>
Solution
</td>
</tr>
</thead>
<tbody>
<tr class="<?=$zend ? 'success' : 'danger';?>">
<td>
<strong>Zend</strong>
</td>
<td>
PHP MVC Framework
</td>
<td <?php if ($zend) {echo 'style="background: #dff0d8 url(css/images/accept.png) no-repeat center"';?>>
<?php
} else {
?>>
<b>Ubuntu</b>: try running <code>sudo apt-get install libzend-framework-php</code>
<br/><b>Debian</b>: try running <code>sudo apt-get install zendframework</code>
<?php
}
?>
</td>
</tr>
<tr class="<?=$database ? 'success' : 'danger';?>">
<td>
<strong>Database</strong>
</td>
<td>
PostgreSQL data store for Airtime
</td>
<td <?php if ($database) {echo 'style="background: #dff0d8 url(css/images/accept.png) no-repeat center"';?>>
<?php
} else {
?>>
Try running <code>sudo apt-get install php5-pgsql php5-mysql</code>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
<?php
if (!$result) {
?>
<p>
Looks like something went wrong! If you've tried everything we've recommended in the table above, come
<a href="https://forum.sourcefabric.org/">visit our forums</a>
or <a href="http://www.sourcefabric.org/en/airtime/manuals/">check out the manual</a>.
</p>
<?php
}
?>
<br/>
<h3>
PHP Extension List
</h3>
<p>
<?php
foreach (get_loaded_extensions() as $ext) {
echo $ext . " | ";
}
?>
</p>
<?php

View File

@ -1,86 +1,44 @@
<?php
// Only enable cookie secure if we are supporting https.
// Ideally, this would always be on and we would force https,
// but the default installation configs are likely to be installed by
// amature users on the setup that does not have https. Forcing
// cookie_secure on non https would result in confusing login problems.
if(!empty($_SERVER['HTTPS'])) {
ini_set('session.cookie_secure', '1');
}
ini_set('session.cookie_httponly', '1');
error_reporting(E_ALL|E_STRICT);
function exception_error_handler($errno, $errstr, $errfile, $errline) {
//Check if the statement that threw this error wanted its errors to be
//suppressed. If so then return without with throwing exception.
if (0 === error_reporting()) return;
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
return false;
}
set_error_handler("exception_error_handler");
define('ROOT_PATH', dirname( __DIR__) . '/');
define('WEB_ROOT_PATH', __DIR__ . '/');
define('LIB_PATH', ROOT_PATH . 'library/');
define('BUILD_PATH', ROOT_PATH . 'build/');
define('SETUP_DIR', 'airtime-setup/');
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('APPLICATION_PATH', ROOT_PATH . 'application');
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
define('AIRTIME_CONFIG', 'airtime.conf');
defined('VERBOSE_STACK_TRACE')
|| define('VERBOSE_STACK_TRACE', (getenv('VERBOSE_STACK_TRACE') ? getenv('VERBOSE_STACK_TRACE') : true));
require_once(APPLICATION_PATH . "/configs/conf.php");
require_once(BUILD_PATH . SETUP_DIR . 'load.php');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
realpath(APPLICATION_PATH . '/../library')
)));
function showConfigCheckPage() {
airtimeConfigureDatabase();
set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path());
//Propel classes.
set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path());
//Controller plugins.
set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . get_include_path());
//Zend framework
if (file_exists('/usr/share/php/libzend-framework-php')) {
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
require_once(WEB_ROOT_PATH . 'config-check.php');
die();
}
/** Zend_Application */
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
require_once (APPLICATION_PATH."/logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
// Create application, bootstrap, and run
try {
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cli') {
set_include_path(APPLICATION_PATH . PATH_SEPARATOR . get_include_path());
require_once("Bootstrap.php");
} else {
$application->bootstrap()->run();
}
} catch (Exception $e) {
echo $e->getMessage();
echo "<pre>";
echo $e->getTraceAsString();
echo "</pre>";
Logging::info($e->getMessage());
if (VERBOSE_STACK_TRACE) {
Logging::info($e->getTraceAsString());
} else {
Logging::info($e->getTrace());
}
if (array_key_exists('config', $_GET)) {
showConfigCheckPage();
}
// If a configuration file exists, forward to our boot script
if (file_exists(BUILD_PATH . AIRTIME_CONFIG)) {
airtimeConfigureDatabase();
// If the database doesn't exist, or is improperly configured,
// show the user a configuration error page so they know what went wrong
if (!airtimeCheckDatabase()) {
showConfigCheckPage();
}
require_once(WEB_ROOT_PATH . 'airtime-boot.php');
}
// Otherwise, we'll need to run our configuration setup
else {
require_once(BUILD_PATH . SETUP_DIR . 'setup-config.php');
}

View File

@ -36,17 +36,17 @@ echo " * \____|__ /___||____|_ / |____| |___\____|__ /__
echo " * \/ \/ \/ \/ *"
echo " ****************************************************************"
echo " ____ ______ ____ ____ __________ __ _________ ____ ____ "
echo " ____ ______ ____ ____ __________ __ _________ ____ ____ "
echo " / _ \\\\____ \_/ __ \ / \ / ___/ _ \| | \_ __ \_/ ___\/ __ \ "
echo " ( <_> ) |_> > ___/| | \ \___ ( <_> ) | /| | \/\ \__\ ___/ "
echo " \____/| __/ \___ >___| / /____ >____/|____/ |__| \___ >___ > "
echo " |__| \/ \/ \/ \/ \/ "
echo " .___.__ __ __ .__ "
echo "____________ __| _/|__| ____ _____ __ ___/ |_ ____ _____ _____ _/ |_|__| ____ ____ "
echo "\_ __ \__ \ / __ | | |/ _ \ \__ \ | | \ __\/ _ \ / \\\\__ \\\\ __\ |/ _ \ / \ "
echo " | | \// __ \_/ /_/ | | ( <_> ) / __ \| | /| | ( <_> ) Y Y \/ __ \| | | ( <_> ) | \ "
echo " |__| (____ /\____ | |__|\____/ (____ /____/ |__| \____/|__|_| (____ /__| |__|\____/|___| / "
echo " \/ \/ \/ \/ \/ \/ "
echo " ( <_> ) |_> > ___/| | \ \___ ( <_> ) | /| | \/\ \__\ ___/ "
echo " \____/| __/ \___ >___| / /____ >____/|____/ |__| \___ >___ > "
echo " |__| \/ \/ \/ \/ \/ "
echo " .___.__ __ __ .__ "
echo "____________ __| _/|__| ____ _____ __ ___/ |_ ____ _____ _____ _/ |_|__| ____ ____ "
echo "\_ __ \__ \ / __ | | |/ _ \ \__ \ | | \ __\/ _ \ / \\\\__ \\\\ __\ |/ _ \ / \ "
echo " | | \// __ \_/ /_/ | | ( <_> ) / __ \| | /| | ( <_> ) Y Y \/ __ \| | | ( <_> ) | \ "
echo " |__| (____ /\____ | |__|\____/ (____ /____/ |__| \____/|__|_| (____ /__| |__|\____/|___| / "
echo " \/ \/ \/ \/ \/ \/ "
echo -e "\n-----------------------------------------------------"
echo " * Installing Apache * "
@ -136,4 +136,3 @@ echo " "
echo " To get started with Airtime, visit localhost:5000 "
echo " in your web browser of choice "
echo "-----------------------------------------------------"