This commit is contained in:
Matthew Tran 2025-05-04 00:41:07 -07:00
parent 3e5a59d513
commit cb8f88fd33
13 changed files with 65 additions and 48 deletions

19
.gitignore vendored
View File

@ -10,6 +10,13 @@ config/*.ign
# minecraft
minecraft/server.properties
# minecraft_bedrock
minecraft_bedrock/server.properties
# terraria
terraria/*.txt
@ -26,18 +33,6 @@ monerod/.bitmonero
# p2pool
p2pool/cache
# minecraft
minecraft/world*
# minecraft_bedrock
minecraft_bedrock/worlds*
# terraria
terraria/worlds
terraria/mods
terraria/config.txt
terraria/password.txt
# nas
nas/*.json
nas/smb.conf

View File

@ -18,5 +18,16 @@
],
"minecraft": {
"world": "main"
},
"minecraft_bedrock": {
"world": "main"
},
"terraria": {
"password": "password",
"world": "main",
"autogen": {
"size": 3,
"difficulty": 2
}
}
}

View File

@ -1 +0,0 @@
worlds/

View File

@ -3,14 +3,15 @@ FROM ubuntu:24.04
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y wget unzip curl tmux
RUN groupadd -g 2002 me && useradd -u 2002 -g 2002 -m me
USER me
WORKDIR /home/me
WORKDIR /root
# from https://www.minecraft.net/en-us/download/server/bedrock (currently 1.21.61.01)
RUN wget -O server.zip --user-agent "Mozilla/5.0" https://www.minecraft.net/bedrockdedicatedserver/bin-linux/bedrock-server-1.21.61.01.zip
# from https://www.minecraft.net/en-us/download/server/bedrock (currently 1.21.73.01)
RUN wget -O server.zip --user-agent "Mozilla/5.0" https://www.minecraft.net/bedrockdedicatedserver/bin-linux/bedrock-server-1.21.73.01.zip
RUN unzip server.zip && rm server.zip
COPY --chown=me:me entry.sh ./
COPY --chown=me:me server.properties ./
COPY --chown=me:me permissions.json ./
COPY entry.sh ./
COPY permissions.json ./
COPY server.properties ./
RUN ln -s /root/data /root/worlds
CMD ["/bin/bash", "/root/entry.sh"]

View File

@ -4,9 +4,8 @@ cleanup() {
tmux send-keys stop Enter
}
trap 'cleanup' TERM
trap 'cleanup' SIGTERM SIGINT
rm log
mkfifo log
tmux new -d 'LD_LIBRARY_PATH=. ./bedrock_server > log'
cat log &

View File

@ -13,7 +13,6 @@ view-distance=32
tick-distance=4
player-idle-timeout=0
max-threads=4
level-name=test
level-seed=
default-player-permission-level=visitor
texturepack-required=false

View File

@ -17,7 +17,10 @@ UIDS = {
PORTS = {
"game": [
"25565:25565",
"25565:25565", # minecraft
"19132:19132/udp", # minecraft_bedrock
"19133:19133/udp",
"7777:7777", # terraria
],
}
@ -280,7 +283,6 @@ if __name__ == "__main__":
# TODO add rest of containers
# add core to nas group
# TODO script to backup => restore backup if desired
# TODO enable bedrock => check idle cpu
# TODO reduce disk logging?

View File

@ -10,6 +10,8 @@ SOURCE_DIR = "/var/source"
IMAGES = {
"game": [
"minecraft",
"minecraft_bedrock",
"terraria",
],
}
@ -17,7 +19,21 @@ def generate(cfg):
# minecraft
shutil.copy("minecraft/server.default", "minecraft/server.properties")
with open("minecraft/server.properties", "a") as f:
f.write(f"level-name=data/{cfg["minecraft"]["world"]}")
f.write(f"level-name=data/{cfg["minecraft"]["world"]}\n")
# minecraft_bedrock
shutil.copy("minecraft_bedrock/server.default", "minecraft_bedrock/server.properties")
with open("minecraft_bedrock/server.properties", "a") as f:
f.write(f"level-name={cfg["minecraft_bedrock"]["world"]}\n")
# terraria
shutil.copy("terraria/config.default", "terraria/config.txt")
with open("terraria/config.txt", "a") as f:
f.write(f"world=/root/data/worlds/{cfg["terraria"]["world"]}.wld\n")
f.write(f"autocreate={cfg["terraria"]["autogen"]["size"]}\n") # 1=small, 2=medium, 3=large
f.write(f"difficulty={cfg["terraria"]["autogen"]["difficulty"]}\n") # 0=normal, 1=expert, 2=master, 3=journey
with open("terraria/password.txt", "w") as f:
f.write(cfg["terraria"]["password"])
def run(cmds):
try:

View File

@ -1 +0,0 @@
worlds/

View File

@ -3,21 +3,21 @@ FROM ubuntu:24.04
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y wget unzip python3 iproute2 dotnet-runtime-8.0
RUN groupadd -g 2002 me && useradd -u 2002 -g 2002 -m me
USER me
WORKDIR /home/me
WORKDIR /root
# from https://github.com/tModLoader/tModLoader/releases (currently v2025.02.3.2)
RUN wget https://github.com/tModLoader/tModLoader/releases/download/v2025.02.3.2/tModLoader.zip
# from https://github.com/tModLoader/tModLoader/releases (currently v2025.03.3.1)
RUN wget https://github.com/tModLoader/tModLoader/releases/download/v2025.03.3.1/tModLoader.zip
RUN unzip tModLoader.zip -d server && rm tModLoader.zip
RUN chmod +x server/start-tModLoaderServer.sh
RUN mkdir server/tModLoader-Logs && touch server/tModLoader-Logs/server.log
RUN echo "" > server/LaunchUtils/InstallDotNet.sh
COPY --chown=me:me entry.py ./
COPY --chown=me:me config.default ./config.txt
COPY --chown=me:me password.default ./password.txt
COPY --chown=me:me config.tx[t] password.tx[t] ./
COPY config.txt ./
COPY entry.py ./
COPY password.txt ./
CMD ["/usr/bin/python3", "/root/entry.py"]
# To add mods, install them on the client and copy over the .tmod files to mods/
# Then modify/create mods/enabled.json and add the desired mods to enable

View File

@ -1,15 +1,12 @@
# world file
world=/home/me/worlds/master.wld
# default options if no world
autocreate=3
worldname=poopy
difficulty=2
# server options
motd=poopy
worldpath=/home/me/worlds
worldpath=/root/data/worlds
secure=1
# tmodloader options
modpath=/home/me/mods
modpath=/root/data/mods
# generated options

View File

@ -27,13 +27,13 @@ class Runner:
logging.info(f"attempted connection from {addr}, starting server...")
# start server
with open("/home/me/password.txt", "r") as f:
with open("/root/password.txt", "r") as f:
password = f.read()
self.server = subprocess.Popen([
"/bin/bash",
"/home/me/server/start-tModLoaderServer.sh",
"/root/server/start-tModLoaderServer.sh",
"-nosteam",
"-config", "/home/me/config.txt",
"-config", "/root/config.txt",
"-pass", f"{password}",
], stdin=subprocess.PIPE, start_new_session=True)
while not self.started():

View File

@ -1 +0,0 @@
password