This commit is contained in:
bash
2024-08-12 19:38:48 +00:00
parent d6bd536d0f
commit e677c95d36
15 changed files with 94 additions and 0 deletions

94
scripts/0_variables.sh Executable file
View File

@@ -0,0 +1,94 @@
#!/bin/bash
ROOT_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
##########################################################################################
# USER CONFIG
##########################################################################################
REALM_IP="192.168.178.185"
REALM_NAME="azerothcore.org"
AH_BOT_MIN_ITEMS="25000"
AH_BOT_MAX_ITEMS="30000"
##########################################################################################
# INTERNAL CONFIGS
# https://github.com/azerothcore/azerothcore-wotlk/blob/master/conf/dist
##########################################################################################
AUTHSERVER="${ROOT_DIR}/_server/azerothcore/acore.sh run-authserver"
WORLDSERVER="${ROOT_DIR}/_server/azerothcore/acore.sh run-worldserver"
AUTHSERVER_SESSION="auth-session"
WORLDSERVER_SESSION="world-session"
MYSQL_ROOT_PASSWORD="rootpassword"
MYSQL_USER="acore"
MYSQL_PASSWORD="acore"
MYSQL_DATABASE="acore_auth"
DATAPATH="${ROOT_DIR}/_server/azerothcore/env/dist/bin"
#----------------------------------------------------------------------------------------
# add chmod rights
#----------------------------------------------------------------------------------------
sudo chmod +x ${ROOT_DIR}/*.sh
sudo chmod +x ${ROOT_DIR}/helper/*.sh
#----------------------------------------------------------------------------------------
# Add ~/.bash_wow to ~/.bashrc if not exist
#----------------------------------------------------------------------------------------
if grep -R "bash_wow" ~/.bashrc
then
echo "bash_wow exists";
else
echo " " >> ~/.bashrc
echo "if [ -f ~/.bash_wow ]; then" >> ~/.bashrc
echo " . ~/.bash_wow" >> ~/.bashrc
echo "fi" >> ~/.bashrc
fi
#----------------------------------------------------------------------------------------
# Add variables to ~/.bash_wow
#----------------------------------------------------------------------------------------
echo "export ROOT_DIR=${ROOT_DIR}" > ~/.bash_wow
echo "export REALM_IP=${REALM_IP}" >> ~/.bash_wow
echo "export REALM_NAME=${REALM_NAME}" >> ~/.bash_wow
echo "export AH_BOT_MIN_ITEMS=${AH_BOT_MIN_ITEMS}" >> ~/.bash_wow
echo "export AH_BOT_MAX_ITEMS=${AH_BOT_MAX_ITEMS}" >> ~/.bash_wow
echo "export AUTHSERVER=${AUTHSERVER}" >> ~/.bash_wow
echo "export WORLDSERVER=${WORLDSERVER}" >> ~/.bash_wow
echo "export AUTHSERVER_SESSION=${AUTHSERVER_SESSION}" >> ~/.bash_wow
echo "export WORLDSERVER_SESSION=${WORLDSERVER_SESSION}" >> ~/.bash_wow
echo "export MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" >> ~/.bash_wow
echo "export MYSQL_USER=${MYSQL_USER}" >> ~/.bash_wow
echo "export MYSQL_PASSWORD=${MYSQL_PASSWORD}" >> ~/.bash_wow
echo "export MYSQL_DATABASE=${MYSQL_DATABASE}" >> ~/.bash_wow
echo "export DATAPATH=${DATAPATH}" >> ~/.bash_wow
#----------------------------------------------------------------------------------------
# Add alias to ~/.bash_wow
#----------------------------------------------------------------------------------------
echo "alias install='${ROOT_DIR}/1_source-install.sh'" >> ~/.bash_wow
echo "alias update='${ROOT_DIR}/2_source-update.sh'" >> ~/.bash_wow
echo "alias build='${ROOT_DIR}/3_server-build.sh'" >> ~/.bash_wow
echo "alias compile='${ROOT_DIR}/4_server-compile.sh'" >> ~/.bash_wow
echo "alias config='${ROOT_DIR}/5_server-configure.sh'" >> ~/.bash_wow
echo "alias start='${ROOT_DIR}/6_server-start.sh'" >> ~/.bash_wow
echo "alias stop='tmux kill-server'" >> ~/.bash_wow
echo "alias wow='cd ${ROOT_DIR}/_server/azerothcore;tmux attach -t ${WORLDSERVER_SESSION}'" >> ~/.bash_wow
echo "alias auth='cd ${ROOT_DIR}/_server/azerothcore;tmux attach -t ${AUTHSERVER_SESSION}'" >> ~/.bash_wow
#----------------------------------------------------------------------------------------
# Print alias
#----------------------------------------------------------------------------------------
echo " "
echo "###########################################################################################"
echo "## After the first install or changes either reboot or TYPE 'source ~/.bashrc' !!!!!!!!"
echo "###########################################################################################"
echo "## After the above you can use the following commands:"
echo "### install - Download the source source-code"
echo "### update - Updates source-code to latest version"
echo "### build - Builds the server based on source-code"
echo "### compile - Compiles the code based on the build server"
echo "### config - Applies the server configration"
echo "### start - starts auth and world in tmux sessions server"
echo "### stop - stops all sessions"
echo "### wow - logon world-server (tmux) session"
echo "### auth - logon auth-server (tmux) session"
echo "###########################################################################################"

65
scripts/1_source-install.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
read -p "This will install the source code. Are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# General dependencies
##########################################################################################
sudo apt update && sudo apt install -y unzip git sudo git
##########################################################################################
# Create download folder
##########################################################################################
if [ ! -d "${ROOT_DIR}/_download" ];
then
mkdir ${ROOT_DIR}/_download
fi
##########################################################################################
# Clone azerothcore (playerbot fork)
##########################################################################################
sudo rm -rf ${ROOT_DIR}/_download/azerothcore > /dev/null 2>&1
git config --global --add safe.directory "${ROOT_DIR}/_download/azerothcore"
git clone https://github.com/liyunfan1223/azerothcore-wotlk.git --branch=Playerbot ${ROOT_DIR}/_download/azerothcore
##########################################################################################
# Clone module playerbots
##########################################################################################
sudo rm -rf ${ROOT_DIR}/_download/modules/mod-playerbots > /dev/null 2>&1
git config --global --add safe.directory "${ROOT_DIR}/_download/modules/mod-playerbots"
git clone https://github.com/liyunfan1223/mod-playerbots.git ${ROOT_DIR}/_download/modules/mod-playerbots
##########################################################################################
# Clone module ah-bot
##########################################################################################
sudo rm -rf ${ROOT_DIR}/_download/modules/mod-ah-bot > /dev/null 2>&1
git config --global --add safe.directory "${ROOT_DIR}/_download/modules/mod-ah-bot"
git clone https://github.com/azerothcore/mod-ah-bot.git ${ROOT_DIR}/_download/modules/mod-ah-bot
##########################################################################################
# Download client-data (only if file does not exist)
##########################################################################################
if ! [ -f ${ROOT_DIR}/_data/data.zip ];
then
mkdir -p ${ROOT_DIR}/_data > /dev/null 2>&1
sudo curl -L https://github.com/wowgaming/client-data/releases/download/v16/data.zip --output ${ROOT_DIR}/_data/data.zip
fi
##########################################################################################
# set azerothcore playerbot fork upstream with original azerothcore
##########################################################################################
cd ${ROOT_DIR}/_download/azerothcore && git remote add upstream https://github.com/azerothcore/azerothcore-wotlk.git
echo "Executed..."
fi

40
scripts/2_source-update.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
read -p "This will update the source code. Are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# General dependencies
##########################################################################################
sudo apt update && sudo apt install -y git
##########################################################################################
# reset azerothcore to latest branch
##########################################################################################
git -C ${ROOT_DIR}/_download/azerothcore fetch origin
git -C ${ROOT_DIR}/_download/azerothcore clean -fd
git -C ${ROOT_DIR}/_download/azerothcore reset --hard origin/Playerbot
##########################################################################################
# reset mod-playerbots to latest branch
##########################################################################################
git -C ${ROOT_DIR}/_download/modules/mod-playerbots fetch origin
git -C ${ROOT_DIR}/_download/modules/mod-playerbots clean -fd
git -C ${ROOT_DIR}/_download/modules/mod-playerbots reset --hard origin/master
##########################################################################################
# reset mod-ah-bot to latest branch
##########################################################################################
git -C ${ROOT_DIR}/_download/modules/mod-ah-bot fetch origin
git -C ${ROOT_DIR}/_download/modules/mod-ah-bot clean -fd
git -C ${ROOT_DIR}/_download/modules/mod-ah-bot reset --hard origin/master
echo "Executed..."
fi

32
scripts/3_server-build.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
read -p "This will build server. Are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# General dependencies
##########################################################################################
sudo apt update && sudo apt install -y unzip
##########################################################################################
# Rebuild server folder based on downloaded source codes
##########################################################################################
sudo rm -rf ${ROOT_DIR}/_server > /dev/null 2>&1
mkdir -p ${ROOT_DIR}/_server/azerothcore/modules && \
cp -r ${ROOT_DIR}/_download/azerothcore ${ROOT_DIR}/_server && \
cp -r ${ROOT_DIR}/_download/modules ${ROOT_DIR}/_server/azerothcore || exit 1
##########################################################################################
# Copy client-data into server folder (instead of ./acore.sh client-data)
##########################################################################################
unzip ${ROOT_DIR}/_data/data.zip -d ${DATAPATH} || exit 1
echo "Executed..."
fi

60
scripts/4_server-compile.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
read -p "This will compile server. Are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# General dependencies
##########################################################################################
sudo apt update && \
sudo apt full-upgrade -y && \
sudo apt-get install -y \
btop \
tmux \
sudo \
curl \
net-tools \
locate \
nano \
software-properties-common
##########################################################################################
# Install core dependencies (https://www.azerothcore.org/wiki/linux-requirements)
##########################################################################################
sudo ${ROOT_DIR}/_server/azerothcore/acore.sh install-deps && \
sudo apt-get update && \
sudo apt-get install \
git \
cmake \
make \
gcc \
g++ \
clang \
libmysqlclient-dev \
libssl-dev \
libbz2-dev libreadline-dev \
libncurses-dev mysql-server \
libboost-all-dev
##########################################################################################
# Compile the code
# https://github.com/azerothcore/azerothcore-wotlk/blob/master/apps/compiler/compiler.sh
##########################################################################################
sudo ${ROOT_DIR}/_server/azerothcore/acore.sh compiler clean
sudo ${ROOT_DIR}/_server/azerothcore/acore.sh compiler configure
sudo ${ROOT_DIR}/_server/azerothcore/acore.sh compiler compile
##########################################################################################
# Ensure all folder and files are accesible for the current user
##########################################################################################
sudo find ${ROOT_DIR}/_server/ -user root -exec sudo chown $USER: {} +
echo "Executed..."
fi

58
scripts/5_server-configure.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
read -p "This will configur the server, are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# Enable mysql server
##########################################################################################
sudo service mysql start
##########################################################################################
# Create acore account
##########################################################################################
sudo mysql -u root -e "CREATE DATABASE IF NOT EXISTS acore_auth;"
sudo mysql -u root -e "CREATE USER IF NOT EXISTS 'acore'@'%' IDENTIFIED BY 'acore';"
sudo mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'acore'@'%';"
sudo mysql -u root -e "FLUSH PRIVILEGES;"
##########################################################################################
# Recompile default conf files
##########################################################################################
sudo ${ROOT_DIR}/_server/azerothcore/acore.sh compiler configure
##########################################################################################
# Ensure all folder and files are accesible for the current user
##########################################################################################
sudo find ${ROOT_DIR}/_server/ -user root -exec sudo chown $USER: {} +
##########################################################################################
# Server config merge
##########################################################################################
sudo cat ${ROOT_DIR}/config/authserver.conf \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/authserver.conf.dist > \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/authserver.conf | exit 1
sudo cat ${ROOT_DIR}/config/worldserver.conf \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/worldserver.conf.dist > \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/worldserver.conf | exit 1
###########################################################################################
## Modules config merge
###########################################################################################
sudo cat ${ROOT_DIR}/config/modules/playerbots.conf \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/modules/playerbots.conf.dist > \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/modules/playerbots.conf | exit 1
sudo cat ${ROOT_DIR}/config/modules/mod_ahbot.conf \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/modules/mod_ahbot.conf.dist > \
${ROOT_DIR}/_server/azerothcore/env/dist/etc/modules/mod_ahbot.conf | exit 1
fi

68
scripts/6_server-start.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
##########################################################################################
# Apply server realm configuration
##########################################################################################
source ${ROOT_DIR}/helper/update_realm_ip.sh ${REALM_IP}
source ${ROOT_DIR}/helper/update_realm_ip.sh ${REALM_NAME}
echo " "
##########################################################################################
# Apply ah-bot custom configuration
##########################################################################################
source ${ROOT_DIR}/helper/update_ahbot_config.sh ${AH_BOT_MIN_ITEMS} ${AH_BOT_MAX_ITEMS}
echo " "
##########################################################################################
# Clear playerbots account and characters (enforces performance and bot levels balance)
##########################################################################################
source ${ROOT_DIR}/helper/clear_playerbots.sh
echo " "
##########################################################################################
# handle the tmux sessions
##########################################################################################
if tmux new-session -d -s $AUTHSERVER_SESSION; then
echo "Created authserver session: $AUTHSERVER_SESSION"
else
echo "Error when trying to create authserver session: $AUTHSERVER_SESSION"
fi
echo " "
if tmux new-session -d -s $WORLDSERVER_SESSION; then
echo "Created worldserver session: $WORLDSERVER_SESSION"
else
echo "Error when trying to create worldserver session: $WORLDSERVER_SESSION"
fi
echo " "
if tmux send-keys -t $AUTHSERVER_SESSION "$AUTHSERVER" C-m; then
echo "Executed \"$AUTHSERVER\" inside $AUTHSERVER_SESSION"
#echo "You can attach to $AUTHSERVER_SESSION and check the result using \"tmux attach -t $AUTHSERVER_SESSION\""
else
echo "Error when executing \"$AUTHSERVER\" inside $AUTHSERVER_SESSION"
fi
echo " "
if tmux send-keys -t $WORLDSERVER_SESSION "$WORLDSERVER" C-m; then
echo "Executed \"$WORLDSERVER\" inside $WORLDSERVER_SESSION"
#echo "You can attach to $WORLDSERVER_SESSION and check the result using \"tmux attach -t $WORLDSERVER_SESSION\""
else
echo "Error when executing \"$WORLDSERVER\" inside $WORLDSERVER_SESSION"
fi
echo " "
echo "###########################################################################################"
echo "## After the above you can use the following commands:"
echo "### update - Updates source-code to latest version"
echo "### build - Builds the server based on source-code"
echo "### compile - Compiles the code based on the build server"
echo "### config - Applies the server configration"
echo "### start - starts auth and world in tmux sessions server"
echo "### stop - stops all sessions"
echo "### wow - logon world-server (tmux) session"
echo "### auth - logon auth-server (tmux) session"
echo "###########################################################################################"

5
scripts/clear_auctionhouse.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
sudo mysql -u root --database="acore_characters" < ${ROOT_DIR}/sql/clear_auctionhouse.sql
echo "Auction house items deleted..."

5
scripts/clear_playerbots.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
sudo mysql -u root --database="acore_characters" < ${ROOT_DIR}/sql/clear_playerbots.sql
echo "Playerbots accounts and characters deleted..."

15
scripts/find_characters.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# param 1
ACCOUNT_NAME=$1;
if [ -z "$ACCOUNT_NAME" ]
then
echo "First parameter 'ACCOUNT_NAME' is required";
exit 1;
fi
sed -e "s/{{ACCOUNT_NAME}}/$ACCOUNT_NAME/g" \
"${ROOT_DIR}/sql/find_character.sql" > "/tmp/find_character.sql"
sudo mysql -u root --database="acore_characters" < /tmp/find_character.sql
echo "Find character executed..."

5
scripts/git-alias.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
# Alias GIT (git lg for git commits, git ls for commits with changed files)
git config --global alias.lg 'log --graph --abbrev-commit --decorate --date=relative --all'
git config --global alias.ls 'log --stat --pretty=short --graph'

26
scripts/merge_core.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
##########################################################################################
# General dependencies
##########################################################################################
sudo apt update && sudo apt install -y git
read -p "Merge the orginal azerothcore code into the playerbot azerothcore, are you sure? (Y)es/(N)o: " -n 1 -r
echo " ";
if [[ $REPLY =~ ^[Yy]$ ]];
then
##########################################################################################
# Try to merge from the orginal azerothcore into the playerbot azerothcore fork branch
##########################################################################################
cd ${ROOT_DIR}/_download/azerothcore
git reset --hard origin/Playerbot
git fetch upstream
git merge upstream/master
echo " "
echo "###########################################################################################"
echo "## If (conflict) error just run update (2_update.sh) again to restore to the latest"
echo "## version of the playerbot branch"
echo "###########################################################################################"
fi

26
scripts/update_ahbot_config.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# param 1
AH_BOT_MIN_ITEMS=$1;
if [ -z "$AH_BOT_MIN_ITEMS" ]
then
echo "First parameter 'AH_BOT_MIN_ITEMS' is required";
echo "Second parameter 'AH_BOT_MAX_ITEMS' is required";
exit 1;
fi
# param 2
AH_BOT_MAX_ITEMS=$2;
if [ -z "$AH_BOT_MAX_ITEMS" ]
then
echo "Second parameter 'AH_BOT_MAX_ITEMS' is required";
exit 1;
fi
sed -e "s/{{AH_BOT_MIN_ITEMS}}/$AH_BOT_MIN_ITEMS/g" \
-e "s/{{AH_BOT_MAX_ITEMS}}/$AH_BOT_MAX_ITEMS/g" \
"${ROOT_DIR}/../sql/update_ahbot_config.sql" > "/tmp/update_ahbot_config.sql"
sudo mysql -u root --database="acore_characters" < /tmp/update_ahbot_config.sql
echo "AH-bot config updated..."

15
scripts/update_realm_ip.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# param 1
REALM_IP=$1;
if [ -z "$REALM_IP" ]
then
echo "First parameter 'REALM_IP' is required";
exit 1;
fi
sed -e "s/{{REALM_IP}}/$REALM_IP/g" \
"${ROOT_DIR}/sql/update_realm_ip.sql" > "/tmp/update_realm_ip.sql"
sudo mysql -u root --database="acore_characters" < /tmp/update_realm_ip.sql
echo "Server realm IP updated..."

15
scripts/update_realm_name.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
#param 1
REALM_NAME=$1;
if [ -z "$REALM_NAME" ]
then
echo "First parameter 'REALM_NAME' is required";
exit 1;
fi
sed -e "s/{{REALM_NAME}}/$REALM_NAME/g" \
"${ROOT_DIR}/sql/update_realm_name.sql" > "/tmp/update_realm_name.sql"
sudo mysql -u root --database="acore_characters" < /tmp/update_realm_name.sql
echo "Server realm name updated..."