Fixed a bug in the server handler app.js
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
const {Client} = require("ssh2");
|
const {Client} = require("ssh2");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const {getReleaseInformation} = require("../controller/shell");
|
||||||
|
|
||||||
const services = fs.readdirSync(__dirname + "/apps").map((item) => item.replace(".js", ""));
|
const services = fs.readdirSync(__dirname + "/apps").map((item) => item.replace(".js", ""));
|
||||||
module.exports = (io, socket) => {
|
module.exports = (io, socket) => {
|
||||||
@ -40,11 +41,11 @@ module.exports = (io, socket) => {
|
|||||||
socket.emit("install", {status: "success", step});
|
socket.emit("install", {status: "success", step});
|
||||||
queue.shift();
|
queue.shift();
|
||||||
execQueue();
|
execQueue();
|
||||||
}).on("data", () => {});
|
}).on("data", (e) => {console.log(e.toString())});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on("install", (msg) => {
|
socket.on("install", async (msg) => {
|
||||||
if (!connected) return socket.emit("install", {status: "failed", message: "Not connected"});
|
if (!connected) return socket.emit("install", {status: "failed", message: "Not connected"});
|
||||||
if (queue.length > 0) return socket.emit("install", {status: "failed", message: "Another installation is in progress"});
|
if (queue.length > 0) return socket.emit("install", {status: "failed", message: "Another installation is in progress"});
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ module.exports = (io, socket) => {
|
|||||||
|
|
||||||
let infoData = [];
|
let infoData = [];
|
||||||
|
|
||||||
|
const os = (await getReleaseInformation(session, false).catch(() => {}))?.id?.toLowerCase();
|
||||||
|
|
||||||
app.steps.map((mappedItem, index) => {
|
app.steps.map((mappedItem, index) => {
|
||||||
let item = {...mappedItem};
|
let item = {...mappedItem};
|
||||||
Object.keys(app.variables).map((key) => {
|
Object.keys(app.variables).map((key) => {
|
||||||
@ -67,6 +70,8 @@ module.exports = (io, socket) => {
|
|||||||
if (msg?.data[key] !== value) return;
|
if (msg?.data[key] !== value) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.os && item.os !== os) return;
|
||||||
|
|
||||||
if (item.replace) {
|
if (item.replace) {
|
||||||
Object.keys(item.replace).map((key) => {
|
Object.keys(item.replace).map((key) => {
|
||||||
item.command = item.command.replace(new RegExp(`{${key}}`, "g"), item.replace[key]());
|
item.command = item.command.replace(new RegExp(`{${key}}`, "g"), item.replace[key]());
|
||||||
|
Reference in New Issue
Block a user