From 3c6c97f9f8285dc146ed7242f18b5044fff1afc9 Mon Sep 17 00:00:00 2001 From: Matthew Tran Date: Wed, 6 Sep 2023 12:39:36 +0000 Subject: [PATCH] wip terraria service --- .gitignore | 4 ++++ compose.yml | 8 ++++++++ terraria/Dockerfile | 19 +++++++++++++++++++ terraria/config.txt | 5 +++++ terraria/entry.sh | 12 ++++++++++++ terraria/password.default | 1 + 6 files changed, 49 insertions(+) create mode 100644 terraria/Dockerfile create mode 100644 terraria/config.txt create mode 100644 terraria/entry.sh create mode 100644 terraria/password.default diff --git a/.gitignore b/.gitignore index 49f05a1..3e92912 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,9 @@ __pycache__ # minecraft minecraft/world +# terraria +terraria/worlds +terraria/password.txt + # wireguard wireguard/*.conf diff --git a/compose.yml b/compose.yml index 34b2c7f..f5dd1f8 100644 --- a/compose.yml +++ b/compose.yml @@ -1,9 +1,17 @@ services: minecraft: + restart: always build: minecraft/. entrypoint: ["/bin/sh", "/root/entry.sh"] ports: - "25565:25565" volumes: - ./minecraft/world:/root/world + terraria: restart: always + build: terraria/. + entrypoint: ["/bin/sh", "/root/entry.sh"] + ports: + - "7777:7777" + volumes: + - ./terraria/worlds:/root/worlds diff --git a/terraria/Dockerfile b/terraria/Dockerfile new file mode 100644 index 0000000..1666469 --- /dev/null +++ b/terraria/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:22.04 + +WORKDIR /root + +RUN apt-get update && apt-get upgrade +RUN apt-get install -y wget unzip tmux + +# from https://terraria.fandom.com/wiki/Server (currently 1.4.4.9) +RUN wget https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip +RUN unzip terraria-server-1449.zip && rm terraria-server-1449.zip +RUN mv 1449/ server/ + +COPY entry.sh ./ + +WORKDIR /root/server/Linux + +RUN chmod +x TerrariaServer.bin.x86_64 +COPY password.default ./password.txt +COPY config.txt password.tx[t] ./ diff --git a/terraria/config.txt b/terraria/config.txt new file mode 100644 index 0000000..83425b0 --- /dev/null +++ b/terraria/config.txt @@ -0,0 +1,5 @@ +world=/root/worlds/default.wld +autocreate=3 +worldname=default +difficulty=0 +worldpath=/root/worlds diff --git a/terraria/entry.sh b/terraria/entry.sh new file mode 100644 index 0000000..faba006 --- /dev/null +++ b/terraria/entry.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +cleanup() { + echo "TODO" +} + +trap 'cleanup' TERM + +# TODO use tmux so can send exit +./TerrariaServer.bin.x86_64 -config config.txt -pass $(cat password.txt) & +wait $! # wait for SIGTERM +# wait $! # wait for server to stop diff --git a/terraria/password.default b/terraria/password.default new file mode 100644 index 0000000..7aa311a --- /dev/null +++ b/terraria/password.default @@ -0,0 +1 @@ +password \ No newline at end of file