ported double tracking from TC

This commit is contained in:
mikx
2020-10-30 23:45:46 -04:00
commit 44b1f31c23
4914 changed files with 4961129 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
function registerHooks() { hwc_event_register_hooks "$@"; }
function runHooks() { hwc_event_run_hooks "$@"; }
source "$AC_PATH_CONF/dist/config.sh" # include dist to avoid missing conf variables
if [ -f "$AC_PATH_CONF/config.sh" ]; then
source "$AC_PATH_CONF/config.sh" # should overwrite previous
else
echo "NOTICE: file <$AC_PATH_CONF/config.sh> has not been found, you should create and configure it."
fi
#
# Load modules
#
for entry in "$AC_PATH_MODULES/"*/include.sh
do
if [ -e $entry ]; then
source $entry
fi
done
ACORE_VERSION=$("$AC_PATH_DEPS/jsonpath/JSONPath.sh" -f $AC_PATH_ROOT/acore.json -b '$.version')

View File

@@ -0,0 +1,13 @@
unamestr=`uname`
if [[ "$unamestr" == 'Darwin' ]]; then
AC_PATH_ROOT=$(greadlink -f "$AC_PATH_APPS/../")
else
AC_PATH_ROOT=$(readlink -f "$AC_PATH_APPS/../")
fi
AC_PATH_CONF="$AC_PATH_ROOT/conf"
AC_PATH_MODULES="$AC_PATH_ROOT/modules"
AC_PATH_DEPS="$AC_PATH_ROOT/deps"

View File

@@ -0,0 +1,17 @@
[[ ${GUARDYVAR:-} -eq 1 ]] && return || readonly GUARDYVAR=1 # include it once
# force default language for applications
LC_ALL=C
AC_PATH_APPS="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
AC_PATH_SHARED="$AC_PATH_APPS/bash_shared"
source "$AC_PATH_SHARED/defines.sh"
source "$AC_PATH_DEPS/hw-core/bash-lib-event/src/hooks.sh"
source "$AC_PATH_SHARED/common.sh"
[[ "$OSTYPE" = "msys" ]] && AC_BINPATH_FULL="$BINPATH" || AC_BINPATH_FULL="$BINPATH/bin"

11
apps/ci/ci-compile.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
echo "compile core"
export CCACHE_CPP2=true
export CCACHE_MAXSIZE='500MB'
export CCACHE_COMPRESS=1
ccache -s
./acore.sh "compiler" "all"
ccache -s

17
apps/ci/ci-error-check.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
DB_ERRORS_FILE="./env/dist/bin/DBErrors.log";
if [[ ! -f ${DB_ERRORS_FILE} ]]; then
echo "File ${DB_ERRORS_FILE} not found!";
exit 1
fi
if [[ -s ${DB_ERRORS_FILE} ]]; then
printf "The DBErrors.log file contains startup errors:\n\n";
cat ${DB_ERRORS_FILE};
printf "\nPlease solve the startup errors listed above!\n";
exit 1;
else
echo "No startup errors found in DBErrors.log, good job!";
fi

14
apps/ci/ci-import-db.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
sudo systemctl start mysql
./acore.sh "db-assembler" "import-all"
if [ -s modules/mod-premium/sql/example_item_9017.sql ]
then
echo "Import custom module item..."
# if the premium module is available insert the example item or else the worldserver dry run will fail
mysql -uroot -proot acore_world < modules/mod-premium/sql/example_item_9017.sql
echo "Done!"
fi

View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
echo "install modules"
git clone --depth=1 --branch=master --recursive https://github.com/azerothcore/mod-eluna-lua-engine.git modules/mod-eluna-lua-engine
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-autobalance.git modules/mod-autobalance
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-transmog.git modules/mod-transmog
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-npc-beastmaster.git modules/mod-npc-beastmaster
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-duel-reset.git modules/mod-duel-reset
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-premium modules/mod-premium

58
apps/ci/ci-install.sh Normal file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
set -e
cat >>conf/config.sh <<CONFIG_SH
MTHREADS=$(($(grep -c ^processor /proc/cpuinfo) + 2))
CWARNINGS=ON
CDEBUG=OFF
CTYPE=Release
CSCRIPTS=ON
CUNIT_TESTS=ON
CSERVERS=ON
CTOOLS=ON
CSCRIPTPCH=OFF
CCOREPCH=OFF
CCUSTOMOPTIONS='-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"'
DB_CHARACTERS_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
DB_AUTH_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
DB_WORLD_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
CONFIG_SH
time sudo apt-get update -y
# time sudo apt-get upgrade -y
time sudo apt-get install -y git lsb-release sudo ccache
time ./acore.sh install-deps
case $COMPILER in
# this is in order to use the "default" clang version of the OS, without forcing a specific version
"clang" )
time sudo apt-get install -y clang
echo "CCOMPILERC=\"clang\"" >> ./conf/config.sh
echo "CCOMPILERCXX=\"clang++\"" >> ./conf/config.sh
;;
"clang6" )
time sudo apt-get install -y clang-6.0
echo "CCOMPILERC=\"clang-6.0\"" >> ./conf/config.sh
echo "CCOMPILERCXX=\"clang++-6.0\"" >> ./conf/config.sh
;;
"clang9" )
time sudo apt-get install -y clang-9
echo "CCOMPILERC=\"clang-9\"" >> ./conf/config.sh
echo "CCOMPILERCXX=\"clang++-9\"" >> ./conf/config.sh
;;
"clang10" )
time sudo apt-get install -y clang-10
echo "CCOMPILERC=\"clang-10\"" >> ./conf/config.sh
echo "CCOMPILERCXX=\"clang++-10\"" >> ./conf/config.sh
;;
* )
echo "Unknown compiler $COMPILER"
exit 1
;;
esac

View File

@@ -0,0 +1,3 @@
#!/bin/bash
time var/build/obj/src/test/unit_tests

View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
echo "[worldserver]" >> ./env/dist/etc/worldserver.conf
echo "DataDir = \"../data/\"" >> ./env/dist/etc/worldserver.conf
echo "LoginDatabaseInfo = \"localhost;3306;root;root;acore_auth\"" >> ./env/dist/etc/worldserver.conf
echo "WorldDatabaseInfo = \"localhost;3306;root;root;acore_world\"" >> ./env/dist/etc/worldserver.conf
echo "CharacterDatabaseInfo = \"localhost;3306;root;root;acore_characters\"" >> ./env/dist/etc/worldserver.conf
git clone --depth=1 --branch=master --single-branch https://github.com/ac-data/ac-data.git ./env/dist/data
(cd ./env/dist/bin/ && timeout 5m ./worldserver --dry-run)

11
apps/ci/docker/.env.dist Normal file
View File

@@ -0,0 +1,11 @@
WORLDSERVER_DATA=./docker/worldserver/data
WORLDSERVER_ETC=./docker/worldserver/etc
WORLDSERVER_LOGS=./docker/worldserver/logs
AUTHSERVER_ETC=./docker/authserver/etc
AUTHSERVER_LOGS=./docker/authserver/logs
WORLD_EXTERNAL_PORT=8085
AUTH_EXTERNAL_PORT=3724
DB_EXTERNAL_PORT=9000
DB_ROOT_PASSWORD=password

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cp apps/ci/docker/.env.dist .env

30
apps/ci/mac/ci-compile.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
export CCACHE_CPP2=true
export CCACHE_MAXSIZE='2G'
export CCACHE_COMPRESS=1
ccache -s
mkdir var/build/obj && cd var/build/obj;
time cmake ../../../ \
-DTOOLS=1 \
-DUNIT_TESTS=1 \
-DSCRIPTS=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DMYSQL_ADD_INCLUDE_PATH=/usr/local/include \
-DMYSQL_LIBRARY=/usr/local/lib/libmysqlclient.dylib \
-DREADLINE_INCLUDE_DIR=/usr/local/opt/readline/include \
-DREADLINE_LIBRARY=/usr/local/opt/readline/lib/libreadline.dylib \
-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include \
-DOPENSSL_SSL_LIBRARIES=/usr/local/opt/openssl/lib/libssl.dylib \
-DOPENSSL_CRYPTO_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.dylib \
-DCMAKE_C_FLAGS="-Werror" \
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
;
time make -j $(($(sysctl -n hw.ncpu ) + 2))
ccache -s

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
time brew update
time brew install openssl readline ace coreutils bash bash-completion mysql ccache

2
apps/compiler/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
config.sh

32
apps/compiler/README.md Normal file
View File

@@ -0,0 +1,32 @@
## How to compile:
first of all, if you need some custom configuration you have to copy
/conf/dist/config.sh in /conf/config.sh and configure it
* for a "clean" compilation you must run all scripts in their order:
./1-clean.sh
./2-configure.sh
./3-build.sh
* if you add/rename/delete some sources and you need to compile it you have to run:
./2-configure.sh
./3-build.sh
* if you have modified code only, you just need to run
./3-build.sh
## compiler.sh
compiler.sh script contains an interactive menu to clean/compile/build. You can also run actions directly by command lines specifying the option.
Ex:
./compiler.sh 3
It will start the build process (it's equivalent to ./3-build.sh)
## Note:
For an optimal development process and **really faster** compilation time, is suggested to use clang instead of gcc

72
apps/compiler/compiler.sh Normal file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -e
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
function run_option() {
re='^[0-9]+$'
if [[ $1 =~ $re ]] && test "${comp_functions[$1-1]+'test'}"; then
${comp_functions[$1-1]}
elif [ -n "$(type -t comp_$1)" ] && [ "$(type -t comp_$1)" = function ]; then
fun="comp_$1"
$fun
else
echo "invalid option, use --help option for the commands list"
fi
}
function comp_quit() {
exit 0
}
comp_options=(
"build: Configure and compile"
"clean: Clean build files"
"configure: Run CMake"
"compile: Compile only"
"all: clean, configure and compile"
"quit: Close this menu")
comp_functions=(
"comp_build"
"comp_clean"
"comp_configure"
"comp_compile"
"comp_all"
"comp_quit")
PS3='[ Please enter your choice ]: '
runHooks "ON_AFTER_OPTIONS" #you can create your custom options
function _switch() {
_reply="$1"
_opt="$2"
case $_reply in
""|"--help")
echo "Available commands:"
printf '%s\n' "${options[@]}"
;;
*)
run_option $_reply $_opt
;;
esac
}
while true
do
# run option directly if specified in argument
[ ! -z $1 ] && _switch $@
[ ! -z $1 ] && exit 0
select opt in "${comp_options[@]}"
do
echo "==== ACORE COMPILER ===="
_switch $REPLY
break;
done
done

View File

@@ -0,0 +1,7 @@
# you can choose build type from cmd argument
if [ ! -z $1 ]
then
CCTYPE=$1
CCTYPE=${CCTYPE^} # capitalize first letter if it's not yet
fi

View File

@@ -0,0 +1,73 @@
function comp_clean() {
echo "Cleaning build files"
CWD=$(pwd)
cd $BUILDPATH
make -f Makefile clean || true
make clean || true
find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
cd $CWD
}
function comp_configure() {
CWD=$(pwd)
cd $BUILDPATH
echo "Build path: $BUILDPATH"
echo "DEBUG info: $CDEBUG"
echo "Compilation type: $CTYPE"
# -DCMAKE_BUILD_TYPE=$CCTYPE disable optimization "slow and huge amount of ram"
# -DWITH_COREDEBUG=$CDEBUG compiled with debug information
#-DSCRIPTS_COMMANDS=$CSCRIPTS -DSCRIPTS_CUSTOM=$CSCRIPTS -DSCRIPTS_EASTERNKINGDOMS=$CSCRIPTS -DSCRIPTS_EVENTS=$CSCRIPTS -DSCRIPTS_KALIMDOR=$CSCRIPTS \
#-DSCRIPTS_NORTHREND=$CSCRIPTS -DSCRIPTS_OUTDOORPVP=$CSCRIPTS -DSCRIPTS_OUTLAND=$CSCRIPTS -DSCRIPTS_PET=$CSCRIPTS -DSCRIPTS_SPELLS=$CSCRIPTS -DSCRIPTS_WORLD=$CSCRIPTS \
#-DAC_WITH_UNIT_TEST=$CAC_UNIT_TEST -DAC_WITH_PLUGINS=$CAC_PLG \
local DCONF=""
if [ ! -z "$CONFDIR" ]; then
DCONF="-DCONF_DIR=$CONFDIR"
fi
cmake $SRCPATH -DCMAKE_INSTALL_PREFIX=$BINPATH $DCONF -DSERVERS=$CSERVERS \
-DSCRIPTS=$CSCRIPTS \
-DUNIT_TESTS=$CUNIT_TESTS \
-DTOOLS=$CTOOLS -DUSE_SCRIPTPCH=$CSCRIPTPCH -DUSE_COREPCH=$CCOREPCH -DWITH_COREDEBUG=$CDEBUG -DCMAKE_BUILD_TYPE=$CTYPE -DWITH_WARNINGS=$CWARNINGS \
-DCMAKE_C_COMPILER=$CCOMPILERC -DCMAKE_CXX_COMPILER=$CCOMPILERCXX "-DDISABLED_AC_MODULES=$CDISABLED_AC_MODULES" $CCUSTOMOPTIONS
cd $CWD
runHooks "ON_AFTER_CONFIG"
}
function comp_compile() {
[ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2))
echo "Using $MTHREADS threads"
CWD=$(pwd)
cd $BUILDPATH
time make -j $MTHREADS
make -j $MTHREADS install
cd $CWD
runHooks "ON_AFTER_BUILD"
}
function comp_build() {
comp_configure
comp_compile
}
function comp_all() {
comp_clean
comp_build
}

View File

@@ -0,0 +1,23 @@
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/../../bash_shared/includes.sh"
AC_PATH_COMPILER="$AC_PATH_APPS/compiler"
if [ -f "$AC_PATH_COMPILER/config.sh" ]; then
source "$AC_PATH_COMPILER/config.sh" # should overwrite previous
fi
function ac_on_after_build() {
# move the run engine
cp -rvf "$AC_PATH_APPS/startup-scripts/"* "$BINPATH"
}
registerHooks "ON_AFTER_BUILD" ac_on_after_build
source "$AC_PATH_COMPILER/includes/defines.sh"
source "$AC_PATH_COMPILER/includes/functions.sh"
mkdir -p $BUILDPATH
mkdir -p $BINPATH

3
apps/db_assembler/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/output/
/backup/
config.sh

View File

@@ -0,0 +1,22 @@
## Description
This script allows you to assemble all sql files into one so you can easily import it to your databases (or use the main script to import directly). By default, it creates the merged files in `/env/dist`.
## How to use:
First of all, if you need some custom configuration, you have to copy `/conf/dist/config.sh` to `/conf/config.sh` and configure it. The file is here: https://github.com/azerothcore/azerothcore-wotlk/tree/master/conf
_Read it because there are several options to configure._
`db_assembler.sh` script contains an interactive menu to assemble and import sql files.
Just run it to display the options.
Note: You can even use actions directly by command lines specifying the option.
Ex:
./db_assembler.sh 1
It will merge all sql files without an interactive menu.

View File

@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -e
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
cmdopt=$1
PS3='[Please enter your choice]: '
options=(
"all: Assemble all" # 1
"bases: Assemble only bases" # 2
"updates: Assemble only updates" # 3
"customs: Assemble only customs" # 4
"import-all: Assemble & Import all" # 5
"import-bases: Assemble & Import only bases" # 6
"import-updates: Assemble & Import only updates" # 7
"import-customs: Assemble & Import only customs" # 8
"quit: Exit from this menu" # 9
)
function _switch() {
_reply="$1"
_opt="$2"
case $_reply in
""|"all"|"1")
dbasm_run true true true
;;
""|"bases"|"2")
dbasm_run true false false
;;
""|"updates"|"3")
dbasm_run false true false
;;
""|"customs"|"4")
dbasm_run false false true
;;
""|"import-all"|"5")
dbasm_import true true true
;;
""|"import-bases"|"6")
dbasm_import true false false
;;
""|"import-updates"|"7")
dbasm_import false true false
;;
""|"import-customs"|"8")
dbasm_import false false true
;;
""|"quit"|"9")
echo "Goodbye!"
exit
;;
""|"--help")
echo "Available commands:"
printf '%s\n' "${options[@]}"
;;
*) echo "invalid option, use --help option for the commands list";;
esac
}
while true
do
# run option directly if specified in argument
[ ! -z $1 ] && _switch $@
[ ! -z $1 ] && exit 0
select opt in "${options[@]}"
do
echo "===== DB ASSEMBLER MENU ====="
_switch $REPLY
break
done
done

View File

@@ -0,0 +1,381 @@
# globals
PROMPT_USER=""
PROMPT_PASS=""
# use in a subshell
function dbasm_resetExitCode() {
exit 0
}
function dbasm_mysqlExec() {
confs=$1
command=$2
options=$3
eval $confs
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
fi
export MYSQL_PWD=$MYSQL_PASS
retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" $options -e "$command")
if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" $options -e "$command" 2>&1 )
if [[ "$err" == *"Access denied"* ]]; then
read -p "Insert mysql user:" PROMPT_USER
read -p "Insert mysql pass:" -s PROMPT_PASS
export MYSQL_PWD=$PROMPT_PASS
retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "$command")
if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "$command" 2>&1 )
# it happens on new mysql 5.7 installations
# since mysql_native_password is explicit now
if [[ "$err" == *"Access denied"* ]]; then
echo "Setting mysql_native_password and for $PROMPT_USER ..."
sudo -h "$MYSQL_HOST" "$DB_MYSQL_EXEC" -e "UPDATE mysql.user SET authentication_string=PASSWORD('${PROMPT_PASS}'), plugin='mysql_native_password' WHERE User='${PROMPT_USER}'; FLUSH PRIVILEGES;"
fi
fi
# create configured account if not exists
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "CREATE USER '${MYSQL_USER}'@'${MYSQL_HOST}' IDENTIFIED BY '${MYSQL_PASS}' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "GRANT CREATE ON *.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
for db in ${DATABASES[@]}
do
local _uc=${db^^}
local _name="DB_"$_uc"_CONF"
local _confs=${!_name}
local _name="DB_"$_uc"_NAME"
local _dbname=${!_name}
eval $_confs
echo "Grant permissions for ${MYSQL_USER}'@'${MYSQL_HOST} to ${_dbname}"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "GRANT ALL PRIVILEGES ON ${_dbname}.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
done
else
exit
fi
fi
}
function dbasm_isNotEmpty() {
dbname=$1
conf=$2
dbasm_mysqlExec "$conf" "SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${dbname}'" "--skip-column-names"
if (( $retval > 0 )); then
true
else
false
fi
}
function dbasm_dbExists() {
dbname=$1
conf=$2
dbasm_mysqlExec "$conf" "SHOW DATABASES LIKE '${dbname}'" "--skip-column-names"
if [ "$retval" == "${dbname}" ]; then
true
else
false
fi
}
function dbasm_createDB() {
database=${1,,}
uc=${database^^}
name="DB_"$uc"_CONF"
confs=${!name}
name="DB_"$uc"_NAME"
dbname=${!name}
eval $confs
CONF_USER=$MYSQL_USER
CONF_PASS=$MYSQL_PASS
if dbasm_dbExists $dbname "$confs"; then
echo "$dbname database exists"
else
echo "Creating DB ${dbname} ..."
dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`" ""
dbasm_mysqlExec "$confs" "CREATE USER IF NOT EXISTS '${CONF_USER}'@'${MYSQL_HOST}' IDENTIFIED BY '${CONF_PASS}';"
dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
fi
}
function dbasm_assemble() {
# to lowercase
database=${1,,}
start_sql=$2
with_base=$3
with_updates=$4
with_custom=$5
uc=${database^^}
name="DB_"$uc"_PATHS"
v="$name[@]"
base=("${!v}")
name="DB_"$uc"_UPDATES_PATHS"
v="$name[@]"
updates=("${!v}")
name='DB_'$uc'_CUSTOM_PATHS'
v="$name[@]"
custom=("${!v}")
suffix_base="_base"
suffix_upd="_updates"
suffix_custom="_custom"
curTime=`date +%Y_%m_%d_%H_%M_%S`
# ALLOW FOR RECURSION WITH "**"
shopt -s globstar
if [ $with_base = true ]; then
echo "" > $OUTPUT_FOLDER$database$suffix_base".sql"
if [ ! ${#base[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_base ..."
for d in "${base[@]}"
do
echo "Searching on $d ..."
if [ ! -z $d ]; then
for entry in "$d"/**/*.sql
do
if [[ -e $entry ]]; then
cat "$entry" >> $OUTPUT_FOLDER$database$suffix_base".sql"
fi
done
fi
done
fi
fi
if [ $with_updates = true ]; then
updFile=$OUTPUT_FOLDER$database$suffix_upd".sql"
echo "" > $updFile
if [ ! ${#updates[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_upd ..."
for d in "${updates[@]}"
do
echo "Searching on $d ..."
if [ ! -z $d ]; then
for entry in "$d"/**/*.sql
do
if [[ ! -e $entry ]]; then
continue
fi
echo "-- $file" >> $updFile
cat "$entry" >> $updFile
done
fi
done
fi
fi
if [ $with_custom = true ]; then
custFile=$OUTPUT_FOLDER$database$suffix_custom".sql"
echo "" > $custFile
if [ ! ${#custom[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_custom ..."
for d in "${custom[@]}"
do
echo "Searching on $d ..."
if [ ! -z $d ]; then
for entry in "$d"/**/*.sql
do
if [[ ! -e $entry ]]; then
continue
fi
echo "-- $file" >> $custFile
cat "$entry" >> $custFile
done
fi
done
fi
fi
}
function dbasm_run() {
echo "===== STARTING ASSEMBLY PROCESS ====="
mkdir -p "$OUTPUT_FOLDER"
for db in ${DATABASES[@]}
do
dbasm_assemble "$db" $version".sql" $1 $2 $3
done
echo "===== DONE ====="
}
function dbasm_db_backup() {
echo "backing up $1"
database=${1,,}
uc=${database^^}
name="DB_"$uc"_CONF"
confs=${!name}
name="DB_"$uc"_NAME"
dbname=${!name}
eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
fi
export MYSQL_PWD=$MYSQL_PASS
now=`date +%s`
"$DB_MYSQL_DUMP_EXEC" --opt --user="$MYSQL_USER" --host="$MYSQL_HOST" "$dbname" > "${BACKUP_FOLDER}${database}_backup_${now}.sql" && echo "done"
if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_DUMP_EXEC" --opt --user="$MYSQL_USER" --host="$MYSQL_HOST" "$dbname" 2>&1 )
if [[ "$err" == *"Access denied"* ]]; then
read -p "Insert mysql user:" PROMPT_USER
read -p "Insert mysql pass:" -s PROMPT_PASS
export MYSQL_PWD=$PROMPT_PASS
"$DB_MYSQL_DUMP_EXEC" --opt --user="$PROMPT_USER" --host="$MYSQL_HOST" "$dbname" > "${BACKUP_FOLDER}${database}_backup_${now}.sql" && echo "done"
else
exit
fi
fi
}
function dbasm_db_import() {
database=${1,,}
type=$2
uc=${database^^}
name="DB_"$uc"_CONF"
confs=${!name}
name="DB_"$uc"_NAME"
dbname=${!name}
if [[ $type = "base" && $DB_SKIP_BASE_IMPORT_IF_EXISTS = true ]]; then
if dbasm_isNotEmpty $dbname "$confs"; then
echo "$dbname is not empty, base importing skipped"
return
else
echo "$dbname seems empty"
fi
fi
echo "importing $1 - $2 ..."
eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
fi
export MYSQL_PWD=$MYSQL_PASS
# TODO: remove this line after we squash our DB updates
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" -e "SET GLOBAL max_allowed_packet=128*1024*1024;"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" --default-character-set=utf8 "$dbname" < "${OUTPUT_FOLDER}${database}_${type}.sql"
if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" "$dbname" 2>&1 )
if [[ "$err" == *"Access denied"* ]]; then
read -p "Insert mysql user:" PROMPT_USER
read -p "Insert mysql pass:" -s PROMPT_PASS
export MYSQL_PWD=$PROMPT_PASS
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" "$dbname" < "${OUTPUT_FOLDER}${database}_${type}.sql"
else
exit
fi
fi
}
function dbasm_import() {
dbasm_run $1 $2 $3
with_base=$1
with_updates=$2
with_custom=$3
echo "===== CHECKING DBs ====="
for db in ${DATABASES[@]}
do
dbasm_createDB "$db"
done
echo "===== DONE ====="
#
# BACKUP
#
if [ $BACKUP_ENABLE = true ]; then
echo "===== STARTING BACKUP PROCESS ====="
mkdir -p "$BACKUP_FOLDER"
for db in ${DATABASES[@]}
do
dbasm_db_backup "$db"
done
echo "===== DONE ====="
fi
echo "===== STARTING IMPORTING PROCESS ====="
#
# IMPORT
#
if [ $with_base = true ]; then
for db in ${DATABASES[@]}
do
dbasm_db_import "$db" "base"
done
fi
if [ $with_updates = true ]; then
for db in ${DATABASES[@]}
do
dbasm_db_import "$db" "updates"
done
fi
if [ $with_custom = true ]; then
for db in ${DATABASES[@]}
do
dbasm_db_import "$db" "custom"
done
fi
echo "===== DONE ====="
}

View File

@@ -0,0 +1,11 @@
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/../../bash_shared/includes.sh"
AC_PATH_DBASSEMBLER="$AC_PATH_APPS/db_assembler"
if [ -f "$AC_PATH_DBASSEMBLER/config.sh" ]; then
source "$AC_PATH_DBASSEMBLER/config.sh" # should overwrite previous
fi
source "$AC_PATH_DBASSEMBLER/includes/functions.sh"

1
apps/db_exporter/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
config.sh

View File

@@ -0,0 +1,12 @@
This script is used by devs to export the databases to base directories
You should use it on clean databases
## USAGE
NOTE: this script is only working under unix currently
1) You must create a config.sh file changing DB connection configurations
of /conf/config.sh.dist
2) Run the db_export.sh script and wait

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
ROOTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )"
source $ROOTPATH"/apps/bash_shared/includes.sh"
if [ -f "./config.sh" ]; then
source "./config.sh" # should overwrite previous
fi
echo "This is a dev-only procedure to export the DB into the SQL base files. All base files will be overwritten."
read -p "Are you sure you want to continue (y/N)? " choice
case "$choice" in
y|Y ) echo "Exporting the DB into the SQL base files...";;
* ) return;;
esac
echo "===== STARTING PROCESS ====="
function export() {
echo "Working on: "$1
database=$1
var_base_path="DB_"$database"_PATHS"
base_path=${!var_base_path}
base_conf="TPATH="$base_path";\
CLEANFOLDER=1; \
CHMODE=0; \
TEXTDUMPS=0; \
PARSEDUMP=1; \
FULL=0; \
DUMPOPTS='--skip-comments --skip-set-charset --routines --extended-insert --order-by-primary --single-transaction --quick'; \
"
var_base_conf="DB_"$database"_CONF"
base_conf=$base_conf${!var_base_conf}
var_base_name="DB_"$database"_NAME"
base_name=${!var_base_name}
bash $AC_PATH_DEPS"/drassil/mysql-tools/mysql-tools" dump "" $base_name "" "$base_conf"
}
for db in ${DATABASES[@]}
do
export "$db"
done
echo "===== DONE ====="

124
apps/db_pendings/import.sh Normal file
View File

@@ -0,0 +1,124 @@
#!/usr/bin/env bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/../bash_shared/includes.sh"
UPDATES_PATH="$AC_PATH_ROOT/data/sql/updates/"
COMMIT_HASH=
function import() {
db=$1
folder="db_"$db
pendingPath="$AC_PATH_ROOT/data/sql/updates/pending_$folder"
updPath="$UPDATES_PATH/$folder"
latestUpd=`ls -1 $updPath/ | tail -n 1`
if [ -z $latestUpd ]; then
echo "FIRST UPDATE FILE MISSING!! DID YOU ARCHIVED IT?";
exit;
fi
dateToday=`date +%Y_%m_%d`
counter=0
dateLast=$latestUpd
tmp=${dateLast#*_*_*_}
oldCnt=${tmp%.sql}
oldDate=${dateLast%_$tmp}
if [ "$oldDate" = "$dateToday" ]; then
((counter=$oldCnt+1))
fi;
for entry in "$pendingPath"/*.sql
do
if [[ -e $entry ]]; then
oldVer=$oldDate"_"$oldCnt
cnt=$(printf -v counter "%02d" $counter ; echo $counter)
newVer=$dateToday"_"$cnt
startTransaction="START TRANSACTION;";
updHeader="ALTER TABLE version_db_"$db" CHANGE COLUMN "$oldVer" "$newVer" bit;";
endTransaction="COMMIT;";
newFile="$updPath/"$dateToday"_"$cnt".sql"
oldFile=$(basename "$entry")
prefix=${oldFile%_*.sql}
suffix=${oldFile#rev_}
rev=${suffix%.sql}
isRev=0
if [[ $prefix = "rev" && $rev =~ ^-?[0-9]+$ ]]; then
isRev=1
fi
echo "-- DB update $oldVer -> $newVer" > "$newFile";
if [[ $isRev -eq 1 ]]; then
echo "DROP PROCEDURE IF EXISTS \`updateDb\`;" >> "$newFile";
echo "DELIMITER //" >> "$newFile";
echo "CREATE PROCEDURE updateDb ()" >> "$newFile";
echo "proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE';" >> "$newFile";
echo "SELECT COUNT(*) INTO @COLEXISTS" >> "$newFile";
echo "FROM information_schema.COLUMNS" >> "$newFile";
echo "WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_"$db"' AND COLUMN_NAME = '"$oldVer"';" >> "$newFile";
echo "IF @COLEXISTS = 0 THEN LEAVE proc; END IF;" >> "$newFile";
fi
echo "$startTransaction" >> "$newFile";
echo "$updHeader" >> "$newFile";
if [[ $isRev -eq 1 ]]; then
echo "SELECT sql_rev INTO OK FROM version_db_"$db" WHERE sql_rev = '$rev'; IF OK <> 'FALSE' THEN LEAVE proc; END IF;" >> "$newFile";
fi;
echo "--" >> "$newFile";
echo "-- START UPDATING QUERIES" >> "$newFile";
echo "--" >> "$newFile";
echo "" >> "$newFile";
cat $entry >> "$newFile";
echo "" >> "$newFile";
echo "--" >> "$newFile";
echo "-- END UPDATING QUERIES" >> "$newFile";
echo "--" >> "$newFile";
echo "$endTransaction" >> "$newFile";
if [[ $isRev -eq 1 ]]; then
echo "END //" >> "$newFile";
echo "DELIMITER ;" >> "$newFile";
echo "CALL updateDb();" >> "$newFile";
echo "DROP PROCEDURE IF EXISTS \`updateDb\`;" >> "$newFile";
fi;
currentHash="$(git log --diff-filter=A "$entry" | grep "^commit " | sed -e 's/commit //')"
if [[ "$COMMIT_HASH" != *"$currentHash"* ]]
then
COMMIT_HASH="$COMMIT_HASH $currentHash"
fi
rm $entry;
oldDate=$dateToday
oldCnt=$cnt
((counter+=1))
fi
done
}
import "world"
import "characters"
import "auth"
echo "Done."

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
## Set a local git commit template
git config --local commit.template ".git_commit_template.txt" ;
echo "--- Successfully set the default commit template for this repository only. Verify with: git config -e"

View File

@@ -0,0 +1,227 @@
function inst_configureOS() {
echo "Platform: $OSTYPE"
case "$OSTYPE" in
solaris*) echo "Solaris is not supported yet" ;;
darwin*) source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;;
linux*)
# If $OSDISTRO is set, use this value (from config.sh)
if [ ! -z "$OSDISTRO" ]; then
DISTRO=$OSDISTRO
# If available, use LSB to identify distribution
elif [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
else
DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
fi
case $DISTRO in
# add here distro that are debian or ubuntu based
# TODO: find a better way, maybe checking the existance
# of a package manager
"neon" | "ubuntu")
DISTRO="ubuntu"
;;
"debian")
DISTRO="debian"
;;
*)
echo "Distro: $DISTRO, is not supported. If your distribution is based on debian or ubuntu,
please set the 'OSDISTRO' environment variable to one of these distro (you can use config.sh file)"
;;
esac
DISTRO=${DISTRO,,}
echo "Distro: $DISTRO"
# TODO: implement different configurations by distro
source "$AC_PATH_INSTALLER/includes/os_configs/$DISTRO.sh"
;;
bsd*) echo "BSD is not supported yet" ;;
msys*) source "$AC_PATH_INSTALLER/includes/os_configs/windows.sh" ;;
*) echo "This platform is not supported" ;;
esac
}
function inst_updateRepo() {
cd "$AC_PATH_ROOT"
git pull origin $(git rev-parse --abbrev-ref HEAD)
}
function inst_resetRepo() {
cd "$AC_PATH_ROOT"
git reset --hard $(git rev-parse --abbrev-ref HEAD)
git clean -f
}
function inst_compile() {
comp_configure
comp_build
}
function inst_cleanCompile() {
comp_clean
inst_compile
}
function inst_allInOne() {
inst_configureOS
inst_updateRepo
inst_compile
dbasm_import true true true
}
function inst_getVersionBranch() {
local res="master"
local v="not-defined"
local MODULE_MAJOR=0
local MODULE_MINOR=0
local MODULE_PATCH=0
local MODULE_SPECIAL=0;
local ACV_MAJOR=0
local ACV_MINOR=0
local ACV_PATCH=0
local ACV_SPECIAL=0;
local curldata=$(curl -f --silent -H 'Cache-Control: no-cache' "$1" || echo "{}")
local parsed=$(echo "$curldata" | "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.compatibility.*.[version,branch]')
semverParseInto "$ACORE_VERSION" ACV_MAJOR ACV_MINOR ACV_PATCH ACV_SPECIAL
if [[ ! -z "$parsed" ]]; then
readarray -t vers < <(echo "$parsed")
local idx
res="none"
# since we've the pair version,branch alternated in not associative and one-dimensional
# array, we've to simulate the association with length/2 trick
for idx in `seq 0 $((${#vers[*]}/2-1))`; do
semverParseInto "${vers[idx*2]}" MODULE_MAJOR MODULE_MINOR MODULE_PATCH MODULE_SPECIAL
if [[ $MODULE_MAJOR -eq $ACV_MAJOR && $MODULE_MINOR -le $ACV_MINOR ]]; then
res="${vers[idx*2+1]}"
v="${vers[idx*2]}"
fi
done
fi
echo "$v" "$res"
}
function inst_module_search {
local res="$1"
local idx=0;
if [ -z "$1" ]; then
echo "Type what to search or leave blank for full list"
read -p "Insert name: " res
fi
local search="+$res"
echo "Searching $res..."
echo "";
readarray -t MODS < <(curl --silent "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" \
| "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.items.*.name')
while (( ${#MODS[@]} > idx )); do
mod="${MODS[idx++]}"
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$mod/master/acore-module.json")
if [[ "$b" != "none" ]]; then
echo "-> $mod (tested with AC version: $v)"
else
echo "-> $mod (no revision available for AC v$AC_VERSION, it could not work!)"
fi
done
echo "";
echo "";
}
function inst_module_install {
local res
if [ -z "$1" ]; then
echo "Type the name of the module to install"
read -p "Insert name: " res
else
res="$1"
fi
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json")
if [[ "$b" != "none" ]]; then
Joiner:add_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"
else
echo "Cannot install $res module: it doesn't exists or no version compatible with AC v$ACORE_VERSION are available"
fi
echo "";
echo "";
}
function inst_module_update {
local res;
local _tmp;
local branch;
local p;
if [ -z "$1" ]; then
echo "Type the name of the module to update"
read -p "Insert name: " res
else
res="$1"
fi
_tmp=$PWD
if [ -d "$J_PATH_MODULES/$res/" ]; then
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json")
cd "$J_PATH_MODULES/$res/"
# use current branch if something wrong with json
if [[ "$v" == "none" || "$v" == "not-defined" ]]; then
b=`git rev-parse --abbrev-ref HEAD`
fi
Joiner:upd_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly" || echo "Cannot update"
cd $_tmp
else
echo "Cannot update! Path doesn't exist"
fi;
echo "";
echo "";
}
function inst_module_remove {
if [ -z "$1" ]; then
echo "Type the name of the module to remove"
read -p "Insert name: " res
else
res="$1"
fi
Joiner:remove "$res" && echo "Done, please re-run compiling" || echo "Cannot remove"
echo "";
echo "";
}
function inst_simple_restarter {
echo "Running $1 ..."
bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1"
echo
#disown -a
#jobs -l
}
function inst_download_client_data {
local path="$AC_BINPATH_FULL"
echo "Downloading client data in: $path/data.zip ..."
curl -L https://github.com/wowgaming/client-data/releases/download/v7/data.zip > "$path/data.zip" \
&& unzip -o "$path/data.zip" -d "$path/" && rm "$path/data.zip"
}

View File

@@ -0,0 +1,38 @@
[[ ${INSTALLER_GUARDYVAR:-} -eq 1 ]] && return || readonly INSTALLER_GUARDYVAR=1 # include it once
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd )
source "$CURRENT_PATH/../../bash_shared/includes.sh"
AC_PATH_INSTALLER="$AC_PATH_APPS/installer"
J_VER_REQ="v0.8.3"
J_PATH="$AC_PATH_APPS/joiner"
J_PATH_MODULES="$AC_PATH_MODULES"
#install/update and include joiner
if [ ! -d "$J_PATH/.git" ]; then
git clone https://github.com/azerothcore/joiner "$J_PATH" -b master
git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
else
# legacy code, with new rev of joiner the update process is internally handled
_cur_branch=`git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" rev-parse --abbrev-ref HEAD`
_cur_ver=`git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" name-rev --tags --name-only $_cur_branch`
if [ "$_cur_ver" != "$J_VER_REQ" ]; then
git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" rev-parse && git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" fetch --tags origin master --quiet
git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
fi
fi
source "$J_PATH/joiner.sh"
if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then
source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous
fi
source "$AC_PATH_APPS/compiler/includes/includes.sh"
source "$AC_PATH_APPS/db_assembler/includes/includes.sh"
source "$AC_PATH_DEPS/semver_bash/semver.sh"
source "$AC_PATH_INSTALLER/includes/functions.sh"

View File

@@ -0,0 +1,5 @@
sudo apt-get update
sudo apt-get install -y git cmake make gcc g++ clang libmysqlclient-dev \
libssl1.0-dev libbz2-dev libreadline-dev libncurses-dev \
mysql-server libace-6.* libace-dev curl unzip

View File

@@ -0,0 +1,6 @@
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew install openssl readline cmake ace coreutils bash bash-completion md5sha1sum curl unzip

View File

@@ -0,0 +1,24 @@
UBUNTU_VERSION=$(lsb_release -sr);
sudo apt-get update
if [[ $CONTINUOUS_INTEGRATION ]]; then
sudo apt-get -y install build-essential libtool make cmake cmake-data clang openssl libgoogle-perftools-dev \
libssl-dev libmysqlclient-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev libace-dev mysql-client \
libncurses5-dev
else
case $UBUNTU_VERSION in
"14.04")
sudo apt-get -y install build-essential libtool make cmake cmake-data gcc g++ clang openssl libgoogle-perftools-dev \
libssl-dev libmysqlclient-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev libace-dev mysql-server libncurses-dev \
curl unzip
;;
*)
sudo apt-get install -y git cmake make gcc g++ clang libmysqlclient-dev \
libssl-dev libbz2-dev libreadline-dev libncurses-dev \
mysql-server libace-6.* libace-dev curl unzip
;;
esac
fi

View File

@@ -0,0 +1,17 @@
echo "WARNING: Installer Script for Windows is not fully supported yet. Work in progress.."
echo "!!README!!: Please install openssl and mysql libraries manually following our wiki"
# install chocolatey before
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# install automatically following packages:
# cmake
# git
# microsoft-build-tools
# mysql 5.6
choco install -y --skip-checksums cmake git git.install microsoft-build-tools
choco install -y --skip-checksums mysql --version 5.6.12
echo "!!README!!: Please remember to install openssl and mysql libraries manually following our wiki"

93
apps/installer/main.sh Normal file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
PS3='[Please enter your choice]: '
options=(
"init (i): First Installation" # 1
"install-deps (d): Configure OS dep" # 2
"pull (u): Update Repository" # 3
"reset (r): Reset & Clean Repository" # 4
"compiler (c): Run compiler tool" # 5
"db-assembler (a): Run db assembler tool" # 6
"module-search (ms): Module Search by keyword" # 7
"module-install (mi): Module Install by name" # 8
"module-update (mu): Module Update by name" # 9
"module-remove: (mr): Module Remove by name" # 10
"client-data: (gd): download client data from github repository (beta)" # 11
"run-worldserver (rw): execute a simple restarter for worldserver" # 12
"run-authserver (ra): execute a simple restarter for authserver" # 13
"quit: Exit from this menu" # 14
)
function _switch() {
_reply="$1"
_opt="$2"
case $_reply in
""|"i"|"init"|"1")
inst_allInOne
;;
""|"d"|"install-deps"|"2")
inst_configureOS
;;
""|"u"|"pull"|"3")
inst_updateRepo
;;
""|"r"|"reset"|"4")
inst_resetRepo
;;
""|"c"|"compiler"|"5")
bash "$AC_PATH_APPS/compiler/compiler.sh" $_opt
;;
""|"a"|"db-assembler"|"6")
bash "$AC_PATH_APPS/db_assembler/db_assembler.sh" $_opt
;;
""|"ms"|"module-search"|"7")
inst_module_search "$_opt"
;;
""|"mi"|"module-install"|"8")
inst_module_install "$_opt"
;;
""|"mu"|"module-update"|"9")
inst_module_update "$_opt"
;;
""|"mr"|"module-remove"|"10")
inst_module_remove "$_opt"
;;
""|"gd"|"client-data"|"11")
inst_download_client_data
;;
""|"rw"|"run-worldserver"|"12")
inst_simple_restarter worldserver
;;
""|"ra"|"run-authserver"|"13")
inst_simple_restarter authserver
;;
""|"quit"|"14")
echo "Goodbye!"
exit
;;
""|"--help")
echo "Available commands:"
printf '%s\n' "${options[@]}"
;;
*) echo "invalid option, use --help option for the commands list";;
esac
}
while true
do
# run option directly if specified in argument
[ ! -z $1 ] && _switch $@ # old method: "${options[$cmdopt-1]}"
[ ! -z $1 ] && exit 0
echo "==== ACORE DASHBOARD ===="
select opt in "${options[@]}"
do
_switch $REPLY
break
done
done

View File

@@ -0,0 +1,50 @@
# enable/disable GDB execution
export GDB_ENABLED=0
# [optional] gdb file
# default: gdb.txt
export GDB=""
# directory where binary are stored
export BINPATH=""
# Put here the pid you configured on your worldserver.conf file
# needed when GDB_ENABLED=1
export SERVERPID=""
# path to configuration file (including the file name)
# ex: /home/user/azerothcore/etc/worldserver.conf
export CONFIG=""
# path of log files
# needed by restarter to store its logs
export LOGS_PATH="";
# exec name
# ex: worldserver
export SERVERBIN=""
# prefix name for log files
# to avoid collision with other restarters
export LOG_PREFIX_NAME=""
# [optional] name of screen service
# if no specified, screen util won't be used
export SCREEN_NAME=""
# [optional] overwrite default screen options: -A -m -d -S
# WARNING: if you are running it under a systemd service
# please do not remove -m -d arguments from screen if are you using it,
# or keep WITH_CONSOLE=0 .
# otherwise the journald-logging system will take 100% of CPU slowing
# down the whole machine. It's because a systemd service should have
# low console output.
export SCREEN_OPTIONS=""
# enable/disable it to show the output
# within console, if disable the output will be redirect to
# logging files
#
export WITH_CONSOLE=0

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
# you must create your conf
# copying conf.sh.dist
# and renaming as below
source ./conf-auth.sh
restarter

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
# you must create your conf
# copying conf.sh.dist
# and renaming as below
source ./conf-world.sh
restarter

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
# you must create your conf
# copying conf.sh.dist
# and renaming as below
source ./conf-auth.sh
starter

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
# you must create your conf
# copying conf.sh.dist
# and renaming as below
source ./conf-world.sh
starter

View File

@@ -0,0 +1,113 @@
export RUN_ENGINE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# load default conf
if [ -e "$RUN_ENGINE_PATH/conf.dist" ]; then
source "$RUN_ENGINE_PATH/conf.sh.dist"
fi
function finish {
if [ ! -z "$SCREEN_NAME" ]; then
screen -X -S "$SCREEN_NAME" quit
fi
}
# disabled for now, but could be useful if we want
# shutdown the process if restarter crashes for some reason
# trap finish EXIT
function configureFiles() {
TRACE_BEGIN_STRING="SIGSEGV"
TRACE_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_trace.log"
ERR_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_error.log"
SYSLOG="$LOGS_PATH/"$LOG_PREFIX_NAME"_system.log"
SYSERR="$LOGS_PATH/"$LOG_PREFIX_NAME"_system.err"
LINKS_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_crash_links.link"
}
function checkStatus() {
local ret=1
# wipe do : destroy old screens + ls
#screen -wipe
#if screen -ls $1 | grep -q "No Sockets found"
#then
# return 0
#fi
local gdbres=$(pgrep -f "gdb -x $GDB --batch $SERVERBIN")
if [[ $GDB_ENABLED -eq 1 && ! -z $gdbres ]]; then
return 1
fi
#
# This is a specific check for Azeroth Core in case of screen failure
# It is possible since same binary file cannot be launched with same configuration file
# This is an extra check
#
local binres=$(pgrep -f "$SERVERBIN -c $CONFIG")
if [ ! -z $binres ]; then
return 1
fi
return 0
}
function run() {
echo $1
if [ ! -z $1 ]; then
local OPTIONS="-A -m -d -S"
if [ ! -z "$SCREEN_OPTIONS" ]; then
OPTIONS=$SCREEN_OPTIONS
fi
echo "> Starting with screen ( screen $OPTIONS )"
screen $OPTIONS $1 "$RUN_ENGINE_PATH/starter" $2 $3 "$4" "$5" "$6" $7
else
$RUN_ENGINE_PATH/starter $2 $3 "$4" "$5" "$6" $7
fi
}
function starter() {
cd $BINPATH
mkdir -p "$LOGS_PATH"
configureFiles
run "$SCREEN_NAME" "$SERVERBIN" "$GDB" "$CONFIG" "$SYSLOG" "$SYSERR" "$GDB_ENABLED"
}
function restarter() {
cd $BINPATH
mkdir -p "$LOGS_PATH"
configureFiles
if [ ! -f $TRACE_FILE ]; then
touch $TRACE_FILE
fi
while :
do
if checkStatus $SCREEN_NAME; then
DATE=$(date)
echo "Restarting $SCREEN_NAME Core blizz($DATE)"
if [ $GDB_ENABLED -eq 1 ]; then
echo "GDB enabled"
grep -B 10 -A 1800 "$TRACE_BEGIN_STRING" "$SYSLOG" >> "$TRACE_FILE"
cat "$SYSERR" > "$ERR_FILE"
run "$SCREEN_NAME" "$SERVERBIN" "$GDB" "$CONFIG" "$SYSLOG" "$SYSERR" 1
fi
if [ $GDB_ENABLED -eq 0 ]; then
echo "GDB disabled"
run "$SCREEN_NAME" "$SERVERBIN" null "$CONFIG" null null 0
fi
fi
sleep 10
done
}

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
#PARAMETER 1: directory
#PARAMETER 2: binary file
_bin_path=$1
_bin_file=$2
_instant_crash_cnt=0
_total_crashes=0
trap 'echo "va bene"' SIGHUP
while true
do
if [ ! -f "$_bin_path/$_bin_file" ]; then
echo "$_bin_path/$_bin_file doesn't exists!"
exit 0
fi
STARTING_TIME=$(date +%s)
cd "$_bin_path" && "./$_bin_file" # &>/dev/null;
_exit_code=$?
echo "exit code: $_exit_code"
# stop restarter on SIGKILL (disabled for now)
# 128 + 9 (SIGKILL)
#if [ $_exit_code -eq 137 ]; then
# echo "$_bin_file has been killed"
# exit 0
#fi
echo "$_bin_file crashed (?), restarting..."
ENDING_TIME=$(date +%s)
DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME ))
((_total_crashes++))
echo "$_bin_file Crashed after $DIFFERENCE seconds, total crashes: $_total_crashes"
if [ $DIFFERENCE -lt 10 ]; then
# increment instant crash if runtime is lower than 10 seconds
((_instant_crash_cnt++))
else
_instant_crash_cnt=0 # reset count
fi
if [ $_instant_crash_cnt -gt 5 ]; then
echo "$_bin_file Restarter exited. Infinite crash loop prevented. Please check your system"
exit 0
fi
done

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
GDB_FILE="$2"
CONFIG="$3"
SYSLOG="$4"
SYSERR="$5"
GDB_ENABLED="$6"
if [ $GDB_ENABLED -eq 1 ]; then
echo "set logging on" > "$GDB_FILE"
echo "set debug timestamp" >> "$GDB_FILE"
echo "run -c $3" >> "$GDB_FILE"
echo "bt" >> "$GDB_FILE"
[ ! -f "$SYSLOG" ] && touch "$SYSLOG"
[ ! -f "$SYSERR" ] && touch "$SYSERR"
if [ $WITH_CONSOLE -eq 0 ]; then
gdb -x $GDB_FILE --batch $1 >> "$SYSLOG" 2>> "$SYSERR"
else
echo "> Console enabled"
gdb -x $GDB_FILE --batch $1 > >(tee ${SYSLOG}) 2> >(tee ${SYSERR} >&2)
fi
elif [ $GDB_ENABLED -eq 0 ]; then
"./$1" -c "$CONFIG"
fi