More work on web installer
This commit is contained in:
parent
9fed113f74
commit
f5b4928538
23 changed files with 728 additions and 186 deletions
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
define("BUILD_PATH", dirname(dirname( __DIR__)) . "/build/");
|
||||
define("AIRTIME_CONF_TEMP_PATH", "/tmp/airtime.conf.temp");
|
||||
|
||||
/**
|
||||
* Class Setup
|
||||
*
|
||||
|
@ -11,6 +14,34 @@ abstract class Setup {
|
|||
|
||||
abstract function runSetup();
|
||||
|
||||
protected function writeToTemp($section, $properties) {
|
||||
if (!file_exists(AIRTIME_CONF_TEMP_PATH)) {
|
||||
copy(BUILD_PATH . "airtime.example.conf", AIRTIME_CONF_TEMP_PATH);
|
||||
}
|
||||
|
||||
$file = file(AIRTIME_CONF_TEMP_PATH);
|
||||
$fileOutput = "";
|
||||
|
||||
$inSection = false;
|
||||
|
||||
foreach($file as $line) {
|
||||
if(strpos($line, $section) !== false) {
|
||||
$inSection = true;
|
||||
} else if (strpos($line, "[") !== false) {
|
||||
$inSection = false;
|
||||
}
|
||||
|
||||
if ($inSection) {
|
||||
$key = trim(@substr($line, 0, strpos($line, "=")));
|
||||
$fileOutput .= $key && isset($properties[$key]) ? $key . " = " . $properties[$key] . "\n" : $line;
|
||||
} else {
|
||||
$fileOutput .= $line;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(AIRTIME_CONF_TEMP_PATH, $fileOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random string.
|
||||
*
|
||||
|
@ -18,8 +49,7 @@ abstract class Setup {
|
|||
* @param string $p_chars characters to use in the output string
|
||||
* @return string the generated random string
|
||||
*/
|
||||
protected function generateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||
{
|
||||
protected function generateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') {
|
||||
$string = '';
|
||||
for ($i = 0; $i < $p_len; $i++)
|
||||
{
|
||||
|
@ -31,11 +61,16 @@ abstract class Setup {
|
|||
|
||||
}
|
||||
|
||||
// Import Setup subclasses
|
||||
|
||||
require_once('database-setup.php');
|
||||
require_once('rabbitmq-setup.php');
|
||||
require_once('general-setup.php');
|
||||
require_once('media-setup.php');
|
||||
require_once('finish-setup.php');
|
||||
|
||||
// If airtime.conf exists, we shouldn't be here
|
||||
if (!file_exists(dirname(dirname(__DIR__)) . '/build/airtime.conf')) {
|
||||
if (!file_exists("/etc/airtime/airtime.conf")) {
|
||||
if (isset($_GET["obj"]) && $objType = $_GET["obj"]) {
|
||||
$obj = new $objType($_POST);
|
||||
if ($obj instanceof Setup) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue