From 143659f205888641ee945db278e54d09464e2e9f Mon Sep 17 00:00:00 2001 From: Pysis Date: Tue, 21 Feb 2023 19:03:50 -0500 Subject: [PATCH] Fixing basic install route Just so it barely functions better mostly with the files it already has, plus the quick script that I added. World FullDB had 2 errors, create scripts could probably be included in bat file allowing customizable schema names, even this entire project could be deduplicated with the main one, which could be done for all C++ cores as well, including the data if it is the same too. Quick script adapted from https://github.com/mangoszero/database/pull/132. --- Install_Account.bat | 50 +++++++++++++++++++++++-------------- Install_Characters.bat | 46 +++++++++++++++++++++------------- Install_Quick.bat | 48 +++++++++++++++++++++++++++++++++++ Install_World.bat | 45 +++++++++++++++++++++------------ Tools/characterCreateDB.sql | 3 +++ Tools/mangosdCreateDB.sql | 5 ++++ 6 files changed, 145 insertions(+), 52 deletions(-) create mode 100644 Install_Quick.bat create mode 100644 Tools/characterCreateDB.sql create mode 100644 Tools/mangosdCreateDB.sql diff --git a/Install_Account.bat b/Install_Account.bat index 77db19a..3b1027a 100644 --- a/Install_Account.bat +++ b/Install_Account.bat @@ -2,16 +2,19 @@ :quick rem Quick install section rem This will automatically use the variables below to install the Account database without prompting then optimize them and exit -rem To use: Set your environment variables below and change 'set quick=off' to 'set quick=on' -set quick=off +rem To use: Configure and run Install_Quick.bat, or set your environment variables below, change 'set quick=off' to 'set quick=on', and run this individual file instead. +IF NOT DEFINED quick set quick=off +IF NOT DEFINED skipPause set skipPause=off +IF NOT DEFINED skipDone set skipDone=off if %quick% == off goto standard echo (( Mangos Account Database Quick Installer )) rem -- Change the values below to match your server -- -set svr=localhost -set user=root -set pass=rootpass -set port=3306 -set wdb=realmd +IF NOT DEFINED DEBUG set DEBUG=NO +IF NOT DEFINED svr set svr=localhost +IF NOT DEFINED user set user=root +IF NOT DEFINED pass set pass=rootpass +IF NOT DEFINED port set port=3306 +IF NOT DEFINED adb set adb=realmd rem -- Don't change past this point -- set yesno=y goto install @@ -45,16 +48,22 @@ set /p pass=What is your MySQL password? [rootpass] : if %pass%. == . set pass=rootpass set /p port=What is your MySQL port? [3306] : if %port%. == . set port=3306 -set /p wdb=What is your Account database name? [mangosVBaccounts] : -if %wdb%. == . set wdb=mangosVBaccounts +set /p adb=What is your Account database name? [mangosVBaccounts] : +if %adb%. == . set adb=mangosVBaccounts :install set dbpath=Realm\Setup -set mysql=tools +IF NOT DEFINED mysqlDir set mysqlDir=tools +IF NOT DEFINED mysqlExeName set mysqlExeName=mysql.exe +set mysqlExePath=%mysqlDir%\%mysqlExeName% +IF NOT DEFINED mysqlConnectionOptions set mysqlConnectionOptions=-h %svr% --user=%user% --password=%pass% --port=%port% +IF NOT DEFINED mysqlConnectionOtherOptions set mysqlConnectionOtherOptions=-q -s +IF NOT DEFINED mysqlConnectionString set mysqlConnectionString=%mysqlExePath% %mysqlConnectionOptions% %mysqlConnectionOtherOptions% +IF %DEBUG%==YES echo mysqlConnectionString: %mysqlConnectionString% :checkpaths -if not exist %dbpath% then goto patherror -if not exist %mysql%\mysql.exe then goto patherror +if not exist %dbpath% goto patherror +if not exist %mysqlExePath% goto patherror goto world :patherror @@ -70,11 +79,14 @@ if %quick% == off set /p yesno=Do you wish to continue? (y/n) echo. echo Importing Account database -REM for %%i in (%dbpath%\*.sql) do echo %%i & %mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < %%i -%mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < %dbpath%\realmdLoadDB.sql -%mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < Tools\updateRealm.sql +REM for %%i in (%dbpath%\*.sql) do echo %%i & %mysqlConnectionString% %adb% < %%i +%mysqlConnectionString% < %dbpath%\realmdCreateDB.sql +%mysqlConnectionString% %adb% < %dbpath%\realmdLoadDB.sql +%mysqlConnectionString% %adb% < Tools\updateRealm.sql :done -echo. -echo Done :) -echo. -pause \ No newline at end of file +IF NOT "%skipPause%"=="on" ( + echo. + echo Done :) + echo. +) +IF NOT "%skipPause%"=="on" pause \ No newline at end of file diff --git a/Install_Characters.bat b/Install_Characters.bat index ac1b3e4..d4c6604 100644 --- a/Install_Characters.bat +++ b/Install_Characters.bat @@ -2,16 +2,19 @@ :quick rem Quick install section rem This will automatically use the variables below to install the Characters database without prompting then optimize them and exit -rem To use: Set your environment variables below and change 'set quick=off' to 'set quick=on' -set quick=off +rem To use: Configure and run Install_Quick.bat, or set your environment variables below, change 'set quick=off' to 'set quick=on', and run this individual file instead. +IF NOT DEFINED quick set quick=off +IF NOT DEFINED skipPause set skipPause=off +IF NOT DEFINED skipDone set skipDone=off if %quick% == off goto standard echo (( Mangos Character Database Quick Installer )) rem -- Change the values below to match your server -- -set svr=localhost -set user=root -set pass=rootpass -set port=3306 -set wdb=character0 +IF NOT DEFINED DEBUG set DEBUG=NO +IF NOT DEFINED svr set svr=localhost +IF NOT DEFINED user set user=root +IF NOT DEFINED pass set pass=rootpass +IF NOT DEFINED port set port=3306 +IF NOT DEFINED cdb set cdb=character0 rem -- Don't change past this point -- set yesno=y goto install @@ -45,16 +48,22 @@ set /p pass=What is your MySQL password? [rootpass] : if %pass%. == . set pass=rootpass set /p port=What is your MySQL port? [3306] : if %port%. == . set port=3306 -set /p wdb=What is your Characters database name? [mangosVBcharacters] : -if %wdb%. == . set wdb=mangosVBcharacters +set /p cdb=What is your Characters database name? [mangosVBcharacters] : +if %cdb%. == . set cdb=mangosVBcharacters :install set dbpath=Character\Setup -set mysql=tools +IF NOT DEFINED mysqlDir set mysqlDir=tools +IF NOT DEFINED mysqlExeName set mysqlExeName=mysql.exe +set mysqlExePath=%mysqlDir%\%mysqlExeName% +IF NOT DEFINED mysqlConnectionOptions set mysqlConnectionOptions=-h %svr% --user=%user% --password=%pass% --port=%port% +IF NOT DEFINED mysqlConnectionOtherOptions set mysqlConnectionOtherOptions=-q -s +IF NOT DEFINED mysqlConnectionString set mysqlConnectionString=%mysqlExePath% %mysqlConnectionOptions% %mysqlConnectionOtherOptions% +IF %DEBUG%==YES echo mysqlConnectionString: %mysqlConnectionString% :checkpaths -if not exist %dbpath% then goto patherror -if not exist %mysql%\mysql.exe then goto patherror +if not exist %dbpath% goto patherror +if not exist %mysqlExePath% goto patherror goto world :patherror @@ -70,10 +79,13 @@ if %quick% == off set /p yesno=Do you wish to continue? (y/n) echo. echo Importing Character database -for %%i in (%dbpath%\*.sql) do echo %%i & %mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < %%i +%mysqlConnectionString% < Tools\characterCreateDB.sql +for %%i in (%dbpath%\*.sql) do echo %%i & %mysqlConnectionString% %cdb% < %%i :done -echo. -echo Done :) -echo. -pause \ No newline at end of file +IF NOT "%skipPause%"=="on" ( + echo. + echo Done :) + echo. +) +IF NOT "%skipPause%"=="on" pause \ No newline at end of file diff --git a/Install_Quick.bat b/Install_Quick.bat new file mode 100644 index 0000000..79eac0d --- /dev/null +++ b/Install_Quick.bat @@ -0,0 +1,48 @@ +@echo off + +REM You can use this file to quickly configure and run all included scripts for the database schemas, or individual ones when provided with the desired script as the first parameter, such as dragging that script onto this one. +REM Configuration involves uncommenting any of the following lines by removing the "REM " prefix text for any setting you need to provide for your database installation that does not match a default value, by also providing your custom after the "=". + +set quick=on +set skipPause=on +set skipDone=on + +REM set DEBUG=YES + +REM set mysqlDir=tools +REM set mysqlExeName=mysql.exe +REM set mysqlConnectionOtherOptions=-q -v +REM set mysqlConnectionOptions=--login-path=root-local-My8 +REM set svr=localhost +REM set user=root +REM set pass=rootpass +REM set port=3306 +REM set adb=realmd +REM set cdb=character0 +REM set wdb=mangos0 + +IF "%1" == "" ( + echo Will execute all 3 scripts. +) ELSE ( + echo Will only execute this script: %~nx1 +) +echo. + +set /p ready="Ready? (Y/<*>): " +IF NOT DEFINED ready set ready=N +if %ready% == Y GOTO EXECUTE: +if %ready% == y GOTO EXECUTE: + +GOTO :EOF + +:Execute +cd %~dp0 +%~d0 +IF "%1" == "" ( + CALL Install_Account.bat + CALL Install_Characters.bat + CALL Install_World.bat + pause +) ELSE ( + CALL %~nx1 +) diff --git a/Install_World.bat b/Install_World.bat index 9b2c6db..a06564f 100644 --- a/Install_World.bat +++ b/Install_World.bat @@ -2,16 +2,20 @@ :quick rem Quick install section rem This will automatically use the variables below to install the World database without prompting then optimize them and exit -rem To use: Set your environment variables below and change 'set quick=off' to 'set quick=on' -set quick=off +rem To use: Configure and run Install_Quick.bat, or set your environment variables below, change 'set quick=off' to 'set quick=on', and run this individual file instead. +IF NOT DEFINED quick set quick=off +IF NOT DEFINED skipPause set skipPause=off +IF NOT DEFINED skipDone set skipDone=off if %quick% == off goto standard echo (( Mangos World Database Quick Installer )) rem -- Change the values below to match your server -- -set svr=localhost -set user=root -set pass=rootpass -set port=3306 -set wdb=mangosVBworld +IF NOT DEFINED DEBUG set DEBUG=NO +IF NOT DEFINED svr set svr=localhost +IF NOT DEFINED user set user=root +IF NOT DEFINED pass set pass=rootpass +IF NOT DEFINED port set port=3306 +REM IF NOT DEFINED wdb set wdb=mangosVBworld +IF NOT DEFINED wdb set wdb=mangos0 rem -- Don't change past this point -- set yesno=y goto install @@ -50,11 +54,17 @@ if %wdb%. == . set wdb=mangosVBworld :install set dbpath=World\Setup -set mysql=tools +IF NOT DEFINED mysqlDir set mysqlDir=tools +IF NOT DEFINED mysqlExeName set mysqlExeName=mysql.exe +set mysqlExePath=%mysqlDir%\%mysqlExeName% +IF NOT DEFINED mysqlConnectionOptions set mysqlConnectionOptions=-h %svr% --user=%user% --password=%pass% --port=%port% +IF NOT DEFINED mysqlConnectionOtherOptions set mysqlConnectionOtherOptions=-q -s +IF NOT DEFINED mysqlConnectionString set mysqlConnectionString=%mysqlExePath% %mysqlConnectionOptions% %mysqlConnectionOtherOptions% +IF %DEBUG%==YES echo mysqlConnectionString: %mysqlConnectionString% :checkpaths -if not exist %dbpath% then goto patherror -if not exist %mysql%\mysql.exe then goto patherror +if not exist %dbpath% goto patherror +if not exist %mysqlExePath% goto patherror goto world :patherror @@ -70,11 +80,14 @@ if %quick% == off set /p yesno=Do you wish to continue? (y/n) echo. echo Importing World database -%mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < %dbpath%\mangosdLoadDB.sql -for %%i in (%dbpath%\FullDB\*.sql) do echo %%i & %mysql%\mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < %%i +%mysqlConnectionString% < Tools\mangosdCreateDB.sql +REM for %%i in (%dbpath%\FullDB\*.sql) do echo %%i & %mysqlConnectionString% %wdb% < %%i +%mysqlConnectionString% %wdb% < %dbpath%\mangosdLoadDB.sql :done -echo. -echo Done :) -echo. -pause \ No newline at end of file +IF NOT "%skipPause%"=="on" ( + echo. + echo Done :) + echo. +) +IF NOT "%skipPause%"=="on" pause \ No newline at end of file diff --git a/Tools/characterCreateDB.sql b/Tools/characterCreateDB.sql new file mode 100644 index 0000000..794e220 --- /dev/null +++ b/Tools/characterCreateDB.sql @@ -0,0 +1,3 @@ +CREATE DATABASE `character0` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; + +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES ON `character0`.* TO 'mangos'@'localhost'; diff --git a/Tools/mangosdCreateDB.sql b/Tools/mangosdCreateDB.sql new file mode 100644 index 0000000..5ce2bb8 --- /dev/null +++ b/Tools/mangosdCreateDB.sql @@ -0,0 +1,5 @@ +CREATE DATABASE IF NOT EXISTS `mangos0` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; + +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE ON `mangos0`.* TO 'mangos'@'localhost'; + +FLUSH PRIVILEGES;