-
Notifications
You must be signed in to change notification settings - Fork 5
/
Database_Installer_Updater.bat
259 lines (240 loc) · 6.25 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
@ECHO OFF
TITLE Database Installation Tool
COLOR 0A
:TOP
CLS
ECHO.
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO º º
ECHO º Welcome to the world DB º
ECHO º for º
ECHO º SkyFireEMU 406a/420a º
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 port=3306
SET dumppath=.\dump\
SET mysqlpath=.\dep\mysql\
SET devsql=.\main_db\world\
SET procsql=.\main_db\procs\
SET changsql=.\world_updates
SET local_sp=\main_db\locals\spanish\
SET local_gr=\main_db\locals\german\
SET local_ru=\main_db\locals\russian\
SET local_it=\main_db\locals\italian\
:Begin
CLS
SET v=""
ECHO.
ECHO.
ECHO 1 - Install 4.0.6a World Database and all updates, NOTE! Whole db will be overwritten!
ECHO.
ECHO,
ECHO L - Apply Locals, "You need to install the world database and updates first."
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%==l GOTO locals
IF %v%==L GOTO locals
IF %v%==a GOTO 406sets
IF %v%==A GOTO 406sets
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% < %devsql%\databaseclean.sql
@DEL %devsql%\databaseclean.sql
ECHO Lets make a clean database.
ECHO Importing Data now...
ECHO.
ECHO. Adding Stored Procedures
for %%C in (%procsql%\*.sql) do (
ECHO import: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %world_db% < "%%~fC"
)
ECHO Stored Procedures imported sucesfully!
ECHO.
ECHO Installing World Data
FOR %%C IN (%devsql%\*.sql) DO (
ECHO Importing: %%~nxC
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %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% %world_db% < "%%~fC"
)
ECHO Changesets imported sucesfully!
ECHO.
ECHO Your current 4.0.6a/4.2.0a 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 %world_db% %%~nC > %dumppath%\%%~nxC
)
endlocal
ECHO Finished ... %world_db% exported to %dumppath% folder...
PAUSE
GOTO begin
:locals
CLS
ECHO Here is a list of locals.!!!)
ECHO.
ECHO Spanish = S
ECHO German = G "No Data Yet"
ECHO Russian = R "No Data Yet"
ECHO Italian = I
ECHO.
ECHO Return to main menu = B
ECHO.
set /p ch= Number:
ECHO.
IF %ch%==s GOTO install_sp
IF %ch%==S GOTO install_sp
IF %ch%==g GOTO install_gr
IF %ch%==G GOTO install_gr
IF %ch%==r GOTO install_ru
IF %ch%==R GOTO install_ru
IF %ch%==i GOTO install_it
IF %ch%==I GOTO install_it
IF %ch%==b GOTO begin
IF %ch%==B GOTO begin
IF %ch%=="" GOTO locals
:install_sp
ECHO Importing Spanish Data now...
ECHO.
FOR %%C IN (%local_sp%\*.sql) DO (
ECHO Importing: %%~nxC1
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %world_db% < "%%~fC"
ECHO Spanish Locals Successfully imported %%~nxC1
)
ECHO Done.
GOTO Begin
:install_gr
ECHO Importing German Data now...
ECHO.
FOR %%C IN (%local_sp%\*.sql) DO (
ECHO Importing: %%~nxC1
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %world_db% < "%%~fC"
ECHO German Locals Successfully imported %%~nxC1
)
ECHO Done.
GOTO Begin
:install_ru
ECHO Importing Russian Data now...
ECHO.
FOR %%C IN (%local_sp%\*.sql) DO (
ECHO Importing: %%~nxC1
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %world_db% < "%%~fC"
ECHO Russian Locals Successfully imported %%~nxC1
)
ECHO Done.
GOTO Begin
:install_it
ECHO Importing Italian Data now...
ECHO.
FOR %%C IN (%local_it%\*.sql) DO (
ECHO Importing: %%~nxC1
%mysqlpath%\mysql --host=%host% --user=%user% --password=%pass% --port=%port% %world_db% < "%%~fC"
ECHO Italian Locals Successfully imported %%~nxC1
)
ECHO Done.
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 --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% %world_db% < "%%~fC"
)
ECHO Changesets imported sucesfully!
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