-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwowsp_cutoff.sh
More file actions
730 lines (625 loc) · 26.3 KB
/
wowsp_cutoff.sh
File metadata and controls
730 lines (625 loc) · 26.3 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
#!/bin/bash
# AzerothCore Single Player WoW Setup Script for Termux
# Compiles everything from GitHub sources
# Usage: curl -fsSL https://raw.githubusercontent.com/duall/singlePlayerWow-android/main/wowsp.sh -o ~/wowsp.sh && bash ~/wowsp.sh
set -e # Exit on any error
SERVER_DIR="$HOME/azeroth-server"
SOURCE_DIR="$HOME/azerothcore-android"
BUILD_DIR="$SOURCE_DIR/build"
AUTOFIX_FLAG="$SERVER_DIR/.autofix_applied"
# Locked commits
AZEROTHCORE_COMMIT="abc884520173084d5cd37b72b57b3822230dcb32"
echo "=== AzerothCore Single Player WoW Setup Script ==="
echo "This script will compile AzerothCore from source for Android/Termux"
echo ""
# Function to check if MariaDB is running
check_mariadb_running() {
if pgrep -f "mariadbd" > /dev/null; then
return 0
else
return 1
fi
}
# Function to start MariaDB if not running
ensure_mariadb_running() {
if ! check_mariadb_running; then
echo "Starting MariaDB..."
mariadbd-safe --datadir="$PREFIX/var/lib/mysql" &
# Wait for MariaDB to be ready
echo "Waiting for MariaDB to start..."
for i in {1..30}; do
if mariadb -u root -e "SELECT 1;" >/dev/null 2>&1; then
print_status "MariaDB started and ready"
break
fi
if [ $i -eq 30 ]; then
print_warning "MariaDB taking longer than expected"
echo "Continuing anyway - it might work..."
else
printf "."
sleep 1
fi
done
else
print_status "MariaDB already running"
fi
}
# Function to launch servers with autofix capability
launch_servers() {
local attempt_autofix=true
# Check if autofix was already applied
if [ -f "$AUTOFIX_FLAG" ]; then
echo "Autofix was previously applied, launching servers directly..."
attempt_autofix=false
fi
if [ "$attempt_autofix" = true ]; then
echo "Starting WorldServer with auto-fix capability..."
# Create log file path in server directory
log_file="$SERVER_DIR/worldserver_output.log"
# Run worldserver in background and capture output
cd "$SERVER_DIR"
./bin/worldserver > "$log_file" 2>&1 &
worldserver_pid=$!
# Show output in real-time but filter warnings
tail -f "$log_file" | grep -v "Deprecated program name\|use.*mariadb.*instead" &
tail_pid=$!
# Check every 5 seconds for up to 20 minutes (240 checks)
echo "Monitoring WorldServer startup..."
for check in {1..240}; do
sleep 5
# Check if the process is still running
if ! kill -0 "$worldserver_pid" 2>/dev/null; then
echo ""
echo "WorldServer process stopped. Running SQL fix..."
kill "$tail_pid" 2>/dev/null || true
break
fi
# Check if it's ready (look for the AC> prompt)
if grep -q "AC>" "$log_file"; then
echo ""
echo "WorldServer fully initialized and ready!"
# Kill monitoring processes
kill "$worldserver_pid" 2>/dev/null || true
kill "$tail_pid" 2>/dev/null || true
wait "$worldserver_pid" 2>/dev/null || true
# Mark autofix as applied (successful startup)
touch "$AUTOFIX_FLAG"
# Give it a moment to release resources
sleep 3
break
fi
# Show progress every 15 seconds
if [ $((check % 3)) -eq 0 ]; then
echo "Still waiting... (${check}0 seconds elapsed)"
fi
done
# Kill any remaining processes
kill "$worldserver_pid" 2>/dev/null || true
kill "$tail_pid" 2>/dev/null || true
wait "$worldserver_pid" 2>/dev/null || true
# If we didn't find AC> prompt, run SQL fix
if ! grep -q "AC>" "$log_file" 2>/dev/null; then
echo "Running integrated SQL fix..."
run_sql_fix
echo "SQL fix completed. Marking autofix as applied..."
touch "$AUTOFIX_FLAG"
fi
echo "Starting servers in tmux in 5 seconds..."
sleep 5
fi
echo "Launching AzerothCore servers in tmux..."
# Kill existing session if it exists
tmux kill-session -t azeroth 2>/dev/null || true
# Start the tmux session
cd "$SERVER_DIR"
tmux new-session -d -c "$SERVER_DIR" -s azeroth './bin/authserver' \; \
split-window -h -c "$SERVER_DIR" './bin/worldserver' \; \
attach
}
# Enhanced integrated SQL fix function
run_sql_fix() {
echo "=== Running Enhanced Integrated SQL Fix ==="
MODULES_DIR="$SOURCE_DIR/modules"
DB_USER="acore"
DB_PASS="acore"
echo "Searching for SQL files in: $MODULES_DIR"
# Function to import SQL file
import_sql() {
local file="$1"
local database="$2"
local relative_path="$3"
echo " Importing: $relative_path -> $database"
if mariadb -u "$DB_USER" -p"$DB_PASS" "$database" < "$file" 2>/dev/null; then
echo " Success"
return 0
else
echo " Failed"
return 1
fi
}
# Check if modules directory exists
if [ ! -d "$MODULES_DIR" ]; then
echo "Warning: Modules directory not found at $MODULES_DIR"
return 1
fi
# Find all modules with SQL data (check both data/sql and sql directories)
modules_with_sql=$(find "$MODULES_DIR" -type d \( -path "*/data/sql" -o -path "*/sql" \) | sed -E 's|/(data/)?sql$||' | sort -u)
if [ -z "$modules_with_sql" ]; then
echo "No modules with SQL data found."
return 0
fi
echo "Found modules with SQL data:"
echo "$modules_with_sql" | sed 's|.*/||' | sed 's/^/ - /'
echo ""
# Process each module
total_files=0
success_count=0
failed_count=0
for module_dir in $modules_with_sql; do
module_name=$(basename "$module_dir")
# Check for both possible SQL directory locations
sql_dir=""
if [ -d "$module_dir/data/sql" ]; then
sql_dir="$module_dir/data/sql"
echo "Processing module: $module_name (using data/sql)"
elif [ -d "$module_dir/sql" ]; then
sql_dir="$module_dir/sql"
echo "Processing module: $module_name (using sql)"
else
echo "Warning: No SQL directory found for module $module_name"
continue
fi
# Find all SQL files in this module
if [ -d "$sql_dir" ]; then
# Find all db-* directories and process them
db_dirs=$(find "$sql_dir" -type d -name "db-*" 2>/dev/null | sort || true)
for db_dir in $db_dirs; do
db_type=$(basename "$db_dir" | sed 's/^db-//')
# Map db type to actual database name
case "$db_type" in
"auth")
target_db="acore_auth"
;;
"characters")
target_db="acore_characters"
;;
"world")
target_db="acore_world"
;;
*)
# For any other db-* directories, try to map to acore_*
target_db="acore_$db_type"
;;
esac
# Find SQL files in this db directory
sql_files=$(find "$db_dir" -name "*.sql" 2>/dev/null || true)
if [ -n "$sql_files" ]; then
echo " Database '$target_db' files:"
while IFS= read -r file; do
if [ -f "$file" ]; then
relative_path="${file#$MODULES_DIR/}"
total_files=$((total_files + 1))
if import_sql "$file" "$target_db" "$relative_path"; then
success_count=$((success_count + 1))
else
failed_count=$((failed_count + 1))
fi
fi
done <<< "$sql_files"
fi
done
# Also check for alternative directory structures (world/, characters/, auth/)
alt_dirs=$(find "$sql_dir" -type d \( -name "world" -o -name "characters" -o -name "auth" \) 2>/dev/null | sort || true)
for alt_dir in $alt_dirs; do
dir_type=$(basename "$alt_dir")
# Map directory type to actual database name
case "$dir_type" in
"auth")
target_db="acore_auth"
;;
"characters")
target_db="acore_characters"
;;
"world")
target_db="acore_world"
;;
esac
# Find SQL files in this directory (including subdirectories)
sql_files=$(find "$alt_dir" -name "*.sql" 2>/dev/null || true)
if [ -n "$sql_files" ]; then
echo " Database '$target_db' files (alt structure):"
while IFS= read -r file; do
if [ -f "$file" ]; then
relative_path="${file#$MODULES_DIR/}"
total_files=$((total_files + 1))
if import_sql "$file" "$target_db" "$relative_path"; then
success_count=$((success_count + 1))
else
failed_count=$((failed_count + 1))
fi
fi
done <<< "$sql_files"
fi
done
fi
echo ""
done
echo "=== SQL Fix Summary ==="
echo "Total files processed: $total_files"
echo "Successful imports: $success_count"
echo "Failed imports: $failed_count"
if [ $failed_count -gt 0 ]; then
echo ""
echo "Some imports failed. This might be normal if:"
echo " - Files contain updates for non-existent tables"
echo " - Files are meant for different AzerothCore versions"
echo " - Dependencies between files exist"
else
echo ""
echo "All SQL files imported successfully!"
fi
}
# Function to check if a package is installed
check_package() {
if dpkg -l | grep -q "^ii $1 "; then
return 0
else
return 1
fi
}
# Function to check if MariaDB user exists
check_mysql_user() {
if mariadb -u root -e "SELECT User FROM mysql.user WHERE User='acore' AND Host='localhost';" 2>/dev/null | grep -q "acore"; then
return 0
else
return 1
fi
}
# Function to print colored output
print_status() {
echo "OK $1"
}
print_step() {
echo ""
echo "=== $1 ==="
}
print_warning() {
echo "WARNING $1"
}
print_error() {
echo "ERROR $1"
}
# Check if worldserver already exists
if [ -f "$SERVER_DIR/bin/worldserver" ]; then
echo "AzerothCore installation found at $SERVER_DIR"
# Ensure MariaDB is running
echo "Checking MariaDB status..."
ensure_mariadb_running
echo "Servers are ready to launch!"
echo ""
echo "Starting servers in:"
for i in 5 4 3 2 1; do
echo " $i..."
sleep 1
done
echo ""
launch_servers
exit 0
fi
echo "Estimated time: 30-60 minutes depending on device performance"
echo ""
# Step 1: Install build dependencies
print_step "Step 1: Installing build dependencies"
PACKAGES=("git" "cmake" "make" "clang" "mariadb" "boost-headers" "boost-static" "tmux" "curl" "unzip" "libc++")
MISSING_PACKAGES=()
echo "Checking for required packages..."
for package in "${PACKAGES[@]}"; do
if ! check_package "$package"; then
MISSING_PACKAGES+=("$package")
fi
done
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
echo "Installing missing packages: ${MISSING_PACKAGES[*]}"
pkg update
pkg install -y "${MISSING_PACKAGES[@]}"
print_status "Dependencies installed"
else
print_status "All dependencies already installed"
fi
echo "Ensuring latest version of critical build tools..."
pkg install -y libc++ clang cmake
print_status "Critical packages upgraded"
# Step 2: Clone AzerothCore source (locked to specific commit)
print_step "Step 2: Downloading AzerothCore source code"
if [ ! -d "$SOURCE_DIR" ]; then
echo "Cloning AzerothCore Android fork..."
git clone https://github.com/duall/azerothcore-android.git "$SOURCE_DIR"
cd "$SOURCE_DIR"
echo "Checking out locked commit $AZEROTHCORE_COMMIT..."
git checkout "$AZEROTHCORE_COMMIT"
print_status "Source code downloaded and locked to commit $AZEROTHCORE_COMMIT"
else
print_status "Source code already exists"
cd "$SOURCE_DIR"
CURRENT_COMMIT=$(git rev-parse HEAD)
if [ "$CURRENT_COMMIT" != "$AZEROTHCORE_COMMIT" ]; then
echo "Resetting to locked commit $AZEROTHCORE_COMMIT..."
git fetch origin
git checkout "$AZEROTHCORE_COMMIT"
print_status "Source code locked to commit $AZEROTHCORE_COMMIT"
else
print_status "Source code already at correct commit"
fi
fi
# Step 2b: Patch Boost compatibility for Boost 1.89+
# boost_system was removed as a standalone library in Boost 1.89 (header-only since 1.69)
print_step "Step 2b: Patching Boost compatibility"
BOOST_CMAKE="$SOURCE_DIR/deps/boost/CMakeLists.txt"
if [ -f "$BOOST_CMAKE" ]; then
if grep -q "system" "$BOOST_CMAKE"; then
echo "Patching deps/boost/CMakeLists.txt for Boost 1.89+ compatibility..."
# Remove 'system' from COMPONENTS list (handles spaces properly)
sed -i -E 's/ system / /g; s/ system$//g; s/^system //g' "$BOOST_CMAKE"
# Also set CMP0167 policy to suppress FindBoost removal warning
if ! grep -q "CMP0167" "$BOOST_CMAKE"; then
sed -i '1i cmake_policy(SET CMP0167 OLD)' "$BOOST_CMAKE"
fi
print_status "Boost compatibility patch applied"
else
print_status "Boost patch already applied"
fi
else
print_warning "deps/boost/CMakeLists.txt not found - skipping patch"
fi
# Step 3: Clone all modules (locked to specific commits)
print_step "Step 3: Downloading AzerothCore modules"
mkdir -p "$SOURCE_DIR/modules"
cd "$SOURCE_DIR/modules"
# Remove any existing modules to ensure clean state
rm -rf mod-* 2>/dev/null || true
echo "Cloning modules with locked commits (this may take a few minutes)..."
# Associative array: "repo_url commit_hash"
MODULES=(
"https://github.com/azerothcore/mod-1v1-arena.git 29748fe1cd20001d97034f533a42c034d822fc7b"
"https://github.com/azerothcore/mod-account-achievements.git bfbe3677635feeef823057964e028e023633115a"
"https://github.com/azerothcore/mod-auto-revive.git ce5ca7a600dbef0dec48dc6da42d374d08d6b728"
"https://github.com/azerothcore/mod-autobalance.git 37455446fe99f073e4a6113987e3228705054639"
"https://github.com/azerothcore/mod-better-item-reloading.git ab4fa9dc28e146e2f0730e989af2c025fac85dd5"
"https://github.com/azerothcore/mod-boss-announcer.git d206190617552ca04540d14b1098cd3717a94c36"
"https://github.com/azerothcore/mod-desertion-warnings.git ed1b7e26869d520b7627c289d461fbc5d040be6a"
"https://github.com/azerothcore/mod-duel-reset.git 8fc67b6baa16cf20d6322b3710f82110dc9ee20b"
"https://github.com/hallgaeuer/mod-dynamic-loot-rates.git 41ffb6a7c5bc78d1c062b8237a9a185892514a32"
"https://github.com/azerothcore/mod-dynamic-xp.git 56033ee97fe400898aea057596e933062821d13e"
"https://github.com/azerothcore/mod-emblem-transfer.git 5d9d0d9ff8c8b80fb33f6615f046b979d5efccb4"
"https://github.com/azerothcore/mod-fireworks-on-level.git e5c58542996e0f1ad3410ebdb7cff9ed9d52e3d6"
"https://github.com/azerothcore/mod-guildhouse.git 23b86dcc78471c50c60b3fc27e07e4cda8a3e200"
"https://github.com/ZhengPeiRu21/mod-individual-progression.git ad2e8e4536275126d55732255e02ac5fd8533b64"
"https://github.com/azerothcore/mod-individual-xp.git a0c60a5da285984dbe8fb028ac4676bf75e573e2"
"https://github.com/azerothcore/mod-instance-reset.git 42ddc011dd6836ad662774472b0b214d32c3ea31"
"https://github.com/noisiver/mod-junk-to-gold.git 2134690bb03899e5c9e44d0682e8e6abf0bbbaf2"
"https://github.com/noisiver/mod-learnspells.git fe63752be467f325ebf283b010325e47a9fce4ff"
"https://github.com/azerothcore/mod-low-level-rbg.git fd6077de0fd49bf2caaae3c5c4dcb857178cf7b9"
"https://github.com/azerothcore/mod-morphsummon.git 28e347515cf97d80f296e5ca072ff2686199c6ca"
"https://github.com/azerothcore/mod-npc-beastmaster.git eb9bdbaaabbf096a22febfbe8a0735a778d96a9e"
"https://github.com/azerothcore/mod-npc-buffer.git 9a755a3ef6ed1f183d8c290729e0db43e174ed64"
"https://github.com/azerothcore/mod-npc-enchanter.git 0c34e45a534d6335732f778eb15eb68bba7f8055"
"https://github.com/Gozzim/mod-npc-spectator.git 8dc107289cf6af9b49945c2c9e6826a29e1dc5a6"
"https://github.com/azerothcore/mod-npc-talent-template.git 43238807f12692dcba96e6cb2b7cc0ac3edcfe51"
"https://github.com/azerothcore/mod-phased-duels.git 349db1972d44dd4b25e24d0e2f0c207bea136ce1"
"https://github.com/DustinHendrickson/mod-player-bot-level-brackets.git 12aac35118c928e423708902f596e961456191c3"
"https://github.com/liyunfan1223/mod-playerbots.git df3c44419de4ec447b1d73de180d3753f3bd8f4c"
"https://github.com/azerothcore/mod-pvp-titles.git 2c7c16a4ff504cb43d60919552581833d7efcb05"
"https://github.com/azerothcore/mod-queue-list-cache.git f10c480f8c43f7716da26150d02903933f50af40"
"https://github.com/azerothcore/mod-quick-teleport.git 3a88ac0f294f7ce21441fb3cb3de13f87c9683eb"
"https://github.com/azerothcore/mod-racial-trait-swap.git 99d1895617bcc1a857c166bccfd4454699f7fdc6"
"https://github.com/azerothcore/mod-random-enchants.git 02a2e0d83b3cfad039bf1967177326aef8dd71f5"
"https://github.com/azerothcore/mod-rdf-expansion.git c7a91c5973cda4529495b52b89375913f98726d6"
"https://github.com/ZhengPeiRu21/mod-reagent-bank.git eceb91d636f56289f8720eea6d3c7e24db07bd43"
"https://github.com/azerothcore/mod-reward-played-time.git fc8a07958213393dbffad035e853bdc18ab66a6e"
"https://github.com/azerothcore/mod-solo-lfg.git 3821fe1d108ade8d2b7ad6611e41154e05864c65"
"https://github.com/azerothcore/mod-top-arena.git 6f3a8eded4e5cd6abab730b633d5e3f0719c9a19"
"https://github.com/azerothcore/mod-transmog.git 949cdfb0b989628064d36d95b0948f8b19ec702f"
"https://github.com/azerothcore/mod-who-logged.git 3f439d0aa56d3a4782dee1467f1bdcb16b35aa2f"
)
FAILED_MODULES=()
for entry in "${MODULES[@]}"; do
repo_url="${entry% *}"
commit_hash="${entry##* }"
module_name=$(basename "$repo_url" .git)
echo "Cloning $module_name..."
if git clone "$repo_url" 2>/dev/null; then
cd "$module_name"
if git checkout "$commit_hash" 2>/dev/null; then
echo " Locked to $commit_hash"
else
echo " WARNING: Failed to checkout commit $commit_hash, using default branch"
FAILED_MODULES+=("$module_name")
fi
cd "$SOURCE_DIR/modules"
else
FAILED_MODULES+=("$module_name")
echo " Failed to clone $module_name, continuing..."
fi
done
if [ ${#FAILED_MODULES[@]} -gt 0 ]; then
print_warning "Some modules had issues: ${FAILED_MODULES[*]}"
echo "The server will still work, but some features may be missing."
else
print_status "All ${#MODULES[@]} modules downloaded and locked successfully"
fi
# Step 4: Configure MariaDB
print_step "Step 4: Configuring MariaDB"
# Initialize MariaDB if needed
if [ ! -d "$PREFIX/var/lib/mysql/mysql" ]; then
echo "Initializing MariaDB database..."
mysql_install_db --datadir="$PREFIX/var/lib/mysql"
print_status "MariaDB initialized"
else
print_status "MariaDB already initialized"
fi
# Configure MySQL version spoofing
if ! grep -q "version=8.0.36" "$PREFIX/etc/my.cnf" 2>/dev/null; then
echo "Adding MySQL version configuration..."
echo -e "\n[mysqld]\nversion=8.0.36" >> "$PREFIX/etc/my.cnf"
print_status "MySQL version configured"
else
print_status "MySQL version already configured"
fi
# Fix MariaDB library link
if [ ! -L "$PREFIX/lib/libmariadb.so" ]; then
echo "Creating MariaDB library link..."
ln -sf "$PREFIX/lib/aarch64-linux-android/libmariadb.so" "$PREFIX/lib/libmariadb.so"
print_status "Library link created"
else
print_status "Library link already exists"
fi
# Step 5: Start MariaDB
print_step "Step 5: Starting MariaDB"
ensure_mariadb_running
# Step 6: Setup database user
print_step "Step 6: Setting up database user"
if ! check_mysql_user; then
echo "Creating acore user..."
# Retry database connection up to 10 times
for attempt in {1..10}; do
if mariadb -u root -e "DROP USER IF EXISTS 'acore'@'localhost'; CREATE USER 'acore'@'localhost' IDENTIFIED BY 'acore';" 2>/dev/null; then
mariadb -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'acore'@'localhost';"
print_status "Database user created and privileges granted"
break
else
if [ $attempt -eq 10 ]; then
print_error "Failed to create database user after 10 attempts"
echo "MariaDB might still be starting. Try running the script again."
exit 1
else
echo " Attempt $attempt failed, retrying in 2 seconds..."
sleep 2
fi
fi
done
else
print_status "Database user already exists"
fi
# Step 7: Create required databases
print_step "Step 7: Creating AzerothCore databases"
echo "Creating required databases..."
if mariadb -u acore -pacore -e "CREATE DATABASE IF NOT EXISTS acore_world; CREATE DATABASE IF NOT EXISTS acore_characters; CREATE DATABASE IF NOT EXISTS acore_auth; CREATE DATABASE IF NOT EXISTS acore_playerbots;" 2>/dev/null; then
print_status "Databases created successfully"
else
print_warning "Failed to create some databases - they may already exist"
fi
# Step 8: Configure and compile AzerothCore
print_step "Step 8: Configuring AzerothCore build"
# Create build directory inside source directory
cd "$SOURCE_DIR"
rm -rf build 2>/dev/null || true
mkdir build
cd build
echo "Running cmake configuration..."
echo "This may take a few minutes..."
# Configure the build
cmake ../ -DCMAKE_INSTALL_PREFIX="$SERVER_DIR" \
-DCMAKE_C_COMPILER=$PREFIX/bin/clang \
-DCMAKE_CXX_COMPILER=$PREFIX/bin/clang++ \
-DWITH_WARNINGS=1 -DTOOLS=0 -DSCRIPTS=static \
-DCMAKE_CXX_FLAGS="-D__ANDROID__ -DANDROID -Wno-deprecated-literal-operator" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-multiple-definition -lunwind"
print_status "Build configured successfully"
# Step 9: Compile AzerothCore
print_step "Step 9: Compiling AzerothCore (this will take 20-45 minutes)"
echo "Starting compilation with $(nproc) CPU cores..."
echo "Please be patient, this is the longest step..."
# Show progress during compilation
START_TIME=$(date +%s)
if make -j$(nproc); then
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
MINUTES=$((DURATION / 60))
SECONDS=$((DURATION % 60))
print_status "Compilation completed in ${MINUTES}m ${SECONDS}s"
else
print_error "Compilation failed!"
echo "This could be due to:"
echo " - Insufficient memory (try closing other apps)"
echo " - Missing dependencies"
echo " - Source code issues"
echo ""
echo "You can try running the compilation manually:"
echo " cd $BUILD_DIR && make -j$(nproc)"
exit 1
fi
# Step 10: Install AzerothCore
print_step "Step 10: Installing AzerothCore"
if make install; then
print_status "AzerothCore installed to $SERVER_DIR"
else
print_error "Installation failed!"
exit 1
fi
# Step 11: Download configuration files
print_step "Step 11: Setting up configuration files"
echo "Downloading configuration files..."
TEMP_CONFIG_DIR="$HOME/temp_configs"
rm -rf "$TEMP_CONFIG_DIR" 2>/dev/null || true
if git clone --filter=blob:none --sparse https://github.com/duall/singlePlayerWow-android.git "$TEMP_CONFIG_DIR"; then
cd "$TEMP_CONFIG_DIR"
git sparse-checkout set configs
# Ensure etc directory exists
mkdir -p "$SERVER_DIR/etc"
# Copy configurations
if [ -d "configs" ]; then
cp -r configs/* "$SERVER_DIR/etc/"
print_status "Configuration files installed"
else
print_warning "Configuration directory not found in repository"
fi
# Cleanup
cd "$HOME"
rm -rf "$TEMP_CONFIG_DIR"
else
print_warning "Failed to download configuration files"
echo "You may need to configure the server manually"
fi
# Step 12: Download server data
print_step "Step 12: Downloading server data files"
echo "Downloading WoW client data (this may take several minutes)..."
DATA_URL="https://github.com/wowgaming/client-data/releases/download/v16/data.zip"
if curl -L "$DATA_URL" -o "$HOME/data.zip"; then
echo "Extracting data files..."
if unzip -q "$HOME/data.zip" -d "$SERVER_DIR/"; then
rm "$HOME/data.zip"
print_status "Server data files installed"
else
print_warning "Failed to extract data files"
rm "$HOME/data.zip" 2>/dev/null || true
fi
else
print_warning "Failed to download server data files"
echo "The server may not work properly without these files"
fi
# Step 13: Final setup and launch
print_step "Step 13: Setup Complete"
# Verify executables exist
if [ ! -f "$SERVER_DIR/bin/authserver" ] || [ ! -f "$SERVER_DIR/bin/worldserver" ]; then
print_error "Server executables not found!"
echo "Expected files:"
echo " $SERVER_DIR/bin/authserver"
echo " $SERVER_DIR/bin/worldserver"
echo ""
echo "Check the compilation step for errors."
exit 1
fi
# Make executables runnable
chmod +x "$SERVER_DIR/bin/authserver"
chmod +x "$SERVER_DIR/bin/worldserver"
echo ""
echo "SUCCESS! AzerothCore has been compiled and installed successfully."
echo "Servers are ready to launch!"
echo ""
echo "Starting servers in:"
for i in 5 4 3 2 1; do
echo " $i..."
sleep 1
done
echo ""
launch_servers