Exported DB Socket to frontend during setup page, used only env variable as DB Socket, removed socket checks and let knex handles it

This commit is contained in:
UnwishingMoon 2026-01-18 14:50:12 +01:00
parent 6358a64279
commit c9919756e4
No known key found for this signature in database
GPG Key ID: F3BCA53610DBE6A1
3 changed files with 24 additions and 21 deletions

View File

@ -161,6 +161,7 @@ class SetupDatabase {
runningSetup: this.runningSetup,
needSetup: this.needSetup,
isEnabledEmbeddedMariaDB: this.isEnabledEmbeddedMariaDB(),
isEnabledMariaDBSocket: (process.env.UPTIME_KUMA_DB_SOCKET && process.env.UPTIME_KUMA_DB_SOCKET.trim().length > 0) || false,
});
});
@ -205,22 +206,10 @@ class SetupDatabase {
if (dbConfig.type === "mariadb") {
// If socketPath is provided and not empty, validate it
if (
dbConfig.socketPath &&
typeof dbConfig.socketPath === "string" &&
dbConfig.socketPath.trim().length > 0
process.env.UPTIME_KUMA_DB_SOCKET &&
process.env.UPTIME_KUMA_DB_SOCKET.trim().length > 0
) {
// Checking if the path exists and is a socket
if (!fs.existsSync(dbConfig.socketPath)) {
response.status(400).json("The path to the Socket does not exist");
this.runningSetup = false;
return;
}
if (!fs.lstatSync(dbConfig.socketPath).isSocket()) {
response.status(400).json("The path provided is not a Socket");
this.runningSetup = false;
return;
}
dbConfig.socketPath = process.env.UPTIME_KUMA_DB_SOCKET;
} else {
// socketPath not provided, hostname and port are required
if (!dbConfig.hostname) {

View File

@ -1362,5 +1362,5 @@
"None (Successful Connection)": "None (Successful Connection)",
"expectedTlsAlertDescription": "Select the TLS alert you expect the server to return. Use {code} to verify mTLS endpoints reject connections without client certificates. See {link} for details.",
"TLS Alert Spec": "RFC 8446",
"socketPath": "Path to socket"
"mariadbSocketPathDetectedHelptext": "environment variable detected, Hostname and Port will be ignored."
}

View File

@ -86,21 +86,25 @@
type="text"
class="form-control"
required
:disabled="!disabledButtonMariaDBSocket"
/>
<label for="floatingInput">{{ $t("Hostname") }}</label>
</div>
<div class="form-floating mt-3 short">
<input id="floatingInput" v-model="dbConfig.port" type="text" class="form-control" required />
<input id="floatingInput" v-model="dbConfig.port" type="text" class="form-control" required :disabled="!disabledButtonMariaDBSocket" />
<label for="floatingInput">{{ $t("Port") }}</label>
</div>
<div class="form-floating mt-3 short">
<input id="floatingInput" v-model="dbConfig.socketPath" type="text" class="form-control" />
<label for="floatingInput">{{ $t("socketPath") }} ({{ $t("Optional") }})</label>
<div class="mt-1 short text-start" :hidden="hiddenHelptextMariaDBSocket">
<div class="form-text">
<code>UPTIME_KUMA_DB_SOCKET</code> {{ $t("mariadbSocketPathDetectedHelptext") }}
</div>
</div>
<div class="form-floating mt-3 short">
<hr class="mt-3 short" />
<div class="form-floating mt-2 short">
<input
id="floatingInput"
v-model="dbConfig.username"
@ -204,6 +208,12 @@ export default {
disabledButton() {
return this.dbConfig.type === undefined || this.info.runningSetup;
},
disabledButtonMariaDBSocket() {
return this.info.isEnabledMariaDBSocket === undefined || this.info.isEnabledMariaDBSocket === false;
},
hiddenHelptextMariaDBSocket() {
return this.info.isEnabledMariaDBSocket === undefined || this.info.isEnabledMariaDBSocket === false;
}
},
async mounted() {
let res = await axios.get("/setup-database-info");
@ -213,6 +223,10 @@ export default {
location.href = "/setup";
} else {
this.show = true;
if (this.info.isEnabledMariaDBSocket) {
}
}
},
methods: {