-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_start.sh
51 lines (40 loc) · 1.62 KB
/
2_start.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
#!/bin/bash
set -euo pipefail
#set -euxo pipefail # useful during development
echo "Starting..."
cd /terraria/config
CMD="../server/TerrariaServer.exe -x64 -config $FILENAME_CONFIG -banlist $FILENAME_BANLIST -logpath logs"
# Create default config files if they don't exist
if [ ! -f "/terraria/config/$FILENAME_CONFIG" ]; then
echo "Server configuration not found, running with default server configuration."
cp /terraria/server/serverconfig-default.txt /terraria/config/$FILENAME_CONFIG
fi
if [ ! -f "/terraria/config/$FILENAME_BANLIST" ]; then
touch /terraria/config/$FILENAME_BANLIST
fi
# Link Worlds folder to /terraria/config so it will save to the correct location
if [ ! -s "/root/.local/share/Terraria/Worlds" ]; then
mkdir -p /root/.local/share/Terraria
ln -sT /terraria/config /root/.local/share/Terraria/Worlds
fi
# Pass in world if set, otherwise generate new world with serverconfig.txt parameters or command flags
if [ -z "$FILENAME_WORLD" ]; then
echo "No world file specified in environment FILENAME_WORLD."
if [ -z "$@" ]; then
echo "Running server setup..."
else
echo "Running server with command flags: $@"
fi
#mono TerrariaServer.exe -config "/terraria/config/$FILENAME_CONFIG" -logpath "$LOGPATH" "$@"
else
echo "Loading world $FILENAME_WORLD..."
if [ ! -f "/terraria/config/$FILENAME_WORLD" ]; then
echo "World file does not exist! Quitting..."
exit 1
fi
#mono TerrariaServer.exe -config "$CONFIGPATH/$CONFIG_FILENAME" -logpath "/terraria/config/logs" -world "$FILENAME_WORLD" "$@"
CMD="$CMD -world $FILENAME_WORLD"
fi
echo "Starting container"
echo "CMD: $CMD $@"
mono $CMD $@