This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-server
67 lines (50 loc) · 1.52 KB
/
start-server
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
#!/bin/bash
. /start-utils
shopt -s nullglob
#umask 002
if ! touch /data/.verify_access; then
log "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
exit 2
fi
rm /data/.verify_access || true
cd /data || exit 1
set -o pipefail
if [[ -z $TERRARIA_VERSION ]]; then
log "Environment variable TERRARIA_VERSION not set."
log "Set TERRARIA_VERSION to the version name of the VintageStory server."
exit 2
fi
SERVER_PACKAGE="terraria-server-$TERRARIA_VERSION.zip"
SERVER="TerrariaServer"
if [ ! -e $SERVER ]; then
log "Downloading VintageStory server version $TERRARIA_VERSION..."
serverDownloadUrl="https://terraria.org/server/$SERVER_PACKAGE"
curl -fsSL -o "$SERVER_PACKAGE" "$serverDownloadUrl"
result=$?
if [ $result != 0 ]; then
log "ERROR failed to download server from $serverDownloadUrl ($result)"
exit 1
fi
log "Download finished."
log "Preparing server..."
unzip -q -o "$SERVER_PACKAGE"
mv -f "$TERRARIA_VERSION"/Linux/* .
rm -rf "$TERRARIA_VERSION"
rm "$SERVER_PACKAGE"
chmod +x TerrariaServer*
log "Server prepared."
fi
SERVER_CONFIG="serverconfig.txt"
function setServerProp() {
local prop=$1
local var=$2
if [ -n "$var" ]; then
sed -i "/^${prop}\s*=/ c ${prop}=${var}" "$SERVER_CONFIG"
fi
}
if [ ! -e "$SERVER_CONFIG" ]; then
cp /tmp/serverconfig.txt "$SERVER_CONFIG"
fi
setServerProp "port" "$SERVER_PORT"
setServerProp "worldpath" "worlds"
exec ./TerrariaServer -config "$SERVER_CONFIG" -port "$SERVER_PORT" -steam