-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-terraria-server.sh
executable file
·68 lines (54 loc) · 1.61 KB
/
start-terraria-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
#
# Run the Terraria server in a Linux container
#
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
BASE_DIR="$(dirname "$(readlink -f "$0")")"
CONTAINER_IMAGE='ubuntu:focal'
LOCAL_SERVER_FILES_DIR="${BASE_DIR}/1432/Linux/"
MOUNT_SERVER_FILES_DIR='/Terraria/'
LOCAL_WORLD_FILES_DIR="${HOME}/.local/share/Terraria/"
MOUNT_WORLD_FILES_DIR='/root/.local/share/Terraria/'
SERVER_ARCHIVE_URL='https://terraria.org/api/download/'
SERVER_ARCHIVE_URL+='pc-dedicated-server/terraria-server-1432.zip'
SERVER_ARCHIVE_FILE=$(basename "${SERVER_ARCHIVE_URL}")
SERVER_EXECUTABLE='TerrariaServer.bin.x86_64'
SERVER_PORT='7777'
#
# Make sure the directory for world data exists
#
mkdir -p "${LOCAL_WORLD_FILES_DIR}"
#
# Download and extract the server files
#
if [ ! -d "${LOCAL_SERVER_FILES_DIR}" ]; then
pushd "${BASE_DIR}"
if [ ! -f "${SERVER_ARCHIVE_FILE}" ]; then
curl --location \
--remote-name \
--remote-header-name \
"${SERVER_ARCHIVE_URL}"
fi
unzip "${SERVER_ARCHIVE_FILE}"
chmod +x "${LOCAL_SERVER_FILES_DIR}/${SERVER_EXECUTABLE}"
popd
fi
#
# Launch the server
#
# NOTE(sdatko): Exporting TERM solves the following problem for me:
# System.Exception: Magic number is wrong: 542
#
podman run \
--interactive \
--tty \
--rm \
--env 'TERM=xterm' \
--volume "${LOCAL_SERVER_FILES_DIR}:${MOUNT_SERVER_FILES_DIR}" \
--volume "${LOCAL_WORLD_FILES_DIR}:${MOUNT_WORLD_FILES_DIR}" \
--publish "${SERVER_PORT}:${SERVER_PORT}" \
"${CONTAINER_IMAGE}" \
"${MOUNT_SERVER_FILES_DIR}/${SERVER_EXECUTABLE}"