From 0a14a6315b7b421debb5db20d70fe5f284d44520 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 15 Sep 2025 14:02:24 -0400 Subject: [PATCH] Added function for template prepare --- app/Controllers/Provision.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Controllers/Provision.php b/app/Controllers/Provision.php index 1a61c8c..72440a6 100644 --- a/app/Controllers/Provision.php +++ b/app/Controllers/Provision.php @@ -214,6 +214,28 @@ class Provision extends BaseController return 0; } + private function prepareTemplateFile($composer_template_contents, $ContainerName, $allocatedPort, $provisionUID): string + { + + $SITE_CONTENTS_GATEWAY = $_ENV['SITE_CONTENTS_GATEWAY']; + $SITE_CONTACT_GATEWAY = $_ENV['SITE_CONTACT_GATEWAY']; + $MYSQL_PROVISION_DATABASE_PORT = $_ENV['PROVISION_MSQL_DATABASE_IP'] . ":" . $_ENV['PROVISION_MSQL_DATABASE_PORT']; // "172.16.4.96:3307"; + $destinationHomeFolder = $_ENV['DESTINATION_HOME_FOLDER'] . $ContainerName; + $templateRandom = 'P' . rand(1, 6); + + $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_PASS", $provisionUID, $composer_template_contents); + $composer_template_contents = str_replace("CNT_DB_DATA", $MYSQL_PROVISION_DATABASE_PORT, $composer_template_contents); + $composer_template_contents = str_replace("PROVISION_UID_REPLACE", $provisionUID, $composer_template_contents); + $composer_template_contents = str_replace("PROVISION_IMAGE_NAME_REPLACE", "registry.chiefsoft.com/pweb/pweb-01-merms-pweb0006c:latest", $composer_template_contents); + $composer_template_contents = str_replace("SITE_CONTENTS_URL_REPLACE", $SITE_CONTENTS_GATEWAY, $composer_template_contents); + $composer_template_contents = str_replace("SITE_CONTACT_URL_REPLACE", $SITE_CONTACT_GATEWAY, $composer_template_contents); + $composer_template_contents = str_replace("TEMPLATE_NAME_REPLACE", $templateRandom, $composer_template_contents); + return $composer_template_contents; + } + private function scheduleRefreshAction() { $mysql = "SELECT * FROM member_product_refresh WHERE product_id IN ('A000001','A000002') AND status =0 LIMIT 1";