feat: remove php web installer

This commit is contained in:
jo 2022-04-29 14:43:45 +02:00 committed by Kyle Robbertze
parent eb8e7b3415
commit 0d16960887
15 changed files with 7 additions and 1063 deletions

View file

@ -1,49 +0,0 @@
<?php
$tempConfigPath = INSTALLER_CONFIG_FILEPATH;
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$db = $airtimeConfig['database'];
}
?>
<form action="#" role="form" id="dbSettingsForm">
<h3 class="form-title">Database Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Enter your Airtime database settings here. Empty or non-existent databases will be created and populated
if the given user has administrative permissions in postgres.
</p>
<div class="form-group">
<label class="control-label" for="dbUser">Username</label>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username" value="<?php echo isset($db) ? $db['user'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbPass">Password</label>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password" value="<?php echo isset($db) ? $db['password'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbName">Name</label>
<input required class="form-control" type="text" name="dbName" id="dbName" placeholder="Name" value="<?php echo isset($db) ? $db['name'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbHost">Host</label>
<input required class="form-control" type="text" name="dbHost" id="dbHost" placeholder="Host" value="<?php echo isset($db) ? $db['host'] : 'localhost'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="dbErr" id="dbErr" aria-describedby="helpBlock" />
<div>
<p style="text-align:right">
This may take up to 30 seconds to complete!
</p>
<input type="submit" formtarget="dbSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;" />
</div>
</form>
<script>
$("#dbSettingsForm").submit(function(e) {
submitForm(e, "DatabaseSetup");
});
</script>

View file

@ -1,32 +0,0 @@
<?php
?>
<form action="#" role="form" id="finishSettingsForm">
<h3 class="form-title">Manual Step: Start Libretime Services</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Looks like you're almost done! As a final step, please run the following commands from the terminal:
</p>
<pre style="text-align: left">sudo systemctl start libretime-analyzer
sudo systemctl start libretime-api
sudo systemctl start libretime-celery
sudo systemctl start libretime-liquidsoap
sudo systemctl start libretime-playout</pre>
<p>
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!
</p>
<p>
If you need to re-run the web installer, just remove <code><?php echo LIBRETIME_CONFIG_FILEPATH; ?></code>.
</p>
<div>
<input type="submit" formtarget="finishSettingsForm" class="btn btn-primary btn-next" value="Done!" />
</div>
</form>
<script>
$("#finishSettingsForm").submit(function(e) {
e.preventDefault();
window.location.assign("/?config");
});
</script>

View file

@ -1,43 +0,0 @@
<?php
?>
<form action="#" role="form" id="generalSettingsForm">
<h3 class="form-title">General Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<div id="generalFormBody">
<div class="form-group">
<label class="control-label" for="publicUrl">Public URL</label>
<input required class="form-control" type="text" name="publicUrl" id="publicUrl" placeholder="https://example.com/" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="generalErr" id="generalErr" aria-describedby="helpBlock" />
<hr />
<p>
The CORS URL can be setup during install if you are accessing your LibreTime instance behind a Proxy.
This is common with docker setups. If you have a reverse proxy setup enter the URL below, otherwise you
can safely ignore this. Please enter one URL per line. Include the entire URL such as http://example.com
If you are reinstalling LibreTime on an existing setup you can ignore this as well,
the settings in your existing database will be retained unless you enter new values below.
</p>
<div class="form-group">
<label class="control-label" for="corsUrl">CORS URLs</label>
<textarea name="corsUrl" class="form-control" id="corsUrl" rows="4" cols="50"></textarea>
</div>
</div>
<div>
<input type="submit" formtarget="generalSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;" />
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back" />
</div>
</form>
<script>
$("#publicUrl").val(function() {
return window.location.href;
});
$("#corsUrl").text(function() {
return window.location.origin;
});
$("#generalSettingsForm").submit(function(e) {
submitForm(e, "GeneralSetup");
});
</script>

View file

@ -1,30 +0,0 @@
<?php
?>
<form action="#" role="form" id="mediaSettingsForm">
<h3 class="form-title">Media Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Here you can set the default media storage directory for Airtime. If left blank, we'll create a new
directory located at <code><?php echo INSTALLER_DEFAULT_STORAGE_PATH; ?></code> for you.
</p>
<div class="form-group">
<label class="control-label" for="mediaFolder">Media folder</label>
<input class="form-control" type="text" name="mediaFolder" id="mediaFolder" placeholder="/path/to/my/music/directory/" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="mediaHelpBlock" class="help-block">
Note that you need to enter the <strong>fully qualified</strong> path name!
</span>
</div>
<input class="form-control" type="hidden" name="mediaErr" id="mediaErr" aria-describedby="helpBlock"/>
<div>
<input type="submit" formtarget="mediaSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#mediaSettingsForm").submit(function(e) {
submitForm(e, "MediaSetup");
});
</script>

View file

@ -1,77 +0,0 @@
<?php
$tempConfigPath = INSTALLER_CONFIG_FILEPATH;
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$rmq = $airtimeConfig['rabbitmq'];
}
?>
<form action="#" role="form" id="rmqSettingsForm">
<h3 class="form-title">RabbitMQ Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
RabbitMQ is an AMQP-based messaging system used by Libretime. You should only edit these settings
if you have changed the defaults since running the installer, or if you've opted to install RabbitMQ manually.
</p>
<p>
In either case, we recommend that you change at least the default password provided -
you can do this by running the following line from the command line:<br/>
<code>sudo rabbitmqctl change_password &lt;username&gt; &lt;newpassword&gt;</code><br/>
<strong>Notice:</strong> using special characters such as ! in your rabbitmq password will cause LibreTime to fail
to load properly after setup. Please use alphanumerical characters only.
</p>
<div id="rmqSlideToggle">
<span><strong>Advanced </strong></span><span id="advCaret" class="caret"></span><hr/>
</div>
<div id="rmqFormBody">
<div class="form-group">
<label class="control-label" for="rmqUser">Username</label>
<input required class="form-control" type="text" name="rmqUser" id="rmqUser" placeholder="Username"
value="<?php echo isset($rmq) ? $rmq['user'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPass">Password</label>
<input class="form-control" type="password" name="rmqPass" id="rmqPass" placeholder="Password"
value="<?php echo isset($rmq) ? $rmq['password'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="rmqHelpBlock" class="help-block">
You probably want to change this!
</span>
</div>
<div class="form-group">
<label class="control-label" for="rmqHost">Host</label>
<input required class="form-control" type="text" name="rmqHost" id="rmqHost" placeholder="Host"
value="<?php echo isset($rmq) ? $rmq['host'] : '127.0.0.1'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPort">Port</label>
<input required class="form-control" type="text" name="rmqPort" id="rmqPort" placeholder="Port"
value="<?php echo isset($rmq) ? $rmq['port'] : '5672'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqVHost">Virtual Host</label>
<input required class="form-control" type="text" name="rmqVHost" id="rmqVHost" placeholder="VHost"
value="<?php echo isset($rmq) ? $rmq['vhost'] : '/airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="rmqErr" id="rmqErr" aria-describedby="helpBlock"/>
</div>
<div>
<input type="submit" formtarget="rmqSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#rmqSlideToggle").click(function() {
$("#rmqFormBody").slideToggle(500);
$("#advCaret").toggleClass("caret-up");
});
$("#rmqSettingsForm").submit(function(e) {
submitForm(e, "RabbitMQSetup");
});
</script>

View file

@ -1,174 +0,0 @@
<?php
function booleanReduce($a, $b)
{
return $a && $b;
}
/**
* Check to see if Airtime is properly configured.
*
* @return bool true if all Airtime dependencies and services are
* properly configured and running
*/
function checkConfiguration()
{
$r1 = array_reduce(checkPhpDependencies(), 'booleanReduce', true);
$r2 = array_reduce(checkExternalServices(), 'booleanReduce', true);
return $r1 && $r2;
}
/**
* Check for Airtime's PHP dependencies and return an associative
* array with the results.
*
* @return array associative array of dependency check results
*/
function checkPhpDependencies()
{
return [
'postgres' => checkDatabaseDependencies(),
];
}
/**
* Check that the PHP dependencies for the database exist.
*
* @return bool true if the database dependencies exist
*/
function checkDatabaseDependencies()
{
global $extensions;
// Check the PHP extension list for the Postgres db extensions
return in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions);
}
/**
* Check that all external services are configured correctly and return an associative
* array with the results.
*
* @return array associative array of external service check results
*/
function checkExternalServices()
{
return [
'database' => checkDatabaseConfiguration(),
'analyzer' => checkAnalyzerService(),
'pypo' => checkPlayoutService(),
'liquidsoap' => checkLiquidsoapService(),
'rabbitmq' => checkRMQConnection(),
'celery' => checkCeleryService(),
'api' => checkApiService(),
];
}
/**
* Check the database configuration by fetching a connection from Propel.
*
* @return bool true if a connection is made to the database
*/
function checkDatabaseConfiguration()
{
configureDatabase();
try {
// Try to establish a database connection. If something goes
// wrong, the database is improperly configured
Propel::getConnection();
Propel::close();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Initialize Propel to configure the Airtime database.
*/
function configureDatabase()
{
Propel::init(PROPEL_CONFIG_FILEPATH);
}
/**
* Check that we can connect to RabbitMQ.
*
* @return true if the RabbitMQ connection can be established
*/
function checkRMQConnection()
{
$config = Config::getConfig();
$conn = new \PhpAmqpLib\Connection\AMQPStreamConnection(
$config['rabbitmq']['host'],
$config['rabbitmq']['port'],
$config['rabbitmq']['user'],
$config['rabbitmq']['password'],
$config['rabbitmq']['vhost']
);
return isset($conn);
}
/**
* Check if airtime-analyzer is currently running.
*
* @return bool true if airtime-analyzer is running
*/
function checkAnalyzerService()
{
exec('systemctl is-active libretime-analyzer --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-playout is currently running.
*
* @return bool true if libretime-playout is running
*/
function checkPlayoutService()
{
exec('systemctl is-active libretime-playout --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-liquidsoap is currently running.
*
* @return bool true if libretime-liquidsoap is running
*/
function checkLiquidsoapService()
{
exec('systemctl is-active libretime-liquidsoap --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-celery is currently running.
*
* @return bool true if libretime-celery is running
*/
function checkCeleryService()
{
exec('systemctl is-active libretime-celery --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-api is currently running.
*
* @return bool true if libretime-api is running
*/
function checkApiService()
{
exec('systemctl status libretime-api --quiet', $out, $status);
return $status == 0;
}

View file

@ -1,60 +0,0 @@
<?php
require_once dirname(__DIR__, 2) . '/application/preload.php';
?>
<html>
<head>
<script type="text/javascript" src="js/libs/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui-1.8.24.min.js"></script>
<script type="text/javascript" src="js/setup/setup-config.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap-3.3.1.min.css" />
<link rel="stylesheet" type="text/css" href="css/setup/setup-config.css" />
</head>
<body>
<div class="header">
<h3 class="logo">
<img src="css/images/libretime_logo_jp.png" id="LibreTimeLogo" /><br/>
<strong>Setup</strong>
</h3>
<strong>Step <span id="stepCount">1</span> of 5</strong>
</div>
<div class="viewport">
<div class="form-slider">
<div id="databaseSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . '/forms/database-settings.php';
?>
</div>
<div id="rabbitmqSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . '/forms/rabbitmq-settings.php';
?>
</div>
<div id="generalSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . '/forms/general-settings.php';
?>
</div>
<div id="mediaSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . '/forms/media-settings.php';
?>
</div>
<div id="finishSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . '/forms/finish-settings.php';
?>
</div>
</div>
</div>
<script>
$(".btn-skip").click(nextSlide);
$(".btn-back").click(prevSlide);
</script>
</body>
</html>