Skip to content

Commit

Permalink
Added mangos user creation to InstallDatabases.bat (#96)
Browse files Browse the repository at this point in the history
* Added mangos user creation to InstallDatabases.bat

* Moved external mangosCreateUser.sql script into InstallDatabases.bat batch script and using world, character and world tables names setup into

* Update InstallDatabases.bat

Added the ability to choose a username / password to add.

fixed some script errors
  • Loading branch information
tbayart authored and billy1arm committed Feb 22, 2017
1 parent 11b41e9 commit f9c967b
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions InstallDatabases.bat
Expand Up @@ -3,6 +3,7 @@
set createcharDB=YES
set createworldDB=YES
set createrealmDB=YES
set createMangosUser=YES

set loadcharDB=YES
set loadworldDB=YES
Expand All @@ -25,8 +26,10 @@ set locDE=NO
rem -- Change the values below to match your server --
set mysql=Tools\
set svr=localhost
set newuser=mangos
set user=root
set pass=mangos
set newpass=mangos
set port=3306
set wdb=mangos2
set wdborig=mangos2
Expand Down Expand Up @@ -69,6 +72,8 @@ echo R - Toggle Create Realm Db Structure (%loadreal
echo Y - Apply Realm DB updates (%RDBUpdate%)
echo L - Toggle Add RealmList Entry (%addrealmentry%)
echo.
echo P - Toggle Create Mangos User (%createMangosUser%)
echo.
set LOCList=NO
if %locFR% == YES set LOCList=YES
if %locDE% == YES set LOCList=YES
Expand Down Expand Up @@ -101,6 +106,8 @@ if %activity% == R goto LoadRealmDB:
if %activity% == r goto LoadRealmDB:
if %activity% == L goto AddRealmDB:
if %activity% == l goto AddRealmDB:
if %activity% == P goto ToggleCreateMangosUser:
if %activity% == p goto ToggleCreateMangosUser:

if %activity% == N goto Step1:
if %activity% == n goto Step1:
Expand Down Expand Up @@ -257,6 +264,19 @@ goto main:
set addrealmentry=NO
goto main:

:ToggleCreateMangosUser
if %createMangosUser% == NO goto ToggleCreateMangosUserNo:
if %createMangosUser% == YES goto ToggleCreateMangosUserYes:
goto main:

:ToggleCreateMangosUserNo
set createMangosUser=YES
goto main:

:ToggleCreateMangosUserYes
set createMangosUser=NO
goto main:

:Step1
if not exist %mysql%\mysql.exe then goto patherror
color 08
Expand Down Expand Up @@ -329,7 +349,7 @@ if %loadrealmDB% == YES goto RealmDB3:
:RealmDB4
if %addrealmentry% == YES goto RealmDB5:

goto done:
goto MangosUser:

:WorldDB1
echo Creating World Database %wdb%
Expand Down Expand Up @@ -375,6 +395,24 @@ echo Adding RealmList entry in Realm Database %rdb%
echo --------------------------------------------------
if %addrealmentry% == YES %mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %rdb% < Tools\updateRealm.sql
echo --------------------------------------------------
goto MangosUser:

:MangosUser
if %createMangosUser% == YES goto MangosUser1:
goto done:

:MangosUser1
echo.
set /p newuser=New MySQL user name? [%newuser%] :
if %newuser%. == . set newuser=mangos
set /p newpass=New MySQL user password? [%newpass%] :
if %newpass%. == . set newpass=mangos

echo Creating '%newuser%' user and granting privileges
%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "CREATE USER '%newuser%'@'%svr%' IDENTIFIED BY '%newpass%'";
%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES ON `%wdb%`.* TO '%newuser%'@'%svr%'";
%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES ON `%cdb%`.* TO '%newuser%'@'%svr%'";
%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES ON `%rdb%`.* TO '%newuser%'@'%svr%'";
goto done:


Expand All @@ -397,11 +435,11 @@ echo.
echo Database Localisation Support
echo _____________________________________________________________
echo.
echo French (Francaís) : F - Toggle Loading Localisations (%locFR%)
echo French (Francaís) : F - Toggle Loading Localisations (%locFR%)
echo.
echo German (Deusch) : G/D - Toggle Loading Localisations (%locDE%)
echo.
echo Spanish (Espána) : S/E - Toggle Loading Localisations (%locES%)
echo Spanish (Espána) : S/E - Toggle Loading Localisations (%locES%)
echo.
echo N - Next Step
echo.
Expand Down

0 comments on commit f9c967b

Please sign in to comment.