More logs
This commit is contained in:
@@ -24,10 +24,10 @@ class Provision extends BaseController
|
|||||||
log_message('critical', "***** ***** prepareProvision :: Working Database " . $current_database);
|
log_message('critical', "***** ***** prepareProvision :: Working Database " . $current_database);
|
||||||
|
|
||||||
log_message('critical', "***** ***** prepareProvision :: Starting Port Allocation ");
|
log_message('critical', "***** ***** prepareProvision :: Starting Port Allocation ");
|
||||||
$this->allocatePortNo(); // allocte port for the conyainer use
|
$this->allocatePortNo(); // allocate port for the container use
|
||||||
|
|
||||||
log_message('critical', "***** ***** prepareProvision :: Starting Product Database if Needed ");
|
log_message('critical', "***** ***** prepareProvision :: Starting Product Database if Needed ");
|
||||||
$this->prepareDataBase(); // allocte port for the conyainer use
|
$this->prepareDataBase(); // allocate port for the container use
|
||||||
|
|
||||||
log_message('critical', "***** ***** prepareProvision :: Create needed DockerCompose Files ");
|
log_message('critical', "***** ***** prepareProvision :: Create needed DockerCompose Files ");
|
||||||
$this->updateProvision();
|
$this->updateProvision();
|
||||||
@@ -47,7 +47,7 @@ class Provision extends BaseController
|
|||||||
//PROVISION_MSQL_DATABASE="wordpress"
|
//PROVISION_MSQL_DATABASE="wordpress"
|
||||||
//PROVISION_MSQL_DATABASE_PORT="3307"
|
//PROVISION_MSQL_DATABASE_PORT="3307"
|
||||||
|
|
||||||
private function prepareDataBase(): string
|
private function prepareDataBase(): void
|
||||||
{
|
{
|
||||||
$servername = $_ENV['PROVISION_MSQL_DATABASE_IP'] . ":" . $_ENV['PROVISION_MSQL_DATABASE_PORT']; // "172.16.4.96:3307";
|
$servername = $_ENV['PROVISION_MSQL_DATABASE_IP'] . ":" . $_ENV['PROVISION_MSQL_DATABASE_PORT']; // "172.16.4.96:3307";
|
||||||
$database = $_ENV['PROVISION_MSQL_DATABASE']; //"wordpress";
|
$database = $_ENV['PROVISION_MSQL_DATABASE']; //"wordpress";
|
||||||
@@ -76,8 +76,7 @@ class Provision extends BaseController
|
|||||||
$productId = $pr->product_id;
|
$productId = $pr->product_id;
|
||||||
$provisionUID = $pr->uid;
|
$provisionUID = $pr->uid;
|
||||||
$ContainerName = $this->generatedContainerName($productId, $pr->id); // $productId . str_pad($pr->id, 10, "0", STR_PAD_LEFT);
|
$ContainerName = $this->generatedContainerName($productId, $pr->id); // $productId . str_pad($pr->id, 10, "0", STR_PAD_LEFT);
|
||||||
|
$dbName = $this->generatedBlogDatabaseName($productId, $pr->id); // $ContainerName;
|
||||||
$dbName = $ContainerName;
|
|
||||||
// Create database
|
// Create database
|
||||||
$sql = "CREATE DATABASE $dbName";
|
$sql = "CREATE DATABASE $dbName";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
@@ -89,9 +88,14 @@ class Provision extends BaseController
|
|||||||
|
|
||||||
$query = $this->db->query($mysql);
|
$query = $this->db->query($mysql);
|
||||||
|
|
||||||
$sql = "CREATE USER '" . $dbName . "'@'localhost' IDENTIFIED BY '" . $provisionUID . "'";
|
// $sql = "CREATE USER '" . $dbName . "'@'localhost' IDENTIFIED BY '" . $provisionUID . "'";
|
||||||
|
$sql = "CREATE USER '" . $dbName . "'@'%' IDENTIFIED BY '" . $provisionUID . "'";
|
||||||
$result = mysqli_query($conn, $sql);
|
$result = mysqli_query($conn, $sql);
|
||||||
$sql = "GRANT SELECT , INSERT , UPDATE , DELETE ON " . $dbName . " . * TO '" . $dbName . "'@'localhost' IDENTIFIED BY '" . $provisionUID . "'";
|
|
||||||
|
// $sql = "GRANT SELECT , INSERT , UPDATE , DELETE ON " . $dbName . " . * TO '" . $dbName . "'@'localhost' IDENTIFIED BY '" . $provisionUID . "'";
|
||||||
|
$sql = "GRANT CREATE, SELECT , INSERT , UPDATE , DELETE ON " . $dbName . " . * TO '" . $dbName . "'@'localhost' IDENTIFIED BY '" . $provisionUID . "'";
|
||||||
|
log_message('critical', "***** ***** prepareDataBase :: GrantQuery === ".$sql);
|
||||||
|
|
||||||
$result = mysqli_query($conn, $sql);
|
$result = mysqli_query($conn, $sql);
|
||||||
|
|
||||||
$mysql = "UPDATE members_products SET updated=now(), db_status = db_status + 1 WHERE uid::TEXT = '" . $provisionUID . "'";
|
$mysql = "UPDATE members_products SET updated=now(), db_status = db_status + 1 WHERE uid::TEXT = '" . $provisionUID . "'";
|
||||||
@@ -107,7 +111,6 @@ class Provision extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mysqli_close($conn);
|
mysqli_close($conn);
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generatedContainerName($productId, $provID)
|
private function generatedContainerName($productId, $provID)
|
||||||
@@ -370,7 +373,7 @@ class Provision extends BaseController
|
|||||||
$composer_template_contents = str_replace("WHAT_CONTAINER_NAME", $ContainerName, $composer_template_contents);
|
$composer_template_contents = str_replace("WHAT_CONTAINER_NAME", $ContainerName, $composer_template_contents);
|
||||||
$composer_template_contents = str_replace("DESTINATION_FOLDER", $destinationHomeFolder, $composer_template_contents);
|
$composer_template_contents = str_replace("DESTINATION_FOLDER", $destinationHomeFolder, $composer_template_contents);
|
||||||
$composer_template_contents = str_replace("ALLOCATED_PORT", $allocatedPort, $composer_template_contents);
|
$composer_template_contents = str_replace("ALLOCATED_PORT", $allocatedPort, $composer_template_contents);
|
||||||
// $composer_template_contents = str_replace("CNT_DB_NAME", $ContainerName, $composer_template_contents);
|
// $composer_template_contents = str_replace("CNT_DB_NAME", $ContainerName, $composer_template_contents);
|
||||||
$composer_template_contents = str_replace("CNT_DB_NAME", $CNT_DB_NAME, $composer_template_contents);
|
$composer_template_contents = str_replace("CNT_DB_NAME", $CNT_DB_NAME, $composer_template_contents);
|
||||||
$composer_template_contents = str_replace("CNT_DB_USER_NAME", $CNT_DB_USER_NAME, $composer_template_contents);
|
$composer_template_contents = str_replace("CNT_DB_USER_NAME", $CNT_DB_USER_NAME, $composer_template_contents);
|
||||||
$composer_template_contents = str_replace("CNT_DB_PASS", $provisionUID, $composer_template_contents);
|
$composer_template_contents = str_replace("CNT_DB_PASS", $provisionUID, $composer_template_contents);
|
||||||
|
|||||||
Reference in New Issue
Block a user