Code Modifications #261
@ -4,7 +4,7 @@ set -ex
|
|||||||
apt update
|
apt update
|
||||||
|
|
||||||
# Install Necessary Packages
|
# Install Necessary Packages
|
||||||
apt -qq install -y curl wget git zsh sudo unzip zip jq python3 screen xz-utils
|
apt -qq install -y curl wget git sudo unzip zip jq python3 xz-utils tar
|
||||||
|
|
||||||
# Install nodejs from github release
|
# Install nodejs from github release
|
||||||
NODEVERSION=$(curl -sL https://api.github.com/repos/nodejs/node/releases | grep tag_name | cut -d '"' -f 4 | sort -V | tail -n 1)
|
NODEVERSION=$(curl -sL https://api.github.com/repos/nodejs/node/releases | grep tag_name | cut -d '"' -f 4 | sort -V | tail -n 1)
|
||||||
@ -22,12 +22,14 @@ mkdir /tmp/Node
|
|||||||
tar -xJf /tmp/node.tar.xz -C /tmp/Node
|
tar -xJf /tmp/node.tar.xz -C /tmp/Node
|
||||||
rm -rf /tmp/node.tar.xz
|
rm -rf /tmp/node.tar.xz
|
||||||
cp -rf /tmp/Node/*/* /usr
|
cp -rf /tmp/Node/*/* /usr
|
||||||
|
rm -rf /tmp/Node
|
||||||
|
|
||||||
# Install Build Dependencies and others Packages
|
# Install Build Dependencies and others Packages
|
||||||
apt -qq install -y ca-certificates make build-essential procps lsb-release xdg-utils g++ libatomic1 libnss3 libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libnss3 libgbm-dev
|
# apt install -y ca-certificates procps lsb-release libatomic1 libnss3 libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libnss3 libgbm-dev
|
||||||
|
apt install -y libcurl4-openssl-dev curl
|
||||||
|
|
||||||
# Update npm
|
# Update npm
|
||||||
npm -g install npm@$(curl -sL https://api.github.com/repos/npm/cli/releases/latest | grep tag_name | cut -d '"' -f 4)
|
npm -g install npm@latest
|
||||||
|
|
||||||
# Install Dependencies to diferent architectures
|
# Install Dependencies to diferent architectures
|
||||||
if ! [ "$(uname -m)" == "x86_64" ];then
|
if ! [ "$(uname -m)" == "x86_64" ];then
|
||||||
@ -45,15 +47,6 @@ case "$(apt search openjdk)" in
|
|||||||
* ) echo "No openjdk version found, skipping";;
|
* ) echo "No openjdk version found, skipping";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Setup non root user
|
|
||||||
setup_user() {
|
|
||||||
useradd -m -p "$(perl -e 'print crypt($ARGV[0], "password")' "LucaA1113ba21")" "thebds"
|
|
||||||
addgroup thebds sudo
|
|
||||||
addgroup thebds root
|
|
||||||
usermod --shell /usr/bin/zsh thebds;
|
|
||||||
echo "thebds ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove Unnecessary Packages
|
# Remove Unnecessary Packages
|
||||||
apt autoremove -y
|
apt autoremove -y
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ ENV PLAYERS="5" \
|
|||||||
ENABLE_COMMANDS="false" \
|
ENABLE_COMMANDS="false" \
|
||||||
ACCOUNT="false" \
|
ACCOUNT="false" \
|
||||||
SERVER="bedrock" \
|
SERVER="bedrock" \
|
||||||
UPDATE_SERVER="true"
|
SERVER_VERSION="true"
|
||||||
|
|
||||||
# Bds Maneger Core required ports
|
# Bds Maneger Core required ports
|
||||||
EXPOSE 19132/udp 19133/udp 1932/tcp
|
EXPOSE 19132/udp 19133/udp 1932/tcp
|
||||||
@ -38,8 +38,7 @@ RUN npm install
|
|||||||
|
|
||||||
# Copy BdsManger Core
|
# Copy BdsManger Core
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
RUN chmod a+x -v bin/*
|
RUN chmod a+x -vR bin/*
|
||||||
RUN npm run esm_module
|
|
||||||
|
|
||||||
# Set Entrypint
|
# Set Entrypint
|
||||||
ENTRYPOINT [ "node", "./bin/Docker.js" ]
|
ENTRYPOINT [ "node", "./bin/Docker.js" ]
|
||||||
|
@ -5,22 +5,24 @@ const BdsCore = require("../index");
|
|||||||
const { CronJob } = require("cron");
|
const { CronJob } = require("cron");
|
||||||
|
|
||||||
async function UpdateInstallServer(OldServerRunner) {
|
async function UpdateInstallServer(OldServerRunner) {
|
||||||
if (process.env.UPDATE_SERVER === "true") {
|
if (process.env.SERVER_VERSION === "true") {
|
||||||
if (typeof OldServerRunner === "function") {
|
if (typeof OldServerRunner === "function") {
|
||||||
OldServerRunner.stop();
|
OldServerRunner.stop();
|
||||||
}
|
}
|
||||||
const BackupBds = BdsCore.Bdsbackup.CreateBackup();
|
const BackupBds = BdsCore.BdsBackup.CreateBackup();
|
||||||
const ServerDownloadResult = await BdsCore.BdsDownload("latest");
|
const ServerDownloadResult = await BdsCore.BdsDownload("latest");
|
||||||
if (!ServerDownloadResult.skip) {
|
if (!ServerDownloadResult.skip) {
|
||||||
console.log("Server Update Sucess, Version:", ServerDownloadResult.version);
|
console.log("Server Update Sucess, Version:", ServerDownloadResult.version);
|
||||||
return StartServer();
|
return StartServer();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await BdsCore.BdsDownload(process.env.SERVER_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function StartServer() {
|
function StartServer() {
|
||||||
let IsUpdate = false;
|
let IsUpdate = false;
|
||||||
const Server = BdsCore.BdsManagerServer.StartServer();
|
const Server = BdsCore.BdsManegerServer.StartServer();
|
||||||
Server.on("log", data => process.stdout.write(data));
|
Server.on("log", data => process.stdout.write(data));
|
||||||
Server.on("exit", code => {
|
Server.on("exit", code => {
|
||||||
if (!IsUpdate) process.exit(code);
|
if (!IsUpdate) process.exit(code);
|
||||||
@ -31,4 +33,26 @@ function StartServer() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function InitDockerConfig() {}
|
function WriteServerConfig() {
|
||||||
|
const { DESCRIPTION, WORLD_NAME, GAMEMODE, DIFFICULTY, ACCOUNT, PLAYERS, SERVER, ENABLE_COMMANDS } = process.env;
|
||||||
|
BdsCore.BdsSettings.UpdatePlatform(SERVER || "bedrock");
|
||||||
|
const ServerConfig = {
|
||||||
|
world: WORLD_NAME,
|
||||||
|
description: DESCRIPTION,
|
||||||
|
gamemode: GAMEMODE,
|
||||||
|
difficulty: DIFFICULTY,
|
||||||
|
players: parseInt(PLAYERS),
|
||||||
|
commands: ENABLE_COMMANDS === "true",
|
||||||
|
account: ACCOUNT === "true",
|
||||||
|
whitelist: false,
|
||||||
|
port: 19132,
|
||||||
|
portv6: 19133,
|
||||||
|
}
|
||||||
|
BdsCore.BdsServerSettings.config(ServerConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
WriteServerConfig();
|
||||||
|
await UpdateInstallServer();
|
||||||
|
StartServer();
|
||||||
|
})();
|
||||||
|
@ -64,11 +64,13 @@ function CreateBackup() {
|
|||||||
|
|
||||||
// Zip Buffer
|
// Zip Buffer
|
||||||
const ZipBuffer = zip.toBuffer();
|
const ZipBuffer = zip.toBuffer();
|
||||||
fs.writeFileSync(PathBackup, ZipBuffer, "binary");
|
|
||||||
return {
|
return {
|
||||||
file_path: PathBackup,
|
file_path: PathBackup,
|
||||||
Buffer: ZipBuffer,
|
Buffer: ZipBuffer,
|
||||||
file_name: ZipName,
|
file_name: ZipName,
|
||||||
|
write_file: () => {
|
||||||
|
fs.writeFileSync(PathBackup, ZipBuffer, "binary");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,4 +79,4 @@ module.exports = {
|
|||||||
Backup: CreateBackup,
|
Backup: CreateBackup,
|
||||||
World_BAckup: CreateBackup,
|
World_BAckup: CreateBackup,
|
||||||
Cloud_backup: CreateBackup
|
Cloud_backup: CreateBackup
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user