mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
## ⚠️ATTENTION! ⚠️ Upgrading procedure: **Database:** After this PR will be merged you need to backup your DB first (you can use the db-assembler or any mysql client to generate the dump) and restore it after. The reason is that we use now docker named volumes instead of binded ones to improve performance. **Conf & client data**: if you use the default configuration, both the etc and the data folder are now available inside the **/env/docker**. Finally, you can cleanup the /docker folder previously used by our system. ## Changes Proposed: This PR will implement the [devcontainer ](https://code.visualstudio.com/docs/remote/containers) feature for VSCode. Allowing us to develop and debug directly within the container in the same way on all OSes. * Implemented support for vscode dev-container feature by remote-extension suite * Docker performance optimizations for MacOS and non-linux hosts * Bash system improvements * Implemented first command using Deno runtime environment (typescript) and [commander.js] * Implemented wait mechanism for db_assembler * Implemented db migration command * possibility to run the authserver and worldserver with GDB using the integrated simple-restarter * Implemented docker multi-stage mechanism to use one single Dockerfile for all the services * client-data downloader now creates a placeholder to avoid downloading the same version of data files multiple times * deployment of pre-compiled docker images on [docker hub](https://hub.docker.com/u/acore), you can test them [here](https://github.com/azerothcore/acore-docker)
110 lines
2.5 KiB
Bash
110 lines
2.5 KiB
Bash
#!/bin/bash
|
|
#
|
|
# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
|
|
# * GNU General Public License version 3; see www.hyperweb2.com/terms/
|
|
|
|
echo "starting import process.."
|
|
# check config from same folder and include only if exists
|
|
CONF_FILE=$MT_DIR"/mysql-config"
|
|
if [ -f "$CONF_FILE" ]; then
|
|
source "$CONF_FILE"
|
|
fi;
|
|
|
|
#overwrite configs if file exists and variables are defined
|
|
if [ ! -z "$4" ]; then
|
|
if [ -e "$4" ]; then
|
|
source "$4"
|
|
else # if 4th parameter is not a file, then try to eval
|
|
eval "$4"
|
|
fi;
|
|
fi;
|
|
|
|
source $MT_DIR"/shared-def"
|
|
|
|
if [ ! -z "$1" ]; then
|
|
MYSQL_DB=$1;
|
|
fi
|
|
|
|
# Table prefix ( to implement )
|
|
PFX=
|
|
|
|
# par 1 : db_name
|
|
function checkdb {
|
|
# Check if database exists
|
|
err=`echo "quit" | $(eval "$MYSQL$OPTS '$1'") 2>&1`
|
|
if [ $? != 0 ]; then
|
|
if echo "$err" | grep -q "Access denied"; then
|
|
echo -e "\nDATABASE $1 EXISTS BUT USER $MYSQL_USER DOES NOT HAVE ACCESS TO IT, ABORTING"
|
|
exit
|
|
fi
|
|
echo -n "[creating $1]"
|
|
if ! echo "CREATE DATABASE $1;" | $(eval "$MYSQL$OPTS" ) 2>/dev/null ; then
|
|
echo -e "\nDATABASE $1 DOES NOT EXIST AND I FAILED TO CREATE IT, ABORTING"
|
|
exit
|
|
fi
|
|
fi
|
|
}
|
|
|
|
#par1: is_text_file ; par2: file
|
|
function import
|
|
{
|
|
echo "Importing $2 into $MYSQL_DB (text: $1) ..."
|
|
|
|
SQL="SET FOREIGN_KEY_CHECKS = 0;"
|
|
#eval "$MYSQL$OPTS -e \"SET FOREIGN_KEY_CHECKS = 0\" '$MYSQL_DB'" #disable foreign check
|
|
|
|
FILE=$2
|
|
if (($1 != 0)); then
|
|
#eval "$MYSQLIMPORT$OPTS $IMPORTOPTS_TEXT '$MYSQL_DB' $2"
|
|
TABLE=${FILE##*/}
|
|
TABLE=${TABLE%.txt}
|
|
SQL+="LOAD DATA LOCAL INFILE '$2' INTO TABLE $MYSQL_DB.$TABLE;"
|
|
else
|
|
#eval "$MYSQL$OPTS '$MYSQL_DB'" < "$2"
|
|
SQL+="SOURCE $2;"
|
|
fi
|
|
#eval "$MYSQL$OPTS -e \"SET FOREIGN_KEY_CHECKS = 1\" '$MYSQL_DB'" #enable foreign check
|
|
SQL+="SET FOREIGN_KEY_CHECKS = 1";
|
|
|
|
eval "$MYSQL$OPTS -e \"$SQL\" '$MYSQL_DB'"
|
|
|
|
echo " done"
|
|
}
|
|
|
|
if [ ! -z "$1" ]; then
|
|
DB=$1;
|
|
fi
|
|
|
|
checkdb $MYSQL_DB
|
|
|
|
if [ ! -z "$2" ]; then
|
|
tables=$(echo $2 | tr "," "\n")
|
|
fi
|
|
if [ ! -z "$3" ]; then
|
|
FULL=$3;
|
|
fi
|
|
|
|
if (($FULL != 0)); then
|
|
echo "importing full world file"
|
|
$(eval "$MYSQL$OPTS '$MYSQL_DB'") < $FPATH
|
|
else
|
|
if [ ! -z "$2" ]; then
|
|
import "0" "$TPATH/$2.sql" # TODO we should check if it's a set of tables before
|
|
if (($TEXTDUMPS != 0)); then
|
|
for x in $TPATH/*.txt; do
|
|
import "1" "$x"
|
|
done
|
|
fi
|
|
else
|
|
for x in $TPATH/*.sql; do
|
|
import "0" "$x"
|
|
done
|
|
|
|
if (($TEXTDUMPS != 0)); then
|
|
for x in $TPATH/*.txt; do
|
|
import "1" "$x"
|
|
done
|
|
fi
|
|
fi
|
|
fi
|