From 79e7f3f85f74bde2ed52c7b6776c5b7ddf679ce3 Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Fri, 15 Nov 2024 13:12:14 +0100 Subject: [PATCH] Add mangosbot db to the script (#1327) --- InstallFullDB.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/InstallFullDB.sh b/InstallFullDB.sh index f81b64835d..5dc176c219 100755 --- a/InstallFullDB.sh +++ b/InstallFullDB.sh @@ -65,6 +65,7 @@ MYSQL_DUMP_PATH_DEFAULT="" LOCALES_DEFAULT="YES" DEV_UPDATES_DEFAULT="NO" AHBOT_DEFAULT="NO" +PLAYERBOTS_DB_DEFAULT="NO" FORCE_WAIT_DEFAULT="YES" # variables assigned and read from $CONFIG_FILE @@ -84,6 +85,7 @@ MYSQL_DUMP_PATH="${MYSQL_DUMP_PATH_DEFAULT}" LOCALES="${LOCALES_DEFAULT}" DEV_UPDATES="${DEV_UPDATES_DEFAULT}" AHBOT="${AHBOT_DEFAULT}" +PLAYERBOTS_DB="${PLAYERBOTS_DB_DEFAULT}" FORCE_WAIT="${FORCE_WAIT_DEFAULT}" #possible search folder for core path @@ -209,8 +211,8 @@ function set_sql_queries # create database user and grant privileges SQL_CREATE_DATABASE_USER="CREATE USER IF NOT EXISTS '$MYSQL_USERNAME'@'$MYSQL_USERIP' IDENTIFIED BY '$MYSQL_PASSWORD';" - SQL_GRANT_TO_WORLD_DATABASE="GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, EXECUTE, ALTER ROUTINE, CREATE ROUTINE ON \`$WORLD_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';" - SQL_GRANT_TO_CHAR_DATABASE=("GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`$CHAR_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';") + SQL_GRANT_TO_WORLD_DATABASE="GRANT INDEX, SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, EXECUTE, ALTER ROUTINE, CREATE ROUTINE ON \`$WORLD_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';" + SQL_GRANT_TO_CHAR_DATABASE=("GRANT INDEX, SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`$CHAR_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';") SQL_GRANT_TO_REALM_DATABASE=("GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`$REALM_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';") SQL_GRANT_TO_LOGS_DATABASE=("GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`$LOGS_DB_NAME\`.* TO '$MYSQL_USERNAME'@'$MYSQL_USERIP';") @@ -299,6 +301,10 @@ function save_settings() allsettings+=("## Set the variable to \"YES\" to import AHBot sql.") allsettings+=("AHBOT=\"$AHBOT\"") allsettings+=("") + allsettings+=("## Define if the 'src/modules/PlayerBots/sql' directory for processing development SQL files needs to be used") + allsettings+=("## Set the variable to \"YES\" to use the playerbots directory") + allsettings+=("PLAYERBOTS_DB=\"$PLAYERBOTS_DB\"") + allsettings+=("") allsettings+=("# Enjoy using the tool") # save to file @@ -640,6 +646,7 @@ function show_mysql_settings() echo -e "LOCALES.................: $LOCALES" echo -e "DEV_UPDATES.............: $DEV_UPDATES" echo -e "AHBOT...................: $AHBOT" + echo -e "PLAYERBOTS_DB...........: $PLAYERBOTS_DB" } # arg1 = arg2 (if arg2 is empty then arg1 = arg3, if arg3 is empty do nothing) @@ -694,6 +701,7 @@ function change_mysql_settings() read -e -p "LOCALE(default:YES).............: " -i "$LOCALES" LOCALES read -e -p "DEV_UPDATES(default:NO).........: " -i "$DEV_UPDATES" DEV_UPDATES read -e -p "AHBOT(default:NO)...............: " -i "$AHBOT" AHBOT + read -e -p "PLAYERBOTS_DB(default:NO).......: " -i "$PLAYERBOTS_DB" PLAYERBOTS_DB else read -e -p "Enter MySQL host...............current($MYSQL_HOST).: " mhost read -e -p "Enter MySQL port...............current($MYSQL_PORT).: " mport @@ -709,6 +717,7 @@ function change_mysql_settings() read -e -p "LOCALE(default:YES)............current($LOCALES).: " loc read -e -p "DEV_UPDATES(default:NO)........current($DEV_UPDATES).: " dev read -e -p "AHBOT(default:NO)..............current($AHBOT).: " ahb + read -e -p "PLAYERBOTS_DB(default:NO)......current($PLAYERBOTS_DB).: " bot assign_new_value 'MYSQL_HOST' "${mhost}" assign_new_value 'MYSQL_PORT' "${mport}" @@ -721,6 +730,7 @@ function change_mysql_settings() assign_new_value 'LOCALES' "${loc}" assign_new_value 'DEV_UPDATES' "${dev}" assign_new_value 'AHBOT' "${ahb}" + assign_new_value 'PLAYERBOTS_DB' "${bot}" fi # some basic checks @@ -1457,6 +1467,58 @@ function apply_dev_content true } +# Apply playerbot sql files +function apply_playerbots_db +{ + if [ "$PLAYERBOTS_DB" != "YES" ]; then + true + return + fi + + BOT_EXP_PREFIX="classic"; + if [ "$EXPANSION" = "TBC" ]; then + BOT_EXP_PREFIX="tbc"; + fi + if [ "$EXPANSION" = "WoTLK" ]; then + BOT_EXP_PREFIX="wotlk"; + fi + + echo "> Trying to apply playerbots sql mods for world db..." + for UPDATEFILE in ${CORE_PATH}/src/modules/PlayerBots/sql/world/*.sql; do + if [ -e "$UPDATEFILE" ]; then + local fName=$(basename "$UPDATEFILE") + if ! execute_sql_file "$WORLD_DB_NAME" "$UPDATEFILE" " - Applying $fName"; then + false + return + fi + fi + done + + for UPDATEFILE in ${CORE_PATH}/src/modules/PlayerBots/sql/world/${BOT_EXP_PREFIX}/*.sql; do + if [ -e "$UPDATEFILE" ]; then + local fName=$(basename "$UPDATEFILE") + if ! execute_sql_file "$WORLD_DB_NAME" "$UPDATEFILE" " - Applying $fName"; then + false + return + fi + fi + done + + echo "> Trying to apply playerbots sql mods for characters db..." + for UPDATEFILE in ${CORE_PATH}/src/modules/PlayerBots/sql/characters/*.sql; do + if [ -e "$UPDATEFILE" ]; then + local fName=$(basename "$UPDATEFILE") + if ! execute_sql_file "$CHAR_DB_NAME" "$UPDATEFILE" " - Applying $fName"; then + false + return + fi + fi + done + + echo + true +} + # Content db installation function apply_content_db() { @@ -1838,6 +1900,29 @@ function create_and_fill_logs_db() true } +function create_and_fill_playerbots_db() +{ + if [ "$PLAYERBOTS_DB" != "YES" ]; then + true + return + fi + + if [[ "$1" = true ]]; then + clear + if ! are_you_sure "Mangosbots"; then + return + fi + fi + + echo "SUCCESS" + + if ! apply_playerbots_db; then + false + return + fi + true +} + function create_all_databases_and_user() { clear @@ -1865,6 +1950,10 @@ function create_all_databases_and_user() return fi + if ! create_and_fill_playerbots_db; then + return + fi + check_dbs_accessibility if ! apply_char_db_core_update; then return @@ -2484,6 +2573,7 @@ function advanced_db_install_menu() echo "> 5) Create and fill logs database" echo "> 6) Create 'core user' for db and set its default privileges" echo "> 7) Delete all databases and users" + echo "> 8) Create and fill playerbots db" echo "> 9) Return to previous menu" echo read -n 1 -e -p "Please enter your choice.....: " CHOICE @@ -2496,6 +2586,7 @@ function advanced_db_install_menu() "5") create_and_fill_logs_db true; wait_key;; "6") create_db_user_and_set_privileges true; wait_key;; "7") delete_all_databases_and_user true; wait_key;; + "8") create_and_fill_playerbots_db true; wait_key;; *) break;; esac done @@ -2720,6 +2811,10 @@ function auto_script_create_all() return fi + if ! create_and_fill_playerbots_db; then + false + return + fi if ! apply_core_update; then false return @@ -2924,6 +3019,7 @@ set_sql_queries # check if user just want fast db installation if [[ "$1" = "-InstallAll" ]]; then + PLAYERBOTS_DB="YES" if ! auto_script_create_all $2 $3 $4; then exit 1 fi