feat(legacy): consolidate constants (#1558)
* remove unused file * fix paths leading slash * remove useless imports * refactor(legacy): use constants everywhere * fix path leading slash * remove useless import * consolidate legacy contants * format code * reuse LIBRETIME_CONFIG_DIR * fix test config path * remove ci legacy log dir creation * some logs improvements
This commit is contained in:
parent
e106858fd8
commit
729a7b99e0
34 changed files with 133 additions and 257 deletions
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
class DatabaseSetup extends Setup
|
||||
{
|
||||
// airtime.conf section header
|
||||
// config file section header
|
||||
protected static $_section = '[database]';
|
||||
|
||||
// Constant form field names for passing errors back to the front-end
|
||||
|
@ -17,7 +17,7 @@ class DatabaseSetup extends Setup
|
|||
public const DB_NAME = 'dbName';
|
||||
public const DB_HOST = 'dbHost';
|
||||
|
||||
// Array of key->value pairs for airtime.conf
|
||||
// Array of key->value pairs for the config file
|
||||
protected static $_properties;
|
||||
|
||||
/**
|
||||
|
@ -294,6 +294,6 @@ class DatabaseSetup extends Setup
|
|||
*/
|
||||
private function updateDjangoTables()
|
||||
{
|
||||
shell_exec('LIBRETIME_CONFIG_FILEPATH=/etc/airtime/airtime.conf.temp libretime-api migrate');
|
||||
shell_exec('LIBRETIME_CONFIG_FILEPATH=' . INSTALLER_CONFIG_FILEPATH . ' libretime-api migrate');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,5 @@
|
|||
<?php
|
||||
|
||||
define('CONFIG_PATH', dirname(__DIR__, 2) . '/application/configs/');
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/vendor/jooola/propel1/runtime/lib/Propel.php';
|
||||
|
||||
require_once CONFIG_PATH . 'conf.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcPref.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcPrefPeer.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcPrefQuery.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/map/CcPrefTableMap.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcPref.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcPrefPeer.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcPrefQuery.php';
|
||||
|
||||
/**
|
||||
* User: sourcefabric
|
||||
* Date: 08/12/14.
|
||||
|
@ -30,10 +10,10 @@ require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcPrefQue
|
|||
*/
|
||||
class GeneralSetup extends Setup
|
||||
{
|
||||
// airtime.conf section header
|
||||
// config file section header
|
||||
protected static $_section = '[general]';
|
||||
|
||||
// Array of key->value pairs for airtime.conf
|
||||
// Array of key->value pairs for the config file
|
||||
protected static $_properties;
|
||||
|
||||
// Constant form field names for passing errors back to the front-end
|
||||
|
@ -86,8 +66,8 @@ class GeneralSetup extends Setup
|
|||
public function setupCorsUrl()
|
||||
{
|
||||
try {
|
||||
$_SERVER['AIRTIME_CONF'] = AIRTIME_CONF_TEMP_PATH;
|
||||
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
||||
$_SERVER['LIBRETIME_CONFIG_FILEPATH'] = INSTALLER_CONFIG_FILEPATH;
|
||||
Propel::init(PROPEL_CONFIG_FILEPATH);
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
self::$message = "Failed to insert Cors URL; database isn't configured properly!";
|
||||
|
@ -104,7 +84,6 @@ class GeneralSetup extends Setup
|
|||
try {
|
||||
Application_Model_Preference::SetAllowedCorsUrls(self::$cors_url);
|
||||
Propel::close();
|
||||
//unset($_SERVER['AIRTIME_CONF']);
|
||||
} catch (Exception $e) {
|
||||
self::$message = 'Failed to insert ' . self::$cors_url . ' into cc_pref' . $e;
|
||||
self::$errors[] = self::CORS_URL;
|
||||
|
|
|
@ -1,26 +1,5 @@
|
|||
<?php
|
||||
|
||||
define('CONFIG_PATH', dirname(__DIR__, 2) . '/application/configs/');
|
||||
define('DEFAULT_STOR_DIR', '/srv/airtime/stor/');
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/vendor/jooola/propel1/runtime/lib/Propel.php';
|
||||
|
||||
require_once CONFIG_PATH . 'conf.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/map/CcMusicDirsTableMap.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcMusicDirsQuery.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcMusicDirsQuery.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcMusicDirs.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcMusicDirs.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/om/BaseCcMusicDirsPeer.php';
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/application/models/airtime/CcMusicDirsPeer.php';
|
||||
|
||||
/**
|
||||
* Author: sourcefabric
|
||||
* Date: 08/12/14.
|
||||
|
@ -32,7 +11,6 @@ require_once dirname(__DIR__, 2) . '/application/models/airtime/CcMusicDirsPeer.
|
|||
class MediaSetup extends Setup
|
||||
{
|
||||
public const MEDIA_FOLDER = 'mediaFolder';
|
||||
public const LIBRETIME_CONF_FILE_NAME = 'airtime.conf';
|
||||
|
||||
public static $path;
|
||||
public static $message;
|
||||
|
@ -50,9 +28,9 @@ class MediaSetup extends Setup
|
|||
{
|
||||
// If the path passed in is empty, set it to the default
|
||||
if (strlen(self::$path) == 0) {
|
||||
self::$path = DEFAULT_STOR_DIR;
|
||||
if (!file_exists(DEFAULT_STOR_DIR)) {
|
||||
mkdir(DEFAULT_STOR_DIR, 0755, true);
|
||||
self::$path = INSTALLER_DEFAULT_STORAGE_PATH;
|
||||
if (!file_exists(INSTALLER_DEFAULT_STORAGE_PATH)) {
|
||||
mkdir(INSTALLER_DEFAULT_STORAGE_PATH, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,10 +46,10 @@ class MediaSetup extends Setup
|
|||
self::$errors[] = self::MEDIA_FOLDER;
|
||||
}
|
||||
|
||||
// Finalize and move airtime.conf.temp
|
||||
if (file_exists('/etc/airtime/')) {
|
||||
// Finalize and move installer config file to libretime config file
|
||||
if (file_exists(LIBRETIME_CONFIG_DIR)) {
|
||||
if (!$this->moveAirtimeConfig()) {
|
||||
self::$message = 'Error moving airtime.conf or deleting /tmp/airtime.conf.temp!';
|
||||
self::$message = 'Error moving or deleting the installer config!';
|
||||
self::$errors[] = 'ERR';
|
||||
}
|
||||
|
||||
|
@ -80,7 +58,7 @@ class MediaSetup extends Setup
|
|||
* airtime.conf to airtime.conf.tmp during the setup process. Now that we're done,
|
||||
* we can rename it to airtime.conf.bak to avoid confusion.
|
||||
*/
|
||||
$fileName = LIBRETIME_CONF_DIR . '/' . self::LIBRETIME_CONF_FILE_NAME;
|
||||
$fileName = LIBRETIME_CONFIG_FILEPATH;
|
||||
$tmpFile = $fileName . '.tmp';
|
||||
$bakFile = $fileName . '.bak';
|
||||
if (file_exists($tmpFile)) {
|
||||
|
@ -104,8 +82,8 @@ class MediaSetup extends Setup
|
|||
*/
|
||||
public function moveAirtimeConfig()
|
||||
{
|
||||
return copy(AIRTIME_CONF_TEMP_PATH, LIBRETIME_CONF_DIR . '/' . self::LIBRETIME_CONF_FILE_NAME)
|
||||
&& unlink(AIRTIME_CONF_TEMP_PATH);
|
||||
return copy(INSTALLER_CONFIG_FILEPATH, LIBRETIME_CONFIG_FILEPATH)
|
||||
&& unlink(INSTALLER_CONFIG_FILEPATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,8 +93,8 @@ class MediaSetup extends Setup
|
|||
public function setupMusicDirectory()
|
||||
{
|
||||
try {
|
||||
$_SERVER['AIRTIME_CONF'] = AIRTIME_CONF_TEMP_PATH;
|
||||
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
||||
$_SERVER['LIBRETIME_CONFIG_FILEPATH'] = INSTALLER_CONFIG_FILEPATH;
|
||||
Propel::init(PROPEL_CONFIG_FILEPATH);
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
self::$message = "Failed to insert media folder; database isn't configured properly!";
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
<?php
|
||||
|
||||
define('BUILD_PATH', dirname(__DIR__, 2) . '/build/');
|
||||
define('AIRTIME_CONF_TEMP_PATH', '/etc/airtime/airtime.conf.temp');
|
||||
define('RMQ_INI_TEMP_PATH', '/tmp/rabbitmq.ini.tmp');
|
||||
|
||||
// load autoloader since this files is an entry path see
|
||||
// the end of the file for the "server" that is being
|
||||
// executed.
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
require_once dirname(__DIR__, 2) . '/application/preload.php';
|
||||
|
||||
/**
|
||||
* Class Setup.
|
||||
|
@ -36,11 +29,11 @@ abstract class Setup
|
|||
*/
|
||||
protected function writeToTemp()
|
||||
{
|
||||
if (!file_exists(AIRTIME_CONF_TEMP_PATH)) {
|
||||
copy(BUILD_PATH . 'airtime.example.conf', AIRTIME_CONF_TEMP_PATH);
|
||||
if (!file_exists(INSTALLER_CONFIG_FILEPATH)) {
|
||||
copy(SAMPLE_CONFIG_FILEPATH, INSTALLER_CONFIG_FILEPATH);
|
||||
}
|
||||
//Logging::info(AIRTIME_CONF_TEMP_PATH);
|
||||
$this->_write(AIRTIME_CONF_TEMP_PATH);
|
||||
//Logging::info(CONFIG_TEMP_FILEPATH);
|
||||
$this->_write(INSTALLER_CONFIG_FILEPATH);
|
||||
}
|
||||
|
||||
protected function _write($filePath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue