forked from cmangos/wotlk-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstallFullDB.sh
243 lines (209 loc) · 6.81 KB
/
InstallFullDB.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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/bin/bash
####################################################################################################
#
# Simple helper script to insert clean WoTLK-DB
#
####################################################################################################
#internal use
SCRIPT_FILE="./InstallFullDB.sh"
CONFIG_FILE="./InstallFullDB.config"
# testing only
ADDITIONAL_PATH=""
#variables assigned and read from $CONFIG_FILE
MANGOS_DBHOST=""
MANGOS_DBNAME=""
MANGOS_DBUSER=""
MANGOS_DBPASS=""
MYSQL=""
CORE_PATH=""
create_config() {
# Re(create) config file
cat > $CONFIG_FILE << EOF
####################################################################################################
# This is the config file for the '$SCRIPT_FILE' script
#
# You need to insert
# MANGOS_DBHOST: Your MANGOS database host
# MANGOS_DBNAME: Your MANGOS database schema
# MANGOS_DBUSER: Your MANGOS username
# MANGOS_DBPASS: Your MANGOS password
# CORE_PATH: Your path to core's directory (OPTIONAL: Use if you want to apply remaining core updates automatically)
# MYSQL: Your mysql command (usually mysql)
#
####################################################################################################
## Define the host on which the mangos database resides (typically localhost)
MANGOS_DBHOST="localhost"
## Define the database in which you want to add clean WoTLK-DB
MANGOS_DBNAME="mangos"
## Define your username
MANGOS_DBUSER="mangos"
## Define your password (It is suggested to restrict read access to this file!)
MANGOS_DBPASS="mangos"
## Define the path to your core's folder (This is optional)
## If set the core updates located under sql/updates/mangos from this mangos-directory will be added automatically
CORE_PATH=""
## Define your mysql programm if this differs
MYSQL="mysql"
# Enjoy using the tool
EOF
}
display_help() {
echo
echo "Welcome to the WoTLK-DB helper $SCRIPT_FILE"
echo
echo "Run this tool from a bash compatible terminal (on windows like Git Bash)"
echo
echo "To configure edit the file $CONFIG_FILE"
echo
}
# Check if config file present
if [ ! -f $CONFIG_FILE ]
then
create_config
display_help
exit 1
fi
. $CONFIG_FILE
MYSQL_MANGOSDB_CMD="$MYSQL -h$MANGOS_DBHOST -u$MANGOS_DBUSER -p$MANGOS_DBPASS $MANGOS_DBNAME"
## Print header
echo
echo "Welcome to the WoTLK-DB helper $SCRIPT_FILE"
echo
echo "ATTENTION: Your database $MANGOS_DBNAME will be reset to WoTLK-DB!"
echo "Please bring your repositories up-to-date!"
echo "Press CTRL+C to exit"
# show a mini progress bar
for i in {1..19}
do
echo -ne .
sleep 1
done
echo .
## Full
echo "Process UDB 0.12.2"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Full_DB/UDB_0.12.2_mangos_11792_SD2_2279.sql
if [ $? != 0 ]; then exit 1; fi;
## 403
echo "Process Updatepack 403"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/403_corepatch_mangos_11793_to_11840.sql
if [ $? != 0 ]; then exit 1; fi;
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/403_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## 404
echo "Process Updatepack 404"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/404_corepatch_mangos_11841_to_11928.sql
if [ $? != 0 ]; then exit 1; fi;
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/404_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## 405
echo "Process Updatepack 405"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/405_corepatch_mangos_11929_to_12111.sql
if [ $? != 0 ]; then exit 1; fi;
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/405_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## 406
echo "Process Updatepack 406"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/406_corepatch_mangos_12112_to_12444.sql
if [ $? != 0 ]; then exit 1; fi;
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/406_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## 407
echo "Process Updatepack 407"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/407_corepatch_mangos_12445_to_12670.sql
if [ $? != 0 ]; then exit 1; fi;
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/407_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## 408
echo "Process Updatepack 408"
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}Current_Release/Updates/408_updatepack_mangos.sql
if [ $? != 0 ]; then exit 1; fi;
## Change these settings with new updatepacks
LAST_CORE_REV="12943"
# Process files in Updates folder
echo
echo "Applying additional updates from Updates folder"
echo
for f in Updates/*.sql
do
CUR_REV=`basename "$f" | sed 's/^\([0-9]*\)_.*/\1/' `
echo "Applying Update $CUR_REV"
$MYSQL_MANGOSDB_CMD < "$f"
if [ $? != 0 ]; then exit 1; fi;
done
#
# Process core updates if desired
#
if [ "$CORE_PATH" != "" ]
then
if [ ! -e "$CORE_PATH" ]
then
echo "Path to core provided, but directory not found! $CORE_PATH"
exit 1
fi
# Convert path to unix style
CORE_PATH=`(cd "$CORE_PATH"; pwd)`
#
# Core updates
#
echo
echo
echo "Applying additional core updates from path $CORE_PATH"
echo
# process future release folders
for NEXT_MILESTONE in ${NEXT_MILESTONES};
do
# A new milestone was released, apply additional updates
if [ -e "${CORE_PATH}"/sql/updates/archive/${NEXT_MILESTONE}/ ]
then
echo "Apply core updates from milestone $NEXT_MILESTONE"
for f in "${CORE_PATH}"/sql/updates/archive/${NEXT_MILESTONE}/*_*_mangos_*.sql
do
CUR_REV=`basename "$f" | sed 's/^\([0-9]*\)_.*/\1/' `
if [ "$CUR_REV" -gt "$LAST_CORE_REV" ]
then
# found a newer core update file
echo "Append core update `basename "$f"` to database $MANGOS_DBNAME"
$MYSQL_MANGOSDB_CMD < "$f"
if [ $? != 0 ]; then exit 1; fi;
fi
done
fi
done
# Apply remaining files from main folder
for f in "${CORE_PATH}"/sql/updates/mangos/*_*_mangos_*.sql
do
CUR_REV=`basename "$f" | sed 's/^\([0-9]*\)_.*/\1/' `
if [ "$CUR_REV" -gt "$LAST_CORE_REV" ]
then
# found a newer core update file
echo "Append core update `basename "$f"` to database $MANGOS_DBNAME"
$MYSQL_MANGOSDB_CMD < "$f"
if [ $? != 0 ]; then exit 1; fi;
fi
done
echo "All core updates applied"
#
# ScriptDev2 updates
#
# Apply ScriptDev2.sql
echo
echo "Applying $ScriptDev2/scriptdev2.sql ..."
echo
$MYSQL_MANGOSDB_CMD < "${CORE_PATH}"/sql/scriptdev2/scriptdev2.sql
if [ $? != 0 ]; then exit 1; fi;
echo "Recent state of ScriptDev2 applied"
fi
#
# ACID Full file
#
# Apply acid_wotlk.sql
echo
echo "Applying Acid ..."
echo
$MYSQL_MANGOSDB_CMD < ${ADDITIONAL_PATH}ACID/acid_wotlk.sql
if [ $? != 0 ]; then exit 1; fi;
echo "Recent state of ACID applied"
echo
echo "You have now a clean and recent WoTLK-DB database loaded into $MANGOS_DBNAME"
echo "Enjoy using WoTLK-DB"
echo