diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8707b725f..59bba6a23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,7 +72,6 @@ jobs: runs-on: ${{ matrix.runs-on }} env: ENVIRONMENT: testing - LIBRETIME_LOG_DIR: /tmp/log/libretime steps: - uses: actions/checkout@v2 @@ -103,10 +102,7 @@ jobs: ${{ runner.os }}-composer- - name: Run tests - run: | - sudo mkdir -p "$LIBRETIME_LOG_DIR" - sudo chown runner:runner "$LIBRETIME_LOG_DIR" - make test + run: make test working-directory: legacy # Start lint the code without failing the entire workflow, should be merged diff --git a/legacy/application/Bootstrap.php b/legacy/application/Bootstrap.php index 4b8e6c051..68a494f1d 100644 --- a/legacy/application/Bootstrap.php +++ b/legacy/application/Bootstrap.php @@ -1,24 +1,23 @@ true]); Config::setAirtimeVersion(); -require_once CONFIG_PATH . 'navigation.php'; +require_once CONFIG_PATH . '/navigation.php'; Zend_Validate::setDefaultNamespaces('Zend'); diff --git a/legacy/application/airtime-boot.php b/legacy/application/airtime-boot.php index f5a54f804..76a181af3 100644 --- a/legacy/application/airtime-boot.php +++ b/legacy/application/airtime-boot.php @@ -27,56 +27,46 @@ function exception_error_handler($errno, $errstr, $errfile, $errline) 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, [ get_include_path(), realpath(LIB_PATH), ])); -set_include_path(APPLICATION_PATH . 'common' . PATH_SEPARATOR . get_include_path()); -set_include_path(APPLICATION_PATH . 'common/enum' . PATH_SEPARATOR . get_include_path()); -set_include_path(APPLICATION_PATH . 'common/interface' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/common/enum' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/common/interface' . PATH_SEPARATOR . get_include_path()); //Propel classes. -set_include_path(APPLICATION_PATH . 'models' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); //Controller plugins. -set_include_path(APPLICATION_PATH . 'controllers' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/controllers' . PATH_SEPARATOR . get_include_path()); //Controller plugins. -set_include_path(APPLICATION_PATH . 'controllers/plugins' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . get_include_path()); //Services. -set_include_path(APPLICATION_PATH . '/services/' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/services' . PATH_SEPARATOR . get_include_path()); //cloud storage directory set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path()); //Upgrade directory -set_include_path(APPLICATION_PATH . '/upgrade/' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/upgrade' . PATH_SEPARATOR . get_include_path()); //Common directory -set_include_path(APPLICATION_PATH . '/common/' . PATH_SEPARATOR . get_include_path()); - -//Composer's autoloader -require_once 'autoload.php'; +set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path()); /** Zend_Application */ $application = new Zend_Application( APPLICATION_ENV, - CONFIG_PATH . 'application.ini', + CONFIG_PATH . '/application.ini', true ); -require_once APPLICATION_PATH . 'logging/Logging.php'; -Logging::setLogPath(LIBRETIME_LOG_DIR . '/legacy.log'); +require_once APPLICATION_PATH . '/logging/Logging.php'; +Logging::setLogPath(LIBRETIME_LOG_FILEPATH); Logging::setupParseErrorLogging(); // Create application, bootstrap, and run diff --git a/legacy/application/cloud_storage/ProxyStorageBackend.php b/legacy/application/cloud_storage/ProxyStorageBackend.php index 64fa81ec8..d34c50d12 100644 --- a/legacy/application/cloud_storage/ProxyStorageBackend.php +++ b/legacy/application/cloud_storage/ProxyStorageBackend.php @@ -17,7 +17,7 @@ class ProxyStorageBackend extends StorageBackend { $CC_CONFIG = Config::getConfig(); - // The storage backend in the airtime.conf directly corresponds to + // The storage backend in the config file directly corresponds to // the name of the class that implements it, so we can create the // right backend object dynamically: if ($storageBackend == 'file') { diff --git a/legacy/application/configs/airtime-conf-production.php b/legacy/application/configs/airtime-conf-production.php index be89c9da5..a01c29cba 100644 --- a/legacy/application/configs/airtime-conf-production.php +++ b/legacy/application/configs/airtime-conf-production.php @@ -5,7 +5,7 @@ /* The original name of this file is airtime-conf.php but since we need to make custom changes * to it I've renamed it so that our changes aren't removed everytime we regenerate a database schema. - * our custom changes requires the database parameters to be loaded from /etc/airtime/airtime.conf so + * our custom changes requires the database parameters to be loaded from the config file so * that the user can customize these. */ diff --git a/legacy/application/configs/conf.php b/legacy/application/configs/conf.php index cb9fd5f2c..f2818e30c 100644 --- a/legacy/application/configs/conf.php +++ b/legacy/application/configs/conf.php @@ -1,29 +1,18 @@ self::$rootDir, - ]; - - //In the unit testing environment, LIBRETIME_CONF_DIR will our local airtime.conf in legacy/application/test/conf: - $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . '/airtime.conf'; - + $filename = $_SERVER['LIBRETIME_CONFIG_FILEPATH'] ?? LIBRETIME_CONFIG_FILEPATH; $values = parse_ini_file($filename, true); + $CC_CONFIG = []; + // Name of the web server user $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; @@ -97,7 +86,7 @@ class Config public static function setAirtimeVersion() { - $version = @file_get_contents(self::$rootDir . '/../VERSION'); + $version = @file_get_contents(dirname(ROOT_PATH) . '/VERSION'); if (!$version) { // fallback to constant from constants.php if no other info is available $version = LIBRETIME_MAJOR_VERSION; diff --git a/legacy/application/configs/config-check.php b/legacy/application/configs/config-check.php index 6b4e4f631..fcf04a428 100644 --- a/legacy/application/configs/config-check.php +++ b/legacy/application/configs/config-check.php @@ -140,7 +140,7 @@ $result = $r1 && $r2; ?>"> Make sure you aren't missing any of the Postgres dependencies in the table above. If your dependencies check out, make sure your database configuration settings in - /etc/airtime.conf are correct and the Airtime database was installed correctly. + are correct and the Airtime database was installed correctly. @@ -158,7 +158,7 @@ $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 are correct. Try using sudo rabbitmqctl list_users and sudo rabbitmqctl list_vhosts to see if the airtime user (or your custom RabbitMQ user) exists, then checking that sudo rabbitmqctl list_exchanges contains entries for airtime-pypo and airtime-uploads. diff --git a/legacy/application/configs/constants.php b/legacy/application/configs/constants.php index 822889bbc..08d03a5c2 100644 --- a/legacy/application/configs/constants.php +++ b/legacy/application/configs/constants.php @@ -1,5 +1,34 @@ _bootstrap->getResource('view'); - $view->addHelperPath(APPLICATION_PATH . 'views/helpers', 'Airtime_View_Helper'); + $view->addHelperPath(APPLICATION_PATH . '/views/helpers', 'Airtime_View_Helper'); } protected function _initTitle() diff --git a/legacy/application/layouts/scripts/layout.phtml b/legacy/application/layouts/scripts/layout.phtml index 12f3c3eeb..808479d1f 100644 --- a/legacy/application/layouts/scripts/layout.phtml +++ b/legacy/application/layouts/scripts/layout.phtml @@ -64,7 +64,7 @@ - +
diff --git a/legacy/application/modules/rest/controllers/PodcastController.php b/legacy/application/modules/rest/controllers/PodcastController.php index 234514689..d670e629f 100644 --- a/legacy/application/modules/rest/controllers/PodcastController.php +++ b/legacy/application/modules/rest/controllers/PodcastController.php @@ -8,7 +8,7 @@ class Rest_PodcastController extends Zend_Rest_Controller // Remove reliance on .phtml files to render requests $this->_helper->viewRenderer->setNoRender(true); - $this->view->setScriptPath(APPLICATION_PATH . 'views/scripts/'); + $this->view->setScriptPath(APPLICATION_PATH . '/views/scripts/'); } /** diff --git a/legacy/application/preload.php b/legacy/application/preload.php new file mode 100644 index 000000000..7e36bae90 --- /dev/null +++ b/legacy/application/preload.php @@ -0,0 +1,7 @@ +
- +
csrf ?> diff --git a/legacy/build/airtime-setup/forms/database-settings.php b/legacy/build/airtime-setup/forms/database-settings.php index 344017679..ffdb2f30e 100644 --- a/legacy/build/airtime-setup/forms/database-settings.php +++ b/legacy/build/airtime-setup/forms/database-settings.php @@ -1,9 +1,9 @@
diff --git a/legacy/build/airtime-setup/forms/finish-settings.php b/legacy/build/airtime-setup/forms/finish-settings.php index 325c3105c..2f119f1d1 100644 --- a/legacy/build/airtime-setup/forms/finish-settings.php +++ b/legacy/build/airtime-setup/forms/finish-settings.php @@ -11,16 +11,16 @@ sudo systemctl start libretime-api sudo systemctl start libretime-celery sudo systemctl start libretime-liquidsoap -sudo systemctl start libretime-playout

Click "Done!" to bring up the Libretime configuration checklist; if your configuration is all green, you're ready to get started with your personal Libretime station!

- If you need to re-run the web installer, just remove /etc/airtime/airtime.conf. + If you need to re-run the web installer, just remove .

- +
diff --git a/legacy/build/airtime-setup/forms/rabbitmq-settings.php b/legacy/build/airtime-setup/forms/rabbitmq-settings.php index aef86ea8c..89dc2f74d 100644 --- a/legacy/build/airtime-setup/forms/rabbitmq-settings.php +++ b/legacy/build/airtime-setup/forms/rabbitmq-settings.php @@ -1,9 +1,9 @@
diff --git a/legacy/build/airtime-setup/load.php b/legacy/build/airtime-setup/load.php index 1f68e090e..4502274b5 100644 --- a/legacy/build/airtime-setup/load.php +++ b/legacy/build/airtime-setup/load.php @@ -92,7 +92,7 @@ function checkDatabaseConfiguration() */ function configureDatabase() { - Propel::init(CONFIG_PATH . 'airtime-conf-production.php'); + Propel::init(PROPEL_CONFIG_FILEPATH); } /** @@ -102,11 +102,11 @@ function configureDatabase() */ function checkRMQConnection() { - // Check for airtime.conf in /etc/airtime/ first, then check in the build directory, - if (file_exists(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG)) { - $ini = parse_ini_file(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG, true); + // Check for installed config file first, then check in the build directory, + if (file_exists(LIBRETIME_CONFIG_FILEPATH)) { + $ini = parse_ini_file(LIBRETIME_CONFIG_FILEPATH, true); } else { - $ini = parse_ini_file(BUILD_PATH . 'airtime.example.conf', true); + $ini = parse_ini_file(SAMPLE_CONFIG_FILEPATH, true); } $conn = new \PhpAmqpLib\Connection\AMQPStreamConnection( diff --git a/legacy/build/airtime-setup/setup-config.php b/legacy/build/airtime-setup/setup-config.php index d58fc7031..87ad35a9c 100644 --- a/legacy/build/airtime-setup/setup-config.php +++ b/legacy/build/airtime-setup/setup-config.php @@ -1,4 +1,7 @@ @@ -23,27 +26,27 @@
diff --git a/legacy/public/index.php b/legacy/public/index.php index 44855fccc..b5a72d57e 100644 --- a/legacy/public/index.php +++ b/legacy/public/index.php @@ -1,5 +1,7 @@ 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'); } } diff --git a/legacy/public/setup/general-setup.php b/legacy/public/setup/general-setup.php index 901b2245a..9353d5f42 100644 --- a/legacy/public/setup/general-setup.php +++ b/legacy/public/setup/general-setup.php @@ -1,25 +1,5 @@ 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; diff --git a/legacy/public/setup/media-setup.php b/legacy/public/setup/media-setup.php index 5b564d3bc..57a9d62a6 100644 --- a/legacy/public/setup/media-setup.php +++ b/legacy/public/setup/media-setup.php @@ -1,26 +1,5 @@ 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!"; diff --git a/legacy/public/setup/setup-functions.php b/legacy/public/setup/setup-functions.php index 177fbb49d..8fc546c1b 100644 --- a/legacy/public/setup/setup-functions.php +++ b/legacy/public/setup/setup-functions.php @@ -1,13 +1,6 @@ _write(AIRTIME_CONF_TEMP_PATH); + //Logging::info(CONFIG_TEMP_FILEPATH); + $this->_write(INSTALLER_CONFIG_FILEPATH); } protected function _write($filePath) diff --git a/legacy/tests/application/bootstrap.php b/legacy/tests/application/bootstrap.php index e6f160475..9cefaa7ca 100644 --- a/legacy/tests/application/bootstrap.php +++ b/legacy/tests/application/bootstrap.php @@ -2,19 +2,7 @@ error_reporting(E_ALL | E_STRICT); -// load composer autoloader -require_once __DIR__ . '/../../vendor/autoload.php'; - -// Define path to application directory -defined('APPLICATION_PATH') - || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application/')); - -// Define path to configs directory -define('CONFIG_PATH', APPLICATION_PATH . '/configs/'); - -// Define application environment -defined('APPLICATION_ENV') - || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing')); +require_once dirname(__DIR__, 2) . '/application/preload.php'; // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, [ @@ -46,9 +34,7 @@ set_include_path(implode(PATH_SEPARATOR, [ realpath(APPLICATION_PATH . '/../../install_minimal/include'), ])); -require_once CONFIG_PATH . '/constants.php'; - -Logging::setLogPath(LIBRETIME_LOG_DIR . '/legacy.log'); +Logging::setLogPath(LIBRETIME_LOG_FILEPATH); set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path()); @@ -76,8 +62,6 @@ set_include_path(APPLICATION_PATH . '/../tests/application/helpers' . PATH_SEPAR //cloud storage files set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path()); -require_once APPLICATION_PATH . '/configs/conf.php'; - require_once 'jooola/propel1/runtime/lib/Propel.php'; Propel::init('../application/configs/airtime-conf-production.php'); diff --git a/legacy/tests/application/configs/ConfigTest.php b/legacy/tests/application/configs/ConfigTest.php index b0617a5cb..57a97aacb 100644 --- a/legacy/tests/application/configs/ConfigTest.php +++ b/legacy/tests/application/configs/ConfigTest.php @@ -1,7 +1,5 @@ bootstrap(); return $application; diff --git a/legacy/tests/application/models/database/BlockDbTest.php b/legacy/tests/application/models/database/BlockDbTest.php index 65978f5ec..9d70cee5e 100644 --- a/legacy/tests/application/models/database/BlockDbTest.php +++ b/legacy/tests/application/models/database/BlockDbTest.php @@ -1,7 +1,5 @@ - - + + + diff --git a/legacy/tests/runtests.sh b/legacy/tests/runtests.sh index ed9ca7624..7d9b195e4 100755 --- a/legacy/tests/runtests.sh +++ b/legacy/tests/runtests.sh @@ -26,7 +26,7 @@ export RABBITMQ_USER export RABBITMQ_PASSWORD export RABBITMQ_VHOST -export AIRTIME_UNIT_TEST="1" +export LIBRETIME_UNIT_TEST="1" #Change the working directory to this script's directory DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd)"