CC-2044: remove hardcoded settings from application/configs/conf.php
-baseFilesDir now moved to /etc/airtime/airtime.conf
This commit is contained in:
parent
fe97a25e28
commit
8e07446e88
|
@ -1,24 +1,15 @@
|
|||
<?php
|
||||
// **********************************
|
||||
// ***** START CUSTOMIZING HERE *****
|
||||
// **********************************
|
||||
|
||||
// Set the location where you want to store all of your audio files.
|
||||
//
|
||||
// For example:
|
||||
// $baseFilesDir = '/home/john/radio-files';
|
||||
$baseFilesDir = __DIR__.'/../../files';
|
||||
// ***********************************************************************
|
||||
// STOP CUSTOMIZING HERE
|
||||
//
|
||||
// You don't need to touch anything below this point.
|
||||
// ***********************************************************************
|
||||
|
||||
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
|
||||
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
|
||||
* /etc/airtime/airtime.conf
|
||||
* /etc/airtime/pypo.cfg
|
||||
* /etc/airtime/recorder.cfg
|
||||
*/
|
||||
|
||||
define('AIRTIME_VERSION', '1.7.0-alpha');
|
||||
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
||||
define('AIRTIME_REST_VERSION', '1.1');
|
||||
|
||||
// These are the default values for the config.
|
||||
global $CC_CONFIG;
|
||||
$values = load_airtime_config();
|
||||
|
||||
|
@ -29,9 +20,9 @@ $CC_CONFIG = array(
|
|||
|
||||
'rabbitmq' => $values['rabbitmq'],
|
||||
|
||||
'baseFilesDir' => $baseFilesDir,
|
||||
'baseFilesDir' => $values['general']['baseFilesDir'],
|
||||
// main directory for storing binary media files
|
||||
'storageDir' => "$baseFilesDir/stor",
|
||||
'storageDir' => $values['general']['baseFilesDir']."/stor",
|
||||
|
||||
// Database config
|
||||
'dsn' => array(
|
||||
|
|
|
@ -14,3 +14,4 @@ vhost = /
|
|||
[general]
|
||||
api_key = AAA
|
||||
webServerUser = www-data
|
||||
baseFilesDir = x
|
||||
|
|
|
@ -11,14 +11,11 @@ require_once(dirname(__FILE__).'/include/installInit.php');
|
|||
|
||||
ExitIfNotRoot();
|
||||
CreateINIFile();
|
||||
UpdateINIFiles();
|
||||
|
||||
require_once(dirname(__FILE__).'/../application/configs/conf.php');
|
||||
require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
|
||||
|
||||
AirtimeInstall::CreateApiKey();
|
||||
AirtimeInstall::UpdateIniValue('../build/build.properties', 'project.home', realpath(__dir__.'/../'));
|
||||
|
||||
|
||||
echo PHP_EOL."*** Database Installation ***".PHP_EOL;
|
||||
|
||||
echo "* Creating Airtime database user".PHP_EOL;
|
||||
|
|
|
@ -60,43 +60,6 @@ class AirtimeInstall {
|
|||
chmod($filePath, $fileperms);
|
||||
}
|
||||
|
||||
private static function GenerateRandomString($len=20, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||
{
|
||||
$string = '';
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
$pos = mt_rand(0, strlen($chars)-1);
|
||||
$string .= $chars{$pos};
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function CreateApiKey()
|
||||
{
|
||||
$api_key = AirtimeInstall::GenerateRandomString();
|
||||
AirtimeInstall::UpdateIniValue('/etc/airtime/airtime.conf', 'api_key', $api_key);
|
||||
AirtimeInstall::UpdateIniValue('/etc/airtime/pypo.cfg', 'api_key', "'$api_key'");
|
||||
AirtimeInstall::UpdateIniValue('/etc/airtime/recorder.cfg', 'api_key', "'$api_key'");
|
||||
}
|
||||
|
||||
public static function UpdateIniValue($filename, $property, $value)
|
||||
{
|
||||
$lines = file($filename);
|
||||
$n=count($lines);
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
if (strlen($lines[$i]) > strlen($property))
|
||||
if ($property == substr($lines[$i], 0, strlen($property))){
|
||||
$lines[$i] = "$property = $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public static function SetupStorageDirectory($CC_CONFIG)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
|
|
@ -54,3 +54,42 @@ function ExitIfNotRoot()
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function GenerateRandomString($len=20, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||
{
|
||||
$string = '';
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
$pos = mt_rand(0, strlen($chars)-1);
|
||||
$string .= $chars{$pos};
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function UpdateIniValue($filename, $property, $value)
|
||||
{
|
||||
$lines = file($filename);
|
||||
$n=count($lines);
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
if (strlen($lines[$i]) > strlen($property))
|
||||
if ($property == substr($lines[$i], 0, strlen($property))){
|
||||
$lines[$i] = "$property = $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function UpdateINIFiles()
|
||||
{
|
||||
$api_key = GenerateRandomString();
|
||||
UpdateIniValue('/etc/airtime/airtime.conf', 'api_key', $api_key);
|
||||
UpdateIniValue('/etc/airtime/airtime.conf', 'baseFilesDir', realpath(__DIR__.'/../../files'));
|
||||
UpdateIniValue('/etc/airtime/pypo.cfg', 'api_key', "'$api_key'");
|
||||
UpdateIniValue('/etc/airtime/recorder.cfg', 'api_key', "'$api_key'");
|
||||
UpdateIniValue(__DIR__.'/../../build/build.properties', 'project.home', realpath(__dir__.'/../../'));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue