-
Notifications
You must be signed in to change notification settings - Fork 21
/
Database_Installer_Updater.bat
182 lines (168 loc) · 4.51 KB
/
Database_Installer_Updater.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
@ECHO OFF
TITLE Database Installation Tool
COLOR 0A
:TOP
CLS
ECHO.
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO º º
ECHO º Welcome to the world DB º
ECHO º for º
ECHO º SkyFireEMU 5.x.x º
ECHO º Installation Tool º
ECHO º º
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
ECHO.
ECHO.
ECHO Please enter your MySQL Info...
ECHO.
SET /p host= MySQL Server Address (e.g. localhost):
ECHO.
SET /p user= MySQL Username:
SET /p pass= MySQL Password:
ECHO.
SET /p world_db= World Database:
SET charset=UTF8
SET port=3306
SET dumppath=.\dump\
SET mysqlpath=.\dep\mysql\
SET devsql=.\main_db\world\
SET procsql=.\main_db\procs\
SET changsql=.\world_updates
:Begin
CLS
SET v=""
ECHO.
ECHO.
ECHO 1 - Install 5.4.1 World Database and all updates, NOTE! Whole db will be overwritten!
ECHO.
ECHO,
ECHO W - Backup World Database.
ECHO C - Backup Character Database.
ECHO U - Import Changeset.
ECHO.
ECHO S - Change your settings
ECHO.
ECHO X - Exit this tool
ECHO.
SET /p v= Enter a char:
IF %v%==* GOTO error
IF %v%==1 GOTO importDB
IF %v%==w GOTO dumpworld
IF %v%==W GOTO dumpworld
IF %v%==c GOTO dumpchar
IF %v%==C GOTO dumpchar
IF %v%==u GOTO changeset
IF %v%==U GOTO changeset
IF %v%==s GOTO top
IF %v%==S GOTO top
IF %v%==x GOTO exit
IF %v%==X GOTO exit
IF %v%=="" GOTO exit
GOTO error
:importDB
CLS
ECHO First Lets Create database (or overwrite old) !!
ECHO.
ECHO DROP database IF EXISTS `%world_db%`; > %devsql%\databaseclean.sql
ECHO CREATE database IF NOT EXISTS `%world_db%`; >> %devsql%\databaseclean.sql
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% --default-character-set=%charset% < %devsql%\databaseclean.sql
@DEL %devsql%\databaseclean.sql
ECHO Lets make a clean database.
ECHO.
ECHO. Adding Stored Procedures
for %%C in (%procsql%\*.sql) do (
ECHO import: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% --default-character-set=%charset% %world_db% < "%%~fC"
)
ECHO Stored Procedures imported successfully!
ECHO.
ECHO Installing World Data
ECHO Importing Data now...
ECHO.
FOR %%C IN (%devsql%\*.sql) DO (
ECHO Importing: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% --default-character-set=%charset% %world_db% < "%%~fC"
ECHO Successfully imported %%~nxC
)
ECHO.
ECHO import: Changesets
for %%C in (%changsql%\*.sql) do (
ECHO import: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% --default-character-set=%charset% %world_db% < "%%~fC"
)
ECHO Changesets imported successfully!
ECHO.
ECHO Your current 5.4.1 database is complete.
ECHO Please check the SkyFire repository for any world updates "/sql/updates".
ECHO.
ECHO.
ECHO.
ECHO.
PAUSE
GOTO Begin
:dumpworld
CLS
IF NOT EXIST "%dumppath%" MKDIR %dumppath%
ECHO %world_db% Database Export started...
FOR %%a IN ("%devsql%\*.sql") DO SET /A Count+=1
setlocal enabledelayedexpansion
FOR %%C IN (%devsql%\*.sql) DO (
SET /A Count2+=1
ECHO Dumping [!Count2!/%Count%] %%~nC
%mysqlpath%\mysqldump --host=%host% --user=%user% --password=%pass% --port=%port% --skip-comments --default-character-set=%charset% %world_db% %%~nC > %dumppath%\%%~nxC
)
endlocal
ECHO Finished ... %world_db% exported to %dumppath% folder...
PAUSE
GOTO begin
:dumpchar
CLS
SET sqlname=char-%DATE:~0,3% - %DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%--%TIME:~0,2%-%TIME:~3,2%
SET /p chardb= Enter name of your character DB:
ECHO.
IF NOT EXIST "%dumppath%" MKDIR %dumppath%
ECHO Dumping %sqlname%.sql to %dumppath%
%mysqlpath%\mysqldump -u%user% -p%pass% --routines --skip-comments --default-character-set=%charset% --result-file="%dumppath%\%sqlname%.sql" %chardb%
ECHO Done.
PAUSE
GOTO begin
:changeset
CLS
ECHO.
ECHO.
ECHO.
ECHO A to import all changesets
ECHO.
ECHO Return to main menu = B
ECHO.
set /p ch= Number:
ECHO.
IF %ch%==a GOTO changesetall
IF %ch%==A GOTO changesetall
IF %ch%==b GOTO begin
IF %ch%==B GOTO begin
IF %ch%=="" GOTO changeset
:changesetall
CLS
ECHO.
ECHO import: Changesets
for %%C in (%changsql%\*.sql) do (
ECHO import: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% --default-character-set=%charset% %world_db% < "%%~fC"
)
ECHO Changesets imported successfully!
ECHO.
PAUSE
GOTO begin
:error
ECHO Please enter a correct character.
ECHO.
PAUSE
GOTO begin
:error2
ECHO Changeset with this number not found.
ECHO.
PAUSE
GOTO begin
:exit