chore(db_assembler): Changed var name (#1091)

- Added a missing "s" to the update suffix because it must match exactly the name of the updates/ directory (we have base, custom and updates)
- Also changed var name in config.sh.dist (edit your config.sh if you use it)
- Removed trailing spaces
This commit is contained in:
Barbz
2019-01-22 22:43:30 +01:00
committed by GitHub
parent 71e0ad005b
commit b41fd95874
2 changed files with 22 additions and 20 deletions

View File

@@ -4,7 +4,7 @@ PROMPT_PASS=""
# use in a subshell # use in a subshell
function dbasm_resetExitCode() { function dbasm_resetExitCode() {
exit 0 exit 0
} }
function dbasm_mysqlExec() { function dbasm_mysqlExec() {
@@ -13,12 +13,12 @@ function dbasm_mysqlExec() {
options=$3 options=$3
eval $confs eval $confs
if [[ ! -z "${PROMPT_USER// }" ]]; then if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS MYSQL_PASS=$PROMPT_PASS
fi fi
export MYSQL_PWD=$MYSQL_PASS export MYSQL_PWD=$MYSQL_PASS
retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" $options -e "$command") retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" $options -e "$command")
@@ -51,7 +51,7 @@ function dbasm_mysqlExec() {
local _name="DB_"$_uc"_NAME" local _name="DB_"$_uc"_NAME"
local _dbname=${!_name} local _dbname=${!_name}
eval $_confs eval $_confs
echo "Grant permissions for ${MYSQL_USER}'@'${MYSQL_HOST} to ${_dbname}" 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;" "$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "GRANT ALL PRIVILEGES ON ${_dbname}.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
@@ -65,7 +65,7 @@ function dbasm_mysqlExec() {
function dbasm_isNotEmpty() { function dbasm_isNotEmpty() {
dbname=$1 dbname=$1
conf=$2 conf=$2
dbasm_mysqlExec "$conf" "SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${dbname}'" "--skip-column-names" dbasm_mysqlExec "$conf" "SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${dbname}'" "--skip-column-names"
if (( $retval > 0 )); then if (( $retval > 0 )); then
true true
@@ -96,7 +96,7 @@ function dbasm_createDB() {
name="DB_"$uc"_NAME" name="DB_"$uc"_NAME"
dbname=${!name} dbname=${!name}
eval $confs eval $confs
CONF_USER=$MYSQL_USER CONF_USER=$MYSQL_USER
@@ -104,7 +104,7 @@ function dbasm_createDB() {
if dbasm_dbExists $dbname "$confs"; then if dbasm_dbExists $dbname "$confs"; then
echo "$dbname database exists" echo "$dbname database exists"
else else
echo "Creating DB ${dbname} ..." echo "Creating DB ${dbname} ..."
dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`" "" dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`" ""
dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;" dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
@@ -125,7 +125,7 @@ function dbasm_assemble() {
v="$name[@]" v="$name[@]"
base=("${!v}") base=("${!v}")
name="DB_"$uc"_UPDATE_PATHS" name="DB_"$uc"_UPDATES_PATHS"
v="$name[@]" v="$name[@]"
updates=("${!v}") updates=("${!v}")
@@ -135,7 +135,7 @@ function dbasm_assemble() {
suffix_base="_base" suffix_base="_base"
suffix_upd="_update" suffix_upd="_updates"
suffix_custom="_custom" suffix_custom="_custom"
curTime=`date +%Y_%m_%d_%H_%M_%S` curTime=`date +%Y_%m_%d_%H_%M_%S`
@@ -242,7 +242,7 @@ function dbasm_db_backup() {
dbname=${!name} dbname=${!name}
eval $confs; eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS MYSQL_PASS=$PROMPT_PASS
@@ -291,7 +291,7 @@ function dbasm_db_import() {
echo "importing $1 - $2 ..." echo "importing $1 - $2 ..."
eval $confs; eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS MYSQL_PASS=$PROMPT_PASS
@@ -299,10 +299,12 @@ function dbasm_db_import() {
export MYSQL_PWD=$MYSQL_PASS export MYSQL_PWD=$MYSQL_PASS
# TODO: remove this line after we squash our DB updates # 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" -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" "$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" --default-character-set=utf8 "$dbname" < "${OUTPUT_FOLDER}${database}_${type}.sql"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" "$dbname" 2>&1 ) err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" "$dbname" 2>&1 )
if [[ "$err" == *"Access denied"* ]]; then if [[ "$err" == *"Access denied"* ]]; then
@@ -355,21 +357,21 @@ function dbasm_import() {
do do
dbasm_db_import "$db" "base" dbasm_db_import "$db" "base"
done done
fi fi
if [ $with_updates = true ]; then if [ $with_updates = true ]; then
for db in ${DATABASES[@]} for db in ${DATABASES[@]}
do do
dbasm_db_import "$db" "update" dbasm_db_import "$db" "updates"
done done
fi fi
if [ $with_custom = true ]; then if [ $with_custom = true ]; then
for db in ${DATABASES[@]} for db in ${DATABASES[@]}
do do
dbasm_db_import "$db" "custom" dbasm_db_import "$db" "custom"
done done
fi fi
echo "===== DONE =====" echo "===== DONE ====="
} }

View File

@@ -19,7 +19,7 @@ BINPATH="$AC_PATH_ROOT/env/dist"
############################################## ##############################################
# Set preferred compilers. # Set preferred compilers.
# To use gcc (not suggested) instead of clang change in: # To use gcc (not suggested) instead of clang change in:
# CCOMPILERC="/usr/bin/gcc" # CCOMPILERC="/usr/bin/gcc"
# CCOMPILERCXX="/usr/bin/g++" # CCOMPILERCXX="/usr/bin/g++"
@@ -99,17 +99,17 @@ DB_WORLD_PATHS=(
) )
# UPDATES # UPDATES
DB_CHARACTERS_UPDATE_PATHS=( DB_CHARACTERS_UPDATES_PATHS=(
$SRCPATH"/data/sql/updates/db_characters/" $SRCPATH"/data/sql/updates/db_characters/"
$SRCPATH"/data/sql/updates/pending_db_characters/" $SRCPATH"/data/sql/updates/pending_db_characters/"
) )
DB_AUTH_UPDATE_PATHS=( DB_AUTH_UPDATES_PATHS=(
$SRCPATH"/data/sql/updates/db_auth/" $SRCPATH"/data/sql/updates/db_auth/"
$SRCPATH"/data/sql/updates/pending_db_auth/" $SRCPATH"/data/sql/updates/pending_db_auth/"
) )
DB_WORLD_UPDATE_PATHS=( DB_WORLD_UPDATES_PATHS=(
$SRCPATH"/data/sql/updates/db_world/" $SRCPATH"/data/sql/updates/db_world/"
$SRCPATH"/data/sql/updates/pending_db_world/" $SRCPATH"/data/sql/updates/pending_db_world/"
) )
@@ -158,7 +158,7 @@ DB_AUTH_CONF="MYSQL_USER='acore'; \
MYSQL_PASS='acore'; \ MYSQL_PASS='acore'; \
MYSQL_HOST='127.0.0.1';\ MYSQL_HOST='127.0.0.1';\
" "
DB_WORLD_CONF="MYSQL_USER='acore'; \ DB_WORLD_CONF="MYSQL_USER='acore'; \
MYSQL_PASS='acore'; \ MYSQL_PASS='acore'; \