CC-2271 1.8.2 code cleanup tasks
changing 1.8.1 upgrade script to using raw source first.
This commit is contained in:
parent
d6616004a6
commit
b84854c13c
|
@ -166,7 +166,8 @@ class LibraryController extends Zend_Controller_Action
|
||||||
|
|
||||||
$data = $formdata;
|
$data = $formdata;
|
||||||
$data['filepath'] = $file->getRealFilePath();
|
$data['filepath'] = $file->getRealFilePath();
|
||||||
RabbitMq::SendFileMetaData($data);
|
//wait for 1.9.0 release
|
||||||
|
//RabbitMq::SendFileMetaData($data);
|
||||||
|
|
||||||
$this->_helper->redirector('index');
|
$this->_helper->redirector('index');
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ class RabbitMq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wait for 1.9.0 release
|
||||||
|
|
||||||
public static function SendFileMetaData($md)
|
public static function SendFileMetaData($md)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
@ -61,6 +64,7 @@ class RabbitMq
|
||||||
$channel->close();
|
$channel->close();
|
||||||
$conn->close();
|
$conn->close();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ system("python ".__DIR__."/../python_apps/pypo/install/pypo-install.py");
|
||||||
echo PHP_EOL."*** Recorder Installation ***".PHP_EOL;
|
echo PHP_EOL."*** Recorder Installation ***".PHP_EOL;
|
||||||
system("python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py");
|
system("python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py");
|
||||||
|
|
||||||
|
//wait for 1.9.0 release
|
||||||
//echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL;
|
//echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL;
|
||||||
//system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py");
|
//system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py");
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ echo PHP_EOL."*** Uninstalling Show Recorder ***".PHP_EOL;
|
||||||
$command = "python ".__DIR__."/../python_apps/show-recorder/install/recorder-uninstall.py";
|
$command = "python ".__DIR__."/../python_apps/show-recorder/install/recorder-uninstall.py";
|
||||||
system($command);
|
system($command);
|
||||||
|
|
||||||
|
//wait for 1.9.0 release
|
||||||
//echo PHP_EOL."*** Uninstalling Media Monitor ***".PHP_EOL;
|
//echo PHP_EOL."*** Uninstalling Media Monitor ***".PHP_EOL;
|
||||||
//$command = "python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-uninstall.py";
|
//$command = "python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-uninstall.py";
|
||||||
//system($command);
|
//system($command);
|
||||||
|
|
|
@ -26,15 +26,14 @@ class AirtimeIni
|
||||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/MediaMonitor.cfg";
|
//const CONF_FILE_MEDIAMONITOR = "/etc/airtime/MediaMonitor.cfg";
|
||||||
|
|
||||||
public static function IniFilesExist()
|
public static function IniFilesExist()
|
||||||
{
|
{
|
||||||
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
||||||
AirtimeIni::CONF_FILE_PYPO,
|
AirtimeIni::CONF_FILE_PYPO,
|
||||||
AirtimeIni::CONF_FILE_RECORDER,
|
AirtimeIni::CONF_FILE_RECORDER,
|
||||||
AirtimeIni::CONF_FILE_LIQUIDSOAP,
|
AirtimeIni::CONF_FILE_LIQUIDSOAP);
|
||||||
AirtimeIni::CONF_FILE_MEDIAMONITOR);
|
|
||||||
$exist = false;
|
$exist = false;
|
||||||
foreach ($configFiles as $conf) {
|
foreach ($configFiles as $conf) {
|
||||||
if (file_exists($conf)) {
|
if (file_exists($conf)) {
|
||||||
|
@ -74,10 +73,11 @@ class AirtimeIni
|
||||||
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!copy(__DIR__."/../../python_apps/pytag-fs/MediaMonitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
//wait until Airtime 1.9.0
|
||||||
echo "Could not copy MediaMonitor.cfg to /etc/airtime/. Exiting.";
|
//if (!copy(__DIR__."/../../python_apps/pytag-fs/MediaMonitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
||||||
exit(1);
|
// echo "Could not copy MediaMonitor.cfg to /etc/airtime/. Exiting.";
|
||||||
}
|
// exit(1);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,9 +102,10 @@ class AirtimeIni
|
||||||
unlink(AirtimeIni::CONF_FILE_LIQUIDSOAP);
|
unlink(AirtimeIni::CONF_FILE_LIQUIDSOAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
//wait until Airtime 1.9.0
|
||||||
unlink(AirtimeIni::CONF_FILE_MEDIAMONITOR);
|
//if (file_exists(AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
||||||
}
|
// unlink(AirtimeIni::CONF_FILE_MEDIAMONITOR);
|
||||||
|
//}
|
||||||
|
|
||||||
if (file_exists("etc/airtime")){
|
if (file_exists("etc/airtime")){
|
||||||
rmdir("/etc/airtime/");
|
rmdir("/etc/airtime/");
|
||||||
|
|
|
@ -7,20 +7,222 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||||
require_once __DIR__.'/../../../airtime_mvc/application/configs/conf.php';
|
|
||||||
require_once(dirname(__FILE__).'/../../include/AirtimeInstall.php');
|
|
||||||
require_once(dirname(__FILE__).'/../../include/AirtimeIni.php');
|
|
||||||
|
|
||||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||||
|
|
||||||
|
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||||
|
const CONF_DIR_STORAGE = "/srv/airtime";
|
||||||
|
const CONF_DIR_WWW = "/var/www/airtime";
|
||||||
|
const CONF_DIR_LOG = "/var/log/airtime";
|
||||||
|
|
||||||
|
const AIRTIME_SRC = __DIR__."/../../../airtime_mvc";
|
||||||
|
const AIRTIME_UTILS = __DIR__."/../../../utils";
|
||||||
|
const AIRTIME_PYTHON_APPS = __DIR__."/../../../python_apps";
|
||||||
|
|
||||||
$configFiles = array(CONF_FILE_AIRTIME,
|
$configFiles = array(CONF_FILE_AIRTIME,
|
||||||
CONF_FILE_PYPO,
|
CONF_FILE_PYPO,
|
||||||
CONF_FILE_RECORDER,
|
CONF_FILE_RECORDER,
|
||||||
CONF_FILE_LIQUIDSOAP);
|
CONF_FILE_LIQUIDSOAP);
|
||||||
|
|
||||||
|
global $CC_CONFIG;
|
||||||
|
|
||||||
|
$CC_CONFIG = array(
|
||||||
|
// prefix for table names in the database
|
||||||
|
'tblNamePrefix' => 'cc_',
|
||||||
|
|
||||||
|
/* ================================================ storage configuration */
|
||||||
|
|
||||||
|
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
|
||||||
|
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
|
||||||
|
|
||||||
|
"rootDir" => __DIR__."/../..",
|
||||||
|
'pearPath' => dirname(__FILE__).'/../../library/pear',
|
||||||
|
'zendPath' => dirname(__FILE__).'/../../library/Zend',
|
||||||
|
'phingPath' => dirname(__FILE__).'/../../library/phing'
|
||||||
|
);
|
||||||
|
|
||||||
|
//$CC_CONFIG = Config::loadConfig($CC_CONFIG);
|
||||||
|
|
||||||
|
// Add database table names
|
||||||
|
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
|
||||||
|
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
|
||||||
|
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||||
|
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||||
|
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||||
|
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||||
|
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||||
|
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||||
|
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||||
|
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
|
||||||
|
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
|
||||||
|
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
|
||||||
|
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
|
||||||
|
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
|
||||||
|
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
|
||||||
|
|
||||||
|
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
|
||||||
|
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
|
||||||
|
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
|
||||||
|
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
||||||
|
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
||||||
|
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
||||||
|
|
||||||
|
// Add libs to the PHP path
|
||||||
|
$old_include_path = get_include_path();
|
||||||
|
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
|
||||||
|
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
|
||||||
|
.PATH_SEPARATOR.$old_include_path);
|
||||||
|
|
||||||
|
public static function LoadConfig($CC_CONFIG) {
|
||||||
|
$values = parse_ini_file(CONF_FILE_AIRTIME, true);
|
||||||
|
|
||||||
|
// Name of the web server user
|
||||||
|
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
|
||||||
|
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
|
||||||
|
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
|
||||||
|
|
||||||
|
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
|
||||||
|
$CC_CONFIG['basePort'] = $values['general']['base_port'];
|
||||||
|
|
||||||
|
$CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir'];
|
||||||
|
// main directory for storing binary media files
|
||||||
|
$CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor";
|
||||||
|
|
||||||
|
// Database config
|
||||||
|
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||||
|
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||||
|
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||||
|
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||||
|
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||||
|
|
||||||
|
$CC_CONFIG['apiKey'] = array($values['general']['api_key']);
|
||||||
|
|
||||||
|
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
|
||||||
|
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
|
||||||
|
|
||||||
|
return $CC_CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function creates the /etc/airtime configuration folder
|
||||||
|
* and copies the default config files to it.
|
||||||
|
*/
|
||||||
|
public static function CreateIniFiles()
|
||||||
|
{
|
||||||
|
if (!file_exists("/etc/airtime/")){
|
||||||
|
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||||
|
echo "Could not create /etc/airtime/ directory. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!copy(AIRTIME_SRC."/build/airtime.conf", CONF_FILE_AIRTIME)){
|
||||||
|
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (!copy(AIRTIME_PYTHON_APPS."/pypo/pypo.cfg", CONF_FILE_PYPO)){
|
||||||
|
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (!copy(AIRTIME_PYTHON_APPS."/show-recorder/recorder.cfg", CONF_FILE_RECORDER)){
|
||||||
|
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (!copy(AIRTIME_PYTHON_APPS."/pypo/scripts/liquidsoap.cfg", CONF_FILE_LIQUIDSOAP)){
|
||||||
|
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function ReadPythonConfig($p_filename)
|
||||||
|
{
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
$lines = file($p_filename);
|
||||||
|
$n=count($lines);
|
||||||
|
for ($i=0; $i<$n; $i++) {
|
||||||
|
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
|
||||||
|
$info = explode("=", $lines[$i]);
|
||||||
|
$values[trim($info[0])] = trim($info[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function UpdateIniValue($p_filename, $p_property, $p_value)
|
||||||
|
{
|
||||||
|
$lines = file($p_filename);
|
||||||
|
$n=count($lines);
|
||||||
|
for ($i=0; $i<$n; $i++) {
|
||||||
|
if (strlen($lines[$i]) > strlen($p_property))
|
||||||
|
if ($p_property == substr($lines[$i], 0, strlen($p_property))){
|
||||||
|
$lines[$i] = "$p_property = $p_value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fp=fopen($p_filename, 'w');
|
||||||
|
for($i=0; $i<$n; $i++){
|
||||||
|
fwrite($fp, $lines[$i]);
|
||||||
|
}
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function MergeConfigFiles($configFiles, $suffix)
|
||||||
|
{
|
||||||
|
foreach ($configFiles as $conf) {
|
||||||
|
if (file_exists("$conf$suffix.bak")) {
|
||||||
|
|
||||||
|
if($conf === CONF_FILE_AIRTIME) {
|
||||||
|
// Parse with sections
|
||||||
|
$newSettings = parse_ini_file($conf, true);
|
||||||
|
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$newSettings = ReadPythonConfig($conf);
|
||||||
|
$oldSettings = ReadPythonConfig("$conf$suffix.bak");
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = array_keys($newSettings);
|
||||||
|
|
||||||
|
foreach($settings as $section) {
|
||||||
|
if(isset($oldSettings[$section])) {
|
||||||
|
if(is_array($oldSettings[$section])) {
|
||||||
|
$sectionKeys = array_keys($newSettings[$section]);
|
||||||
|
foreach($sectionKeys as $sectionKey) {
|
||||||
|
if(isset($oldSettings[$section][$sectionKey])) {
|
||||||
|
UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UpdateIniValue($conf, $section, $oldSettings[$section]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function InstallPhpCode()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
echo "* Installing PHP code to ".$CC_CONFIG['phpDir'].PHP_EOL;
|
||||||
|
exec("mkdir -p ".$CC_CONFIG['phpDir']);
|
||||||
|
exec("cp -R ".AIRTIME_SRC."/* ".$CC_CONFIG['phpDir']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function InstallBinaries()
|
||||||
|
{
|
||||||
|
echo "* Installing binaries to ".CONF_DIR_BINARIES.PHP_EOL;
|
||||||
|
exec("mkdir -p ".CONF_DIR_BINARIES);
|
||||||
|
exec("cp -R ".AIRTIME_UTILS." ".CONF_DIR_BINARIES);
|
||||||
|
}
|
||||||
|
|
||||||
$suffix = date("Ymdhis");
|
$suffix = date("Ymdhis");
|
||||||
foreach ($configFiles as $conf) {
|
foreach ($configFiles as $conf) {
|
||||||
if (file_exists($conf)) {
|
if (file_exists($conf)) {
|
||||||
|
@ -29,11 +231,11 @@ foreach ($configFiles as $conf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AirtimeIni::CreateIniFiles();
|
CreateIniFiles();
|
||||||
echo "* Initializing INI files".PHP_EOL;
|
echo "* Initializing INI files".PHP_EOL;
|
||||||
AirtimeIni::MergeConfigFiles($configFiles, $suffix);
|
MergeConfigFiles($configFiles, $suffix);
|
||||||
global $CC_CONFIG;
|
|
||||||
$CC_CONFIG = Config::loadConfig($CC_CONFIG);
|
|
||||||
|
|
||||||
AirtimeInstall::InstallPhpCode();
|
$CC_CONFIG = LoadConfig($CC_CONFIG);
|
||||||
AirtimeInstall::InstallBinaries();
|
|
||||||
|
InstallPhpCode();
|
||||||
|
InstallBinaries();
|
||||||
|
|
Loading…
Reference in New Issue