forked from notagamedevnono/trinityCore-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·223 lines (168 loc) · 7.36 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·223 lines (168 loc) · 7.36 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
##############################################################################################################
# This script will build TrinityCore from source, extract all data and pack all required binaries, sql files
# and client data into a docker image that can be instantly mounted to spawn a TrinityCore server. Please see
# accomanying README.md for details on how to run.
##############################################################################################################
# Set up some vars to control where/how we work. You don't need to do any here, default values will work fine.
# force exit if anything fails
set -e
# used to time build
SECONDS=0
# path to WoW 3.3.5 client
CLIENT_FOLDER=$(readlink -f ../wowClient)
# path trinity source will be checked out to
SRC_FOLDER=$(readlink -f ../trinitysrc)
# path trinity will be built to. Must be abs path, /opt/trinitycore is highly recommended, this will be the
# same path used in docker container
BUILD_FOLDER=/opt/trinitycore
# path container zips will be placed. These can be transferred to other systems to mount. Assuming you're not
# going to push a 6+gig docker image to the official docker hub, and you probably don't have a private
# container repo, so we're transferring images as bin files
CONTAINER_FOLDER=$(readlink -f ../trinityContainers)
# overbook threads to use for build. You want to build at full tilt, it speeds the build up tremendously
BUILD_THREAD_COUNT=18
# if you want to force this script to build a specific tag, set it here. Use tags only, don't built arbitrary
# hashes, this script hasn't been tested to work with hashes
BUILD_TAG=
# if you want to rebuild and skip compilation and client extraction, use "--partial" switch. This is for
# dev/testing, so don't use this unless you know what you're doing
FULL_BUILD=1
while [ -n "$1" ]; do
case "$1" in
-p|--partial) FULL_BUILD=0 ;;
esac
shift
done
# ensure script was run as sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
##############################################################################################################
# try to test as much as possible before running script so we can catch missing/broken things
# ensure that docker is available
echo "doing docker version check ..."
docker --version
echo "doing git version check ..."
git --version
echo "testing wget"
wget --help
echo "testing curl"
curl --version
##############################################################################################################
# clean out build target folder entirely. we're building into /opt/trinitycore so chown it. We build to
# /opt/trinitycore because trinitycore's make hardcodes its path internally. We want our docker bins to live in
# /opt/trinitycore, so we need to build there
if [ $FULL_BUILD -eq 1 ]; then
rm -rf $BUILD_FOLDER
fi
mkdir -p $BUILD_FOLDER
chown $USER -R $BUILD_FOLDER
# capture this script's path so we can come back here later to fetch our Dockerfile
CWD=$(pwd)
# clone or pull trinity src
if [ ! -d $SRC_FOLDER ]; then
git clone -b 3.3.5 git://github.com/TrinityCore/TrinityCore.git $SRC_FOLDER
else
cd $SRC_FOLDER
git checkout 3.3.5
git reset --hard
git clean -f
git pull
cd --
fi
cd $SRC_FOLDER
# figure out the latest tag in trinity src. We build tags and tags only, because that's how civilized people
# distribute stuff
if [ -z "$BUILD_TAG" ]; then
BUILD_TAG=$(git describe --tags --abbrev=0)
fi
# Now that we have the tag, check it out
git checkout $BUILD_TAG
# construct the name of the full database file for this tag. Trinity expects this honking big sql file to be
# placed in its /bin folder
TAG_DATE=$(git log -1 --format=%ai $BUILD_TAG)
TAG_DATE=${TAG_DATE:0:10}
TAG_DATE=${TAG_DATE//-/_}
FULL_DATABASE_FRAGMENT="${BUILD_TAG}/TDB_full_world_${BUILD_TAG/TDB/}_${TAG_DATE}"
# install build prerequisites. This is an unholy mess that's going to constantly shift as Ubuntu 20.04 gets
# maintainance patches, but we'll hopefully stay sync with our Ubuntu 20.04 docker image by buiding at the
# same time as updating the host. Fingers crossed.
apt-get update
apt-get upgrade -y
apt-get install -y git clang cmake make gcc g++ libmariadbclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev libboost-all-dev=1.71.0.0ubuntu2 mariadb-server p7zip p7zip-full libmariadb-client-lgpl-dev-compat
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang 100
# configure and build
cd $SRC_FOLDER
if [ $FULL_BUILD -eq 1 ]; then
rm -rf build
fi
mkdir -p build
cd build
if [ $FULL_BUILD -eq 1 ]; then
cmake ../ -DCMAKE_INSTALL_PREFIX=$BUILD_FOLDER
make -j $BUILD_THREAD_COUNT
make install
fi
# clean out any trinity extract stuff from wowClient folder, if we don't do this trinity extract will complain
# about contamination
cd $CLIENT_FOLDER
if [ $FULL_BUILD -eq 1 ]; then
rm -rf Buildings
rm -rf Cameras
rm -rf dbc
rm -rf maps
rm -rf mmaps
rm -rf vmaps
fi
# extract data from WoW client, this is where the real time penalty hits
if [ $FULL_BUILD -eq 1 ]; then
${BUILD_FOLDER}/bin/mapextractor
fi
mkdir -p ${BUILD_FOLDER}/data
cp -r dbc maps ${BUILD_FOLDER}/data
if [ $FULL_BUILD -eq 1 ]; then
${BUILD_FOLDER}/bin/vmap4extractor
fi
mkdir -p vmaps
if [ $FULL_BUILD -eq 1 ]; then
${BUILD_FOLDER}/bin/vmap4assembler Buildings vmaps
fi
cp -r vmaps ${BUILD_FOLDER}/data
mkdir -p mmaps
if [ $FULL_BUILD -eq 1 ]; then
${BUILD_FOLDER}/bin/mmaps_generator
fi
cp -r mmaps ${BUILD_FOLDER}/data
# get stock conf files and put them where bins expect them to be
cp ${BUILD_FOLDER}/etc/worldserver.conf.dist ${BUILD_FOLDER}/etc/worldserver.conf
cp ${BUILD_FOLDER}/etc/authserver.conf.dist ${BUILD_FOLDER}/etc/authserver.conf
# get sql files and put them in /sql folder
mkdir -p ${BUILD_FOLDER}/sql
cp -R $SRC_FOLDER/sql ${BUILD_FOLDER}
# download that honking big full database file and unpack it to /bin
wget https://github.com/TrinityCore/TrinityCore/releases/download/${FULL_DATABASE_FRAGMENT}.7z -O ${BUILD_FOLDER}/bin/fulldb.7z
# -aoa = overwrite everything with prompt
7z x ${BUILD_FOLDER}/bin/fulldb.7z -o${BUILD_FOLDER}/bin -aoa
rm ${BUILD_FOLDER}/bin/fulldb.7z
# build docker image using the Dockerfile in this repo.
cd ${BUILD_FOLDER}
docker build -f ${CWD}/DockerFile -t trinitycore .
# Use docker save to pack our container to a tar file, then zip that because it's giant AF and we will almost
# certainly want to transfer it to another server to host. Note that the container has already been tagged to
# match the TrinityCore tag we built from.
mkdir -p $CONTAINER_FOLDER
docker tag trinitycore:latest trinitycore:$BUILD_TAG
docker save trinitycore:$BUILD_TAG > ${CONTAINER_FOLDER}/trinitycore.tar
# stage conf files to container folder, then zip everything up
cp ${BUILD_FOLDER}/etc/worldserver.conf ${CONTAINER_FOLDER}/worldserver.conf
cp ${BUILD_FOLDER}/etc/authserver.conf ${CONTAINER_FOLDER}/authserver.conf
7z a ${CONTAINER_FOLDER}/trinitycore-docker.${BUILD_TAG}.$(date +\%F).7z ${CONTAINER_FOLDER}/trinitycore.tar ${CONTAINER_FOLDER}/worldserver.conf ${CONTAINER_FOLDER}/authserver.conf
# clean up container folder, it should contain only 7z files
rm ${CONTAINER_FOLDER}/*.tar
rm ${CONTAINER_FOLDER}/*.conf
# phew, we're done
DURATION=$SECONDS
echo "build done - time taken : $((($DURATION / 60) % 60)) minutes"