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 :: 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 ");
|
||||
$this->prepareDataBase(); // allocte port for the conyainer use
|
||||
$this->prepareDataBase(); // allocate port for the container use
|
||||
|
||||
log_message('critical', "***** ***** prepareProvision :: Create needed DockerCompose Files ");
|
||||
$this->updateProvision();
|
||||
@@ -47,7 +47,7 @@ class Provision extends BaseController
|
||||
//PROVISION_MSQL_DATABASE="wordpress"
|
||||
//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";
|
||||
$database = $_ENV['PROVISION_MSQL_DATABASE']; //"wordpress";
|
||||
@@ -76,8 +76,7 @@ class Provision extends BaseController
|
||||
$productId = $pr->product_id;
|
||||
$provisionUID = $pr->uid;
|
||||
$ContainerName = $this->generatedContainerName($productId, $pr->id); // $productId . str_pad($pr->id, 10, "0", STR_PAD_LEFT);
|
||||
|
||||
$dbName = $ContainerName;
|
||||
$dbName = $this->generatedBlogDatabaseName($productId, $pr->id); // $ContainerName;
|
||||
// Create database
|
||||
$sql = "CREATE DATABASE $dbName";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
@@ -89,9 +88,14 @@ class Provision extends BaseController
|
||||
|
||||
$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);
|
||||
$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);
|
||||
|
||||
$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);
|
||||
return '';
|
||||
}
|
||||
|
||||
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("DESTINATION_FOLDER", $destinationHomeFolder, $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_USER_NAME", $CNT_DB_USER_NAME, $composer_template_contents);
|
||||
$composer_template_contents = str_replace("CNT_DB_PASS", $provisionUID, $composer_template_contents);
|
||||
|
||||
Reference in New Issue
Block a user