-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
62 lines (48 loc) 路 2.57 KB
/
Copy pathentrypoint.sh
File metadata and controls
62 lines (48 loc) 路 2.57 KB
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
#!/bin/sh
# Extract total memory in MB
SYSTEM_TOTAL_MEMORY=$(free -m | awk '/^Mem:/ {print $2}')
SYSTEM_TOTAL_MEMORY=${SYSTEM_TOTAL_MEMORY:-4096} # fallback to 4GB if free command fails
# Set minimum memory to 128M if not specified
HYTALE_MINIMUM_MEMORY=${HYTALE_MINIMUM_MEMORY:-128M}
# Set maximum memory to 90% of total system memory if not specified
HYTALE_MAXIMUM_MEMORY=${HYTALE_MAXIMUM_MEMORY:-$(($SYSTEM_TOTAL_MEMORY * 90 / 100))M}
# Set default server port if not specified
HYTALE_SERVER_PORT=${HYTALE_SERVER_PORT:-5520}
# set default parameters for Hytale server
HYTALE_PARAMETERS=${HYTALE_PARAMETERS:-"-XX:AOTCache=/app/Hytale/Server/HytaleServer.aot -Xms${HYTALE_MINIMUM_MEMORY} -Xmx${HYTALE_MAXIMUM_MEMORY} -jar /app/Hytale/Server/HytaleServer.jar --assets /app/Hytale/Assets.zip --bind 0.0.0.0:${HYTALE_SERVER_PORT}"}
# do we have any additional parameters to append?
if [ ! -z "$HYTALE_ADDITIONAL_PARAMETERS" ]; then
HYTALE_PARAMETERS="$HYTALE_PARAMETERS $HYTALE_ADDITIONAL_PARAMETERS"
fi
# Download Hytale server files if not already present
if [ ! -f "/app/Hytale/Server/HytaleServer.jar" ]; then
echo "Hytale server files not found. Downloading..."
./hytale-downloader-linux-amd64 -download-path /tmp/HytaleServer.zip
else
echo "Hytale server files already present. Skipping download."
fi
# Unzip the server files
if [ -f "/tmp/HytaleServer.zip" ]; then
echo "Unzipping Hytale server files..."
unzip -o /tmp/HytaleServer.zip -d /app/Hytale/
rm /tmp/HytaleServer.zip
else
echo "No Hytale server zip file found to unzip."
fi
if [ -f /app/Hytale/config.json ] && [ -n "$HYTALE_MAX_VIEW_RADIUS" ]; then
sed -i "s/\"MaxViewRadius\"[[:space:]]*:[[:space:]]*[0-9.]\+/\"MaxViewRadius\": $HYTALE_MAX_VIEW_RADIUS/" /app/Hytale/config.json
fi
if [ -f /app/Hytale/config.json ] && [ -n "$HYTALE_SERVER_NAME" ]; then
sed -i "s/\"ServerName\"[[:space:]]*:[[:space:]]*\"[^\"]*\"/\"ServerName\": \"$HYTALE_SERVER_NAME\"/" /app/Hytale/config.json
fi
if [ -f /app/Hytale/config.json ] && [ -n "$HYTALE_MOTD" ]; then
sed -i "s/\"MOTD\"[[:space:]]*:[[:space:]]*\"[^\"]*\"/\"MOTD\": \"$HYTALE_MOTD\"/" /app/Hytale/config.json
fi
if [ -f /app/Hytale/config.json ] && [ -n "$HYTALE_PASSWORD" ]; then
sed -i "s/\"Password\"[[:space:]]*:[[:space:]]*\"[^\"]*\"/\"Password\": \"$HYTALE_PASSWORD\"/" /app/Hytale/config.json
fi
if [ -f /app/Hytale/config.json ] && [ -n "$HYTALE_MAX_PLAYERS" ]; then
sed -i "s/\"MaxPlayers\"[[:space:]]*:[[:space:]]*[0-9]\+/\"MaxPlayers\": $HYTALE_MAX_PLAYERS/" /app/Hytale/config.json
fi
# Start the Hytale server
exec java $HYTALE_PARAMETERS