Async functions #169
@ -89,7 +89,7 @@ async function StartServer(){
|
|||||||
process.exit(2)
|
process.exit(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(async () => {
|
||||||
// Bds Maneger CLI Help
|
// Bds Maneger CLI Help
|
||||||
if (help) {
|
if (help) {
|
||||||
let help = [
|
let help = [
|
||||||
@ -129,6 +129,7 @@ if (version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SystemCheck) {
|
if (SystemCheck) {
|
||||||
|
const { valid_platform } = await SystemInfo();
|
||||||
var checkothearch = "";
|
var checkothearch = "";
|
||||||
if (process.platform === "linux" && bds.arch !== "x64"){checkothearch = `qemu-x86_64-static is installed to emulate an x64 system: ${commandExits("qemu-x86_64-static")}\n`}
|
if (process.platform === "linux" && bds.arch !== "x64"){checkothearch = `qemu-x86_64-static is installed to emulate an x64 system: ${commandExits("qemu-x86_64-static")}\n`}
|
||||||
if (process.platform === "android" && bds.arch !== "x64"){checkothearch = `qemu-x86_64 is installed to emulate an x64 system: ${commandExits("qemu-x86_64")}\n`}
|
if (process.platform === "android" && bds.arch !== "x64"){checkothearch = `qemu-x86_64 is installed to emulate an x64 system: ${commandExits("qemu-x86_64")}\n`}
|
||||||
@ -150,11 +151,11 @@ if (SystemCheck) {
|
|||||||
"*",
|
"*",
|
||||||
"**************************************************************",
|
"**************************************************************",
|
||||||
"* Servers currently available:",
|
"* Servers currently available:",
|
||||||
`* - Bedrock: ${SystemInfo.valid_platform.bedrock}`,
|
`* - Bedrock: ${valid_platform.bedrock}`,
|
||||||
`* - Pocketmine-MP: ${SystemInfo.valid_platform.pocketmine}`,
|
`* - Pocketmine-MP: ${valid_platform.pocketmine}`,
|
||||||
`* - Dragonfly: ${SystemInfo.valid_platform.dragonfly}`,
|
`* - Dragonfly: ${valid_platform.dragonfly}`,
|
||||||
`* - Java: ${SystemInfo.valid_platform.java}`,
|
`* - Java: ${valid_platform.java}`,
|
||||||
`* - Spigot: ${SystemInfo.valid_platform.java}`,
|
`* - Spigot: ${valid_platform.java}`,
|
||||||
"*",
|
"*",
|
||||||
"**************************************************************"
|
"**************************************************************"
|
||||||
];
|
];
|
||||||
@ -206,3 +207,5 @@ if (bds_version){
|
|||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
if (start && !(server || version || SystemCheck || bds_version || help)) StartServer();
|
if (start && !(server || version || SystemCheck || bds_version || help)) StartServer();
|
||||||
|
|
||||||
|
})()
|
2
index.js
2
index.js
@ -47,7 +47,7 @@ module.exports.telegram_token_save = UpdateTelegramToken
|
|||||||
*
|
*
|
||||||
* @param {function} callback - The callback function after start API
|
* @param {function} callback - The callback function after start API
|
||||||
*/
|
*/
|
||||||
module.exports.api = require("./src/rest/api");
|
module.exports.api = require("./src/api/api");
|
||||||
|
|
||||||
function token_register(Admin_Scoper = ["web_admin", "admin"]) {
|
function token_register(Admin_Scoper = ["web_admin", "admin"]) {
|
||||||
Admin_Scoper = Array.from(Admin_Scoper).filter(scoper => /admin/.test(scoper));
|
Admin_Scoper = Array.from(Admin_Scoper).filter(scoper => /admin/.test(scoper));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { join, resolve, basename } = require("path");
|
const { join, resolve, basename } = require("path");
|
||||||
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
|
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
|
||||||
const { homedir } = require("os");
|
const { homedir } = require("os");
|
||||||
const { valid_platform } = require("./BdsSystemInfo");
|
const BdsInfo = require("./BdsSystemInfo");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
// PATHs
|
// PATHs
|
||||||
@ -9,12 +9,19 @@ const home = homedir();
|
|||||||
const bds_dir = join(home, "bds_core");
|
const bds_dir = join(home, "bds_core");
|
||||||
if (!(existsSync(bds_dir))) mkdirSync(bds_dir, {recursive: true})
|
if (!(existsSync(bds_dir))) mkdirSync(bds_dir, {recursive: true})
|
||||||
|
|
||||||
|
BdsInfo().then(validation => {
|
||||||
|
const { valid_platform } = validation;
|
||||||
// Set default platform for bds maneger
|
// Set default platform for bds maneger
|
||||||
var default_platformConfig;
|
var default_platformConfig;
|
||||||
if (valid_platform["bedrock"]) default_platformConfig = "bedrock";
|
if (valid_platform["bedrock"]) default_platformConfig = "bedrock";
|
||||||
else if (valid_platform["java"]) default_platformConfig = "java";
|
else if (valid_platform["java"]) default_platformConfig = "java";
|
||||||
else if (valid_platform["pocketmine"]) default_platformConfig = "pocketmine";
|
else if (valid_platform["pocketmine"]) default_platformConfig = "pocketmine";
|
||||||
else throw new Error("We cannot run any platforms on this system/device");
|
else throw new Error("We cannot run any platforms on this system/device");
|
||||||
|
UpdatePlatform(default_platformConfig);
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
// Config Base to Bds Maneger Core and others Projects
|
// Config Base to Bds Maneger Core and others Projects
|
||||||
var Config = {
|
var Config = {
|
||||||
@ -28,7 +35,7 @@ var Config = {
|
|||||||
enable_tmp_host: false
|
enable_tmp_host: false
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
platform: default_platformConfig,
|
platform: "bedrock",
|
||||||
BackupCron: [
|
BackupCron: [
|
||||||
{
|
{
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
@ -1,27 +1,21 @@
|
|||||||
const { execSync } = require("child_process");
|
|
||||||
const { release } = require("os");
|
const { release } = require("os");
|
||||||
const { readdirSync } = require("fs");
|
const { readdirSync } = require("fs");
|
||||||
|
const { execSync } = require("child_process");
|
||||||
const commadExist = require("./commandExist");
|
const commadExist = require("./commandExist");
|
||||||
const fetchSync = require("@the-bds-maneger/fetchsync");
|
const Request = require("./Requests");
|
||||||
|
|
||||||
// Load JSON for Server and PHP Zip files
|
async function CheckSystemAsync() {
|
||||||
const PHPBin = fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json").json(),
|
const
|
||||||
Servers = fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json").json();
|
PHPBin = await Request.JSON("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json"),
|
||||||
|
Servers = await Request.JSON("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json");
|
||||||
|
|
||||||
// System Architect (x64, aarch64 and others)
|
let system, require_qemu = false;
|
||||||
var arch;
|
const valid_platform = {
|
||||||
if (process.arch === "arm64") arch = "aarch64";
|
|
||||||
else arch = process.arch
|
|
||||||
module.exports.arch = arch
|
|
||||||
|
|
||||||
var system,
|
|
||||||
require_qemu = false,
|
|
||||||
valid_platform = {
|
|
||||||
bedrock: true,
|
bedrock: true,
|
||||||
pocketmine: true,
|
pocketmine: true,
|
||||||
java: commadExist("java"),
|
java: commadExist("java"),
|
||||||
dragonfly: commadExist("go"),
|
dragonfly: commadExist("go"),
|
||||||
}
|
};
|
||||||
|
|
||||||
// check php bin
|
// check php bin
|
||||||
if ((PHPBin[process.platform] || {})[arch]) valid_platform["pocketmine"] = true;
|
if ((PHPBin[process.platform] || {})[arch]) valid_platform["pocketmine"] = true;
|
||||||
@ -53,10 +47,27 @@ if (process.platform == "win32") {
|
|||||||
system = "Android";
|
system = "Android";
|
||||||
valid_platform["bedrock"] = false
|
valid_platform["bedrock"] = false
|
||||||
} else {
|
} else {
|
||||||
console.log(`The Bds Maneger Core does not support ${process.platform} systems, as no tests have been done.`);
|
throw new Error(`The Bds Maneger Core does not support ${process.platform} systems, as no tests have been done.`);
|
||||||
process.exit(127);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
system,
|
||||||
|
require_qemu,
|
||||||
|
valid_platform,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CheckSystemAsync;
|
||||||
|
|
||||||
|
// System Architect (x64, aarch64 and others)
|
||||||
|
let arch;
|
||||||
|
if (process.arch === "arm64") arch = "aarch64";
|
||||||
|
else arch = process.arch
|
||||||
|
module.exports.arch = arch
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platforms valid from deferents systems
|
||||||
|
*/
|
||||||
function GetKernel() {
|
function GetKernel() {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
const kernelVersion = parseFloat(release());
|
const kernelVersion = parseFloat(release());
|
||||||
@ -93,11 +104,4 @@ function GetKernel() {
|
|||||||
else return str.replace(/\n|\t|\r/gi, "");
|
else return str.replace(/\n|\t|\r/gi, "");
|
||||||
} else return "Not identified";
|
} else return "Not identified";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Platforms valid from deferents systems
|
|
||||||
*/
|
|
||||||
module.exports.valid_platform = valid_platform
|
|
||||||
module.exports.require_qemu = require_qemu
|
|
||||||
module.exports.system = system
|
|
||||||
module.exports.GetKernel = GetKernel;
|
module.exports.GetKernel = GetKernel;
|
||||||
|
6
lib/Requests.js
Normal file
6
lib/Requests.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
|
||||||
|
module.exports = {
|
||||||
|
JSON: async (url = "", options) => await (await fetch(url, options)).json(),
|
||||||
|
TEXT: async (url = "", options) => await (await fetch(url, options)).text(),
|
||||||
|
BUFFER: async (url = "", options) => Buffer.from(await (await fetch(url, options)).arrayBuffer()),
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const app = express.Router();
|
const app = express.Router();
|
||||||
const { GetPlatform, GetPaths } = require("../../../lib/BdsSettings")
|
const { GetPlatform, GetPaths } = require("../../../lib/BdsSettings")
|
||||||
const bds = require("../../../index");
|
|
||||||
const { token_verify, CheckPlayer } = require("../../UsersAndtokenChecks");
|
const { token_verify, CheckPlayer } = require("../../UsersAndtokenChecks");
|
||||||
const { readFileSync } = require("fs");
|
const { readFileSync } = require("fs");
|
||||||
const docs = require("../../../BdsManegerInfo.json").docs;
|
const docs = require("../../../BdsManegerInfo.json").docs;
|
Reference in New Issue
Block a user