Move scripts/ to src/ folder #137
@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env node
|
||||
if (process.platform === "win32") process.title = "Bds Maneger CLI";else process.title = "Bds_Manger_CLI"
|
||||
const readline = require("readline");
|
||||
const bds = require("../../index");
|
||||
const { valid_platform } = require("../../lib/BdsSystemInfo");
|
||||
const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../../lib/BdsSettings");
|
||||
const commandExits = require("../../lib/commandExist");
|
||||
const bds = require("../index");
|
||||
const { valid_platform } = require("../lib/BdsSystemInfo");
|
||||
const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../lib/BdsSettings");
|
||||
const commandExits = require("../lib/commandExist");
|
||||
const download = require("../src/Scripts/download");
|
||||
process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
|
||||
// Bds Maneger ArgV
|
||||
@ -12,7 +12,15 @@ const argv = require("minimist")(process.argv.slice(2));
|
||||
if (Object.getOwnPropertyNames(argv).length <= 1) argv.help = true
|
||||
|
||||
// Options
|
||||
const server = (argv.p || argv.platform), version = (argv.v || argv.version), SystemCheck = (argv.S || argv.system_info), bds_version = (argv.d || argv.server_download), start = (argv.s || argv.server_version), help = (argv.h || argv.help), kill = (argv.k || argv.kill), docker_runner = (argv.DOCKER_IMAGE)
|
||||
const
|
||||
server = (argv.p || argv.platform),
|
||||
version = (argv.v || argv.version),
|
||||
SystemCheck = (argv.S || argv.system_info),
|
||||
bds_version = (argv.d || argv.server_download),
|
||||
start = (argv.s || argv.server_version),
|
||||
help = (argv.h || argv.help),
|
||||
kill = (argv.k || argv.kill),
|
||||
docker_runner = (argv.DOCKER_IMAGE);
|
||||
|
||||
// --------------------------
|
||||
const Versions = GetServerVersion();
|
||||
|
@ -1,9 +1,9 @@
|
||||
const { Telegraf } = require("telegraf");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const bds = require("../../index");
|
||||
const { GetPlatform, GetPaths } = require("../../lib/BdsSettings");
|
||||
const { GetKernel, arch, system } = require("../../lib/BdsSystemInfo");
|
||||
const bds = require("../index");
|
||||
const { GetPlatform, GetPaths } = require("../lib/BdsSettings");
|
||||
const { GetKernel, arch, system } = require("../lib/BdsSystemInfo");
|
||||
const { Detect } = require("../src/Scripts/CheckKill");
|
||||
const TelegramOptions = require("minimist")(process.argv.slice(2));
|
||||
|
||||
|
@ -154,7 +154,8 @@ module.exports = {
|
||||
GetJsonConfig: function(){return Config},
|
||||
GetPaths: function(path = null){
|
||||
if (!(path)) throw new Error("Set path to get");
|
||||
if (!(Config.paths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(Config.paths).join(", "));
|
||||
if (!(path === "all" || Config.paths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(Config.paths).join(", "));
|
||||
if (path === "all") return Config.paths
|
||||
return Config.paths[path]
|
||||
},
|
||||
GetServerPaths: function(path = null){
|
||||
|
@ -1,6 +1,6 @@
|
||||
const bds = require("../../index")
|
||||
const { join } = require("path");
|
||||
const { readdirSync, existsSync, readFileSync } = require("fs")
|
||||
const { join, resolve } = require("path");
|
||||
const { readdirSync, existsSync, readFileSync, statSync } = require("fs")
|
||||
const AdmZip = require("adm-zip");
|
||||
const { GetServerPaths, GetPaths, bds_dir } = require("../../lib/BdsSettings")
|
||||
|
||||
@ -18,49 +18,35 @@ function Backup() {
|
||||
const PathBackup = join(GetPaths("backups"), name);
|
||||
|
||||
// Bedrock
|
||||
if (existsSync(join(Paths.bedrock, (() => {if (process.platform === "win32") return "bedrock_server.exe";else if (process.platform === "linux") return "bedrock_server";})()))) {
|
||||
zip.addLocalFolder(join(Paths.bedrock, "worlds"), join("Servers", "bedrock", "worlds"));
|
||||
for (let index of [
|
||||
"server.properties",
|
||||
"permissions.json",
|
||||
"whitelist.json"
|
||||
]) if (existsSync(join(Paths.bedrock, index))) zip.addLocalFile(join(Paths.bedrock, index), join("Servers", "bedrock"));
|
||||
if (readdirSync(Paths.bedrock).filter(a=>/worlds/.test(a)).length >= 1) {
|
||||
zip.addLocalFolder(join(Paths.bedrock, "worlds"), join("Servers", "Bedrock", "worlds"));
|
||||
for (let index of ["server.properties", "permissions.json", "whitelist.json"]) {if (existsSync(join(Paths.bedrock, index))) zip.addLocalFile(join(Paths.bedrock, index), join("Servers", "Bedrock"));}
|
||||
} else console.info("Skipping the bedrock as it was not installed");
|
||||
|
||||
// Java
|
||||
if (existsSync(join(Paths.java, "MinecraftServerJava.jar"))) {
|
||||
let javaDir = readdirSync(Paths.java).filter(function(value) {if (value === "banned-ips.json" || value === "banned-players.json" || value === "eula.txt" || value === "logs" || value === "ops.json" || value === "server.jar" || value === "MinecraftServerJava.jar" || value === "server.properties" || value === "usercache.json" || value === "whitelist.json") return false;return true});
|
||||
for (let index of javaDir) zip.addLocalFolder(join(Paths.java, index), join("Servers", "java", index))
|
||||
for (let index of [
|
||||
"banned-ips.json",
|
||||
"banned-players.json",
|
||||
"ops.json",
|
||||
"server.properties",
|
||||
"whitelist.json"
|
||||
]) if (existsSync(join(Paths.java, index))) zip.addLocalFile(join(Paths.java, index), join("Servers", "java"));
|
||||
for (let index of readdirSync(Paths.java).filter(value => !/banned-ips.json|banned-players.json|eula.txt|logs|ops.json|server.jar|MinecraftServerJava.jar|server.properties|usercache.json|whitelist.json/.test(value))) zip.addLocalFolder(join(Paths.java, index), join("Servers", "Java", index));
|
||||
for (let index of ["banned-ips.json", "banned-players.json", "ops.json", "server.properties", "whitelist.json"]) {if (existsSync(join(Paths.java, index))) zip.addLocalFile(join(Paths.java, index), join("Servers", "Java"))}
|
||||
} else console.info("Skipping the java as it was not installed");
|
||||
|
||||
// PocketMine
|
||||
if (existsSync(join(Paths.pocketmine, "PocketMine-MP.phar"))) {
|
||||
if (existsSync(join(Paths.pocketmine, "worlds"))) zip.addLocalFolder(join(Paths.pocketmine, "worlds"), join("Servers", "pocketmine", "worlds"));
|
||||
for (let index of [
|
||||
"pocketmine.yml",
|
||||
"server.properties",
|
||||
"white-list.txt",
|
||||
"ops.txt",
|
||||
"banned-players.txt",
|
||||
"banned-ips.txt"
|
||||
]) if (existsSync(join(Paths.pocketmine, index))) zip.addLocalFile(join(Paths.pocketmine, index), "pocketmine");
|
||||
for (let index of ["pocketmine.yml", "server.properties", "white-list.txt", "ops.txt", "banned-players.txt", "banned-ips.txt"]) if (existsSync(join(Paths.pocketmine, index))) zip.addLocalFile(join(Paths.pocketmine, index), "pocketmine");
|
||||
} else console.info("Skipping the pocketmine as it was not installed");
|
||||
|
||||
|
||||
// JSPrismarine
|
||||
|
||||
// The Bds Maneger Core Backup
|
||||
for (let index of [
|
||||
"BdsConfig.yaml",
|
||||
"bds_tokens.json"
|
||||
]) if (existsSync(join(bds_dir, index))) zip.addLocalFile(join(bds_dir, index));
|
||||
for (let index of ["BdsConfig.yaml", "bds_tokens.json"]) if (existsSync(join(bds_dir, index))) zip.addLocalFile(join(bds_dir, index));
|
||||
|
||||
for (let index of Object.getOwnPropertyNames(GetPaths("all")).filter(path => !/servers|backups/.test(path)).map(name => GetPaths(name))) {
|
||||
if (existsSync(index)) {
|
||||
const _S = statSync(resolve(index));
|
||||
if (_S.isFile() || _S.isSymbolicLink()) zip.addLocalFile(index); else zip.addLocalFolder(index)
|
||||
}
|
||||
}
|
||||
|
||||
zip.addZipComment("Settings and World Backups, by The Bds Maneger Project©");
|
||||
zip.writeZip(PathBackup);
|
||||
|
Reference in New Issue
Block a user