From 1bc238dabd45249fbfd326d1c72937d281850b6d Mon Sep 17 00:00:00 2001 From: Wildan M Date: Thu, 13 Jun 2024 01:35:28 +0700 Subject: [PATCH] Fix db not triggered subdomain --- src/executor/runnersub.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/executor/runnersub.js b/src/executor/runnersub.js index 00646a2..4ee314c 100644 --- a/src/executor/runnersub.js +++ b/src/executor/runnersub.js @@ -56,7 +56,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, } if (value === "off") { await writeLog("$> Disabling MySQL"); - if (enabled) { + if (subenabled) { await virtExec("disable-feature", value, { subdomain, mysql: true, @@ -66,7 +66,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, } break; } - if (!enabled) { + if (!subenabled) { await writeLog("$> Enabling MySQL"); await virtExec("enable-feature", value, { subdomain, @@ -79,15 +79,14 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, dbname = getDbName(domaindata['Username'], domainprefix == "db" ? newdb : domainprefix + '_' + newdb); dbneedcreate = true; } - if (!dbneedcreate) { - break; + if (dbneedcreate) { + await writeLog(`$> Creating db instance ${dbname} on MySQL`); + await virtExec("create-database", { + subdomain, + name: dbname, + type: 'mysql', + }); } - await writeLog(`$> Creating db instance ${dbname} on MySQL`); - await virtExec("create-database", { - subdomain, - name: dbname, - type: 'mysql', - }); break; case 'postgres': if (!stillroot && !enabled) { @@ -96,7 +95,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, } if (value === "off") { await writeLog("$> Disabling PostgreSQL"); - if (enabled) { + if (subenabled) { await virtExec("disable-feature", value, { subdomain, postgres: true, @@ -106,7 +105,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, } break; } - if (!enabled) { + if (!subenabled) { await writeLog("$> Enabling PostgreSQL"); await virtExec("enable-feature", value, { subdomain, @@ -119,15 +118,15 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, dbname = getDbName(domaindata['Username'], domainprefix == "db" ? newdb : domainprefix + '_' + newdb); dbneedcreate = true; } - if (!dbneedcreate) { - break; + if (dbneedcreate) { + await writeLog(`$> Creating db instance ${dbname} on PostgreSQL`); + await virtExec("create-database", { + subdomain, + name: dbname, + type: 'postgres', + } + ); } - await writeLog(`$> Creating db instance ${dbname} on PostgreSQL`); - await virtExec("create-database", { - subdomain, - name: dbname, - type: 'postgres', - }); break; case 'dns': if (!stillroot && !enabled) {