-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·169 lines (137 loc) · 4.92 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·169 lines (137 loc) · 4.92 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
#!/bin/bash
function ask_user() {
read -p "$1 (y/n): " choice
case "$choice" in
y|Y ) return 0;;
* ) return 1;;
esac
}
sed -i "s|^TZ=.*$|TZ=$(cat /etc/timezone)|" src/.env
sudo apt update
# Check if MySQL client is installed
if ! command -v mysql &> /dev/null
then
echo "MySQL client is not installed. Installing mariadb-client now..."
sudo apt install -y mariadb-client
else
echo "MySQL client is already installed."
fi
# Check if Docker is installed
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Installing Docker now..."
# Add Docker's official GPG key:
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
echo "::NOTE::"
echo "Added your user to docker group to manage docker without root."
echo "Log out and back in and rerun setup.sh."
exit 1;
else
echo "Docker is already installed."
fi
# Check if Azeroth Core is installed
if [ -d "azerothcore-wotlk" ]; then
destination_dir="data/sql/custom"
world=$destination_dir"/db_world/"
chars=$destination_dir"/db_characters/"
auth=$destination_dir"/db_auth/"
cd azerothcore-wotlk
rm -rf $world/*.sql
rm -rf $chars/*.sql
rm -rf $auth/*.sql
cd ..
cp src/.env azerothcore-wotlk/
cp src/*.yml azerothcore-wotlk/
cd azerothcore-wotlk
else
if ask_user "Download and install AzerothCore Playerbots?"; then
git clone https://github.com/liyunfan1223/azerothcore-wotlk.git --branch=Playerbot
cp src/.env azerothcore-wotlk/
cp src/*.yml azerothcore-wotlk/
cd azerothcore-wotlk/modules
git clone https://github.com/liyunfan1223/mod-playerbots.git --branch=master
cd ..
else
echo "Aborting..."
exit 1
fi
fi
if ask_user "Install modules?"; then
cd modules
function install_mod() {
local mod_name=$1
local repo_url=$2
if [ -d "${mod_name}" ]; then
echo "${mod_name} exists. Skipping..."
else
if ask_user "Install ${mod_name}?"; then
git clone "${repo_url}"
fi
fi
}
install_mod "mod-aoe-loot" "https://github.com/azerothcore/mod-aoe-loot.git"
install_mod "mod-learn-spells" "https://github.com/noisiver/mod-learnspells.git"
install_mod "mod-fireworks-on-level" "https://github.com/azerothcore/mod-fireworks-on-level.git"
install_mod "mod-individual-progression" "https://github.com/ZhengPeiRu21/mod-individual-progression.git"
cd ..
fi
docker compose up -d --build
cd ..
sudo chown -R 1000:1000 wotlk
# Directory for custom SQL files
custom_sql_dir="src/sql"
auth="acore_auth"
world="acore_world"
chars="acore_characters"
ip_address=$(hostname -I | awk '{print $1}')
# Temporary SQL file
temp_sql_file="/tmp/temp_custom_sql.sql"
# Function to execute SQL files with IP replacement
function execute_sql() {
local db_name=$1
local sql_files=("$custom_sql_dir/$db_name"/*.sql)
if [ -e "${sql_files[0]}" ]; then
for custom_sql_file in "${sql_files[@]}"; do
echo "Executing $custom_sql_file"
temp_sql_file=$(mktemp)
if [[ "$(basename "$custom_sql_file")" == "update_realmlist.sql" ]]; then
sed -e "s/{{IP_ADDRESS}}/$ip_address/g" "$custom_sql_file" > "$temp_sql_file"
else
cp "$custom_sql_file" "$temp_sql_file"
fi
mysql -h "$ip_address" -uroot -ppassword "$db_name" < "$temp_sql_file"
done
else
echo "No SQL files found in $custom_sql_dir/$db_name, skipping..."
fi
}
# Run custom SQL files
echo "Running custom SQL files..."
execute_sql "$auth"
execute_sql "$world"
execute_sql "$chars"
# Clean up temporary file
rm "$temp_sql_file"
echo ""
echo "NOTE:"
echo ""
echo "!!! If ac-db-import failed, run 'sudo chown -R 1000:1000 wotlk' and './setup.sh' again !!!"
echo ""
echo "1. Execute 'docker attach ac-worldserver'"
echo "2. 'account create username password' creates an account."
echo "3. 'account set gmlevel username 3 -1' sets the account as gm for all servers."
echo "4. Ctrl+p Ctrl+q will take you out of the world console."
echo "5. Edit your gameclients realmlist.wtf and set it to $ip_address."
echo "6. Now login to wow with 3.3.5a client!"
echo "7. All config files are copied into the wotlk folder created with setup.sh."