diff --git a/.gitignore b/.gitignore index 3c81c91..2a9e688 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/config/server.default b/config/server.default index a935d35..4131750 100644 --- a/config/server.default +++ b/config/server.default @@ -18,5 +18,16 @@ ], "minecraft": { "world": "main" + }, + "minecraft_bedrock": { + "world": "main" + }, + "terraria": { + "password": "password", + "world": "main", + "autogen": { + "size": 3, + "difficulty": 2 + } } } \ No newline at end of file diff --git a/minecraft_bedrock/.dockerignore b/minecraft_bedrock/.dockerignore deleted file mode 100644 index 6a2fdbd..0000000 --- a/minecraft_bedrock/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -worlds/ diff --git a/minecraft_bedrock/Dockerfile b/minecraft_bedrock/Dockerfile index 824c1a8..e302776 100644 --- a/minecraft_bedrock/Dockerfile +++ b/minecraft_bedrock/Dockerfile @@ -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"] diff --git a/minecraft_bedrock/entry.sh b/minecraft_bedrock/entry.sh index 9a86145..e6ba9ae 100644 --- a/minecraft_bedrock/entry.sh +++ b/minecraft_bedrock/entry.sh @@ -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 & diff --git a/minecraft_bedrock/server.properties b/minecraft_bedrock/server.default similarity index 98% rename from minecraft_bedrock/server.properties rename to minecraft_bedrock/server.default index 4d1ba3b..a5b05f7 100644 --- a/minecraft_bedrock/server.properties +++ b/minecraft_bedrock/server.default @@ -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 diff --git a/scripts/provision.py b/scripts/provision.py index 024a639..85d732f 100755 --- a/scripts/provision.py +++ b/scripts/provision.py @@ -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? diff --git a/scripts/update.py b/scripts/update.py index f3fab87..28506e7 100755 --- a/scripts/update.py +++ b/scripts/update.py @@ -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: diff --git a/terraria/.dockerignore b/terraria/.dockerignore deleted file mode 100644 index 6a2fdbd..0000000 --- a/terraria/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -worlds/ diff --git a/terraria/Dockerfile b/terraria/Dockerfile index e0a2119..1d32d05 100644 --- a/terraria/Dockerfile +++ b/terraria/Dockerfile @@ -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 diff --git a/terraria/config.default b/terraria/config.default index 8f656aa..53461a3 100644 --- a/terraria/config.default +++ b/terraria/config.default @@ -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 diff --git a/terraria/entry.py b/terraria/entry.py index 99c31bd..1ad3f81 100644 --- a/terraria/entry.py +++ b/terraria/entry.py @@ -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(): diff --git a/terraria/password.default b/terraria/password.default deleted file mode 100644 index 7aa311a..0000000 --- a/terraria/password.default +++ /dev/null @@ -1 +0,0 @@ -password \ No newline at end of file