database_installer.bat 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. @echo off
  2. REM ##############################################
  3. REM ## L2JDP Database Installer - (by DrLecter) ##
  4. REM ##############################################
  5. REM ## Interactive script setup - (by TanelTM) ##
  6. REM ##############################################
  7. REM Copyright (C) 2004-2013 L2J DataPack
  8. REM
  9. REM This file is part of L2J DataPack.
  10. REM
  11. REM L2J DataPack is free software: you can redistribute it and/or modify
  12. REM it under the terms of the GNU General Public License as published by
  13. REM the Free Software Foundation, either version 3 of the License, or
  14. REM (at your option) any later version.
  15. REM
  16. REM L2J DataPack is distributed in the hope that it will be useful,
  17. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. REM General Public License for more details.
  20. REM
  21. REM You should have received a copy of the GNU General Public License
  22. REM along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. set config_file=vars.txt
  24. set config_version=0
  25. set workdir="%cd%"
  26. set full=0
  27. set stage=0
  28. set logging=0
  29. set upgrade_mode=0
  30. set backup=.
  31. set logdir=.
  32. set safe_mode=1
  33. set cmode=c
  34. set fresh_setup=0
  35. :loadconfig
  36. cls
  37. title L2JDP Installer - Reading Configuration from File...
  38. if not exist %config_file% goto configure
  39. ren %config_file% vars.bat
  40. call vars.bat
  41. ren vars.bat %config_file%
  42. call :colors 17
  43. if /i %config_version% == 2 goto ls_backup
  44. set upgrade_mode=2
  45. echo It seems to be the first time you run this version of
  46. echo database_installer but I found a settings file already.
  47. echo I'll hopefully ask this questions just once.
  48. echo.
  49. echo Configuration upgrade options:
  50. echo.
  51. echo (1) Import and continue: I'll read your old settings and
  52. echo continue execution, but since no new settings will be
  53. echo saved, you'll see this menu again next time.
  54. echo.
  55. echo (2) Import and configure: This tool has some new available
  56. echo options, you choose the values that fit your needs
  57. echo using former settings as a base.
  58. echo.
  59. echo (3) Ignore stored settings: I'll let you configure me
  60. echo with a fresh set of default values as a base.
  61. echo.
  62. echo (4) View saved settings: See the contents of the config
  63. echo file.
  64. echo.
  65. echo (5) Quit: Did you came here by mistake?
  66. echo.
  67. set /P upgrade_mode="Type a number, press Enter (default is '%upgrade_mode%'): "
  68. if %upgrade_mode%==1 goto ls_backup
  69. if %upgrade_mode%==2 goto configure
  70. if %upgrade_mode%==3 goto configure
  71. if %upgrade_mode%==4 (cls&type %config_file%&pause&goto loadconfig)
  72. if %upgrade_mode%==5 goto :eof
  73. goto loadconfig
  74. :colors
  75. if /i "%cmode%"=="n" (
  76. if not "%1"=="17" ( color F ) else ( color )
  77. ) else ( color %1 )
  78. goto :eof
  79. :configure
  80. cls
  81. call :colors 17
  82. title L2JDP Installer - Setup
  83. set config_version=2
  84. if NOT %upgrade_mode% == 2 (
  85. set fresh_setup=1
  86. set mysqlBinPath=%ProgramFiles%\MySQL\MySQL Server 5.6\bin
  87. set lsuser=root
  88. set lspass=
  89. set lsdb=l2jls
  90. set lshost=localhost
  91. set cbuser=root
  92. set cbpass=
  93. set cbdb=l2jcs
  94. set cbhost=localhost
  95. set gsuser=root
  96. set gspass=
  97. set gsdb=l2jgs
  98. set gshost=localhost
  99. set cmode=c
  100. set backup=.
  101. set logdir=.
  102. )
  103. set mysqlPath=%mysqlBinPath%\mysql.exe
  104. echo New settings will be created for this tool to run in
  105. echo your computer, so I need to ask you some questions.
  106. echo.
  107. echo 1-MySql Binaries
  108. echo --------------------
  109. echo In order to perform my tasks, I need the path for commands
  110. echo such as 'mysql' and 'mysqldump'. Both executables are
  111. echo usually stored in the same place.
  112. echo.
  113. if "%mysqlBinPath%" == "" (
  114. set mysqlBinPath=use path
  115. echo I can't determine if the binaries are available with your
  116. echo default settings.
  117. ) else (
  118. echo I can try to find out if the current setting actually works...
  119. echo.
  120. echo %mysqlPath%
  121. )
  122. if not "%mysqlBinPath%" == "use path" call :binaryfind
  123. echo.
  124. path|find "MySQL">NUL
  125. if %errorlevel% == 0 (
  126. echo I found MySQL is in your PATH, this will be used by default.
  127. echo If you want to use something different, change 'use path' for
  128. echo something else.
  129. set mysqlBinPath=use path
  130. ) else (
  131. echo Look, I can't find "MYSQL" in your PATH environment variable.
  132. echo It would be good if you go and find out where "mysql.exe" and
  133. echo "mysqldump.exe" are.
  134. echo.
  135. echo If you have no idea about the meaning of words such as MYSQL
  136. echo or PATH, you'd better close this window, and consider googling
  137. echo and reading about it. Setup and host an L2J server requires a
  138. echo minimum of technical skills.
  139. )
  140. echo.
  141. echo Write the path to your MySQL binaries (no trailing slash needed):
  142. set /P mysqlBinPath="(default %mysqlBinPath%): "
  143. cls
  144. echo.
  145. echo 2-Login Server settings
  146. echo -----------------------
  147. echo In order to connect to the MySQL Server, you should
  148. echo specify the Login Server DataBase parameters here.
  149. echo.
  150. set /P lsuser="MySQL Username (default is '%lsuser%'): "
  151. set /P lspass="Password (default is '%lspass%'): "
  152. set /P lsdb="Database (default is '%lsdb%'): "
  153. set /P lshost="Host (default is '%lshost%'): "
  154. echo.
  155. cls
  156. echo.
  157. echo 3-Community Server settings
  158. echo ---------------------------
  159. echo In order to connect to the MySQL Server, you should
  160. echo specify the Community Server DataBase parameters here.
  161. echo.
  162. set /P cbuser="MySQL Username (default is '%cbuser%'): "
  163. set /P cbpass="Password (default is '%cbpass%'): "
  164. set /P cbdb="Database (default is '%cbdb%'): "
  165. set /P cbhost="Host (default is '%cbhost%'): "
  166. echo.
  167. cls
  168. echo.
  169. echo 4-Game Server settings
  170. echo ----------------------
  171. echo In order to connect to the MySQL Server, you should
  172. echo specify the Game Server DataBase parameters here.
  173. echo.
  174. set /P gsuser="User (default is '%gsuser%'): "
  175. set /P gspass="Pass (default is '%gspass%'): "
  176. set /P gsdb="Database (default is '%gsdb%'): "
  177. set /P gshost="Host (default is '%gshost%'): "
  178. echo.
  179. cls
  180. echo.
  181. echo 5-Misc. settings
  182. echo --------------------
  183. set /P cmode="Color mode (c)olor or (n)on-color, default %cmode% : "
  184. set /P backup="Path for your backups (default '%backup%'): "
  185. set /P logdir="Path for your logs (default '%logdir%'): "
  186. :safe1
  187. set safemode=y
  188. set /P safemode="Debugging messages and increase verbosity a lil bit (y/n, default '%safemode%'): "
  189. if /i %safemode%==y (set safe_mode=1&goto safe2)
  190. if /i %safemode%==n (set safe_mode=0&goto safe2)
  191. goto safe1
  192. :safe2
  193. cls
  194. echo.
  195. if "%mysqlBinPath%" == "use path" (
  196. set mysqlBinPath=
  197. set mysqldumpPath=mysqldump
  198. set mysqlPath=mysql
  199. ) else (
  200. set mysqldumpPath=%mysqlBinPath%\mysqldump.exe
  201. set mysqlPath=%mysqlBinPath%\mysql.exe
  202. )
  203. echo @echo off > %config_file%
  204. echo set config_version=%config_version% >> %config_file%
  205. echo set cmode=%cmode%>> %config_file%
  206. echo set safe_mode=%safe_mode% >> %config_file%
  207. echo set mysqlPath=%mysqlPath%>> %config_file%
  208. echo set mysqlBinPath=%mysqlBinPath%>> %config_file%
  209. echo set mysqldumpPath=%mysqldumpPath%>> %config_file%
  210. echo set lsuser=%lsuser%>> %config_file%
  211. echo set lspass=%lspass%>> %config_file%
  212. echo set lsdb=%lsdb%>> %config_file%
  213. echo set lshost=%lshost% >> %config_file%
  214. echo set cbuser=%cbuser%>> %config_file%
  215. echo set cbpass=%cbpass%>> %config_file%
  216. echo set cbdb=%cbdb%>> %config_file%
  217. echo set cbhost=%cbhost% >> %config_file%
  218. echo set gsuser=%gsuser%>> %config_file%
  219. echo set gspass=%gspass%>> %config_file%
  220. echo set gsdb=%gsdb%>> %config_file%
  221. echo set gshost=%gshost%>> %config_file%
  222. echo set logdir=%logdir%>> %config_file%
  223. echo set backup=%backup%>> %config_file%
  224. echo.
  225. echo Script setup complete, your settings were saved in the
  226. echo '%config_file%' file. Remember: your passwords are stored
  227. echo as clear text.
  228. echo.
  229. pause
  230. goto loadconfig
  231. :ls_backup
  232. cls
  233. call :colors 17
  234. set cmdline=
  235. set stage=1
  236. title L2JDP Installer - Login Server DataBase Backup
  237. echo.
  238. echo Trying to make a backup of your Login Server DataBase.
  239. set cmdline="%mysqldumpPath%" --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% ^> "%backup%\ls_backup.sql" 2^> NUL
  240. %cmdline%
  241. if %ERRORLEVEL% == 0 goto ls_db_ok
  242. :ls_err1
  243. cls
  244. set lsdbprompt=y
  245. call :colors 47
  246. title L2JDP Installer - Login Server DataBase Backup ERROR!
  247. echo.
  248. echo Backup attempt failed! A possible reason for this to
  249. echo happen, is that your DB doesn't exist yet. I could
  250. echo try to create %lsdb% for you, or maybe you prefer to
  251. echo continue with the Community Server part of this tool.
  252. echo.
  253. echo ATTEMPT TO CREATE LOGINSERVER DATABASE:
  254. echo.
  255. echo (y) Yes
  256. echo.
  257. echo (n) No
  258. echo.
  259. echo (r) Reconfigure
  260. echo.
  261. echo (q) Quit
  262. echo.
  263. set /p lsdbprompt=Choose (default yes):
  264. if /i %lsdbprompt%==y goto ls_db_create
  265. if /i %lsdbprompt%==n goto cs_backup
  266. if /i %lsdbprompt%==r goto configure
  267. if /i %lsdbprompt%==q goto end
  268. goto ls_err1
  269. :ls_db_create
  270. cls
  271. call :colors 17
  272. set cmdline=
  273. set stage=2
  274. title L2JDP Installer - Login Server DataBase Creation
  275. echo.
  276. echo Trying to create a Login Server DataBase.
  277. set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -e "CREATE DATABASE %lsdb%" 2^> NUL
  278. %cmdline%
  279. if %ERRORLEVEL% == 0 goto ls_db_ok
  280. if %safe_mode% == 1 goto omfg
  281. :ls_err2
  282. cls
  283. set omfgprompt=q
  284. call :colors 47
  285. title L2JDP Installer - Login Server DataBase Creation ERROR!
  286. echo.
  287. echo An error occured while trying to create a database for
  288. echo your login server.
  289. echo.
  290. echo Possible reasons:
  291. echo 1-You provided inaccurate info , check user, password, etc.
  292. echo 2-User %lsuser% don't have enough privileges for
  293. echo database creation. Check your MySQL privileges.
  294. echo 3-Database exists already...?
  295. echo.
  296. echo Unless you're sure that the pending actions of this tool
  297. echo could work, i'd suggest you to look for correct values
  298. echo and try this script again later.
  299. echo.
  300. echo (c) Continue running
  301. echo.
  302. echo (r) Reconfigure
  303. echo.
  304. echo (q) Quit now
  305. echo.
  306. set /p omfgprompt=Choose (default quit):
  307. if /i %omfgprompt%==c goto cs_backup
  308. if /i %omfgprompt%==r goto configure
  309. if /i %omfgprompt%==q goto end
  310. goto ls_err2
  311. :ls_db_ok
  312. cls
  313. set loginprompt=u
  314. call :colors 17
  315. title L2JDP Installer - Login Server DataBase WARNING!
  316. echo.
  317. echo LOGINSERVER DATABASE install type:
  318. echo.
  319. echo (f) Full: WARNING! I'll destroy ALL of your existing login
  320. echo data.
  321. echo.
  322. echo (u) Upgrade: I'll do my best to preserve all login data.
  323. echo.
  324. echo (s) Skip: I'll take you to the communityserver database
  325. echo installation and upgrade options.
  326. echo.
  327. echo (r) Reconfigure: You'll be able to redefine MySQL path,
  328. echo user and database information and start over with
  329. echo those fresh values.
  330. echo.
  331. echo (q) Quit
  332. echo.
  333. set /p loginprompt=Choose (default upgrade):
  334. if /i %loginprompt%==f goto ls_cleanup
  335. if /i %loginprompt%==u goto ls_upgrade
  336. if /i %loginprompt%==s goto cs_backup
  337. if /i %loginprompt%==r goto configure
  338. if /i %loginprompt%==q goto end
  339. goto ls_db_ok
  340. :ls_cleanup
  341. call :colors 17
  342. set cmdline=
  343. title L2JDP Installer - Login Server DataBase Full Install
  344. echo.
  345. echo Deleting Login Server tables for new content.
  346. set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% ^< ls_cleanup.sql 2^> NUL
  347. %cmdline%
  348. if not %ERRORLEVEL% == 0 goto omfg
  349. set full=1
  350. echo.
  351. echo Login Server tables has been deleted.
  352. goto ls_install
  353. :ls_upgrade
  354. cls
  355. echo.
  356. echo Upgrading structure of Login Server tables.
  357. echo.
  358. echo @echo off> temp.bat
  359. if exist ls_errors.log del ls_errors.log
  360. for %%i in (..\sql\login\updates\*.sql) do echo "%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% --force ^< %%i 2^>^> ls_errors.log >> temp.bat
  361. call temp.bat> nul
  362. del temp.bat
  363. move ls_errors.log %workdir%
  364. goto ls_install
  365. :ls_install
  366. cls
  367. set cmdline=
  368. if %full% == 1 (
  369. title L2JDP Installer - Login Server DataBase Installing...
  370. echo.
  371. echo Installing new Login Server content.
  372. echo.
  373. ) else (
  374. title L2JDP Installer - Login Server DataBase Upgrading...
  375. echo.
  376. echo Upgrading Login Server content.
  377. echo.
  378. )
  379. if %logging% == 0 set output=NUL
  380. set dest=ls
  381. for %%i in (..\sql\login\*.sql) do call :dump %%i
  382. echo done...
  383. echo.
  384. goto cs_backup
  385. :cs_backup
  386. cls
  387. call :colors 17
  388. set cmdline=
  389. set stage=3
  390. title L2JDP Installer - Community Server DataBase Backup
  391. echo.
  392. echo Trying to make a backup of your Comunity Server DataBase.
  393. set cmdline="%mysqldumpPath%" --add-drop-table -h %cbhost% -u %cbuser% --password=%cbpass% %cbdb% ^> "%backup%\cs_backup.sql" 2^> NUL
  394. %cmdline%
  395. if %ERRORLEVEL% == 0 goto cs_db_ok
  396. :cs_err1
  397. cls
  398. set cbdbprompt=y
  399. call :colors 47
  400. title L2JDP Installer - Community Server DataBase Backup ERROR!
  401. echo.
  402. echo Backup attempt failed! A possible reason for this to
  403. echo happen, is that your DB doesn't exist yet. I could
  404. echo try to create %cbdb% for you, or maybe you prefer to
  405. echo continue with the GameServer part of this tool.
  406. echo.
  407. echo ATTEMPT TO CREATE COMMUNITY SERVER DATABASE:
  408. echo.
  409. echo (y) Yes
  410. echo.
  411. echo (n) No
  412. echo.
  413. echo (r) Reconfigure
  414. echo.
  415. echo (q) Quit
  416. echo.
  417. set /p cbdbprompt=Choose (default yes):
  418. if /i %cbdbprompt%==y goto cs_db_create
  419. if /i %cbdbprompt%==n goto gs_backup
  420. if /i %cbdbprompt%==r goto configure
  421. if /i %cbdbprompt%==q goto end
  422. goto cs_err1
  423. :cs_db_create
  424. cls
  425. call :colors 17
  426. set cmdline=
  427. set stage=4
  428. title L2JDP Installer - Community Server DataBase Creation
  429. echo.
  430. echo Trying to create a Community Server DataBase...
  431. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -e "CREATE DATABASE %cbdb%" 2^> NUL
  432. %cmdline%
  433. if %ERRORLEVEL% == 0 goto cs_db_ok
  434. if %safe_mode% == 1 goto omfg
  435. :cs_err2
  436. cls
  437. set omfgprompt=q
  438. call :colors 47
  439. title L2JDP Installer - Community Server DataBase Creation ERROR!
  440. echo.
  441. echo An error occured while trying to create a database for
  442. echo your Community Server.
  443. echo.
  444. echo Possible reasons:
  445. echo 1-You provided inaccurate info , check user, password, etc.
  446. echo 2-User %cbuser% don't have enough privileges for
  447. echo database creation. Check your MySQL privileges.
  448. echo 3-Database exists already...?
  449. echo.
  450. echo Unless you're sure that the pending actions of this tool
  451. echo could work, i'd suggest you to look for correct values
  452. echo and try this script again later.
  453. echo.
  454. echo (c) Continue running
  455. echo.
  456. echo (r) Reconfigure
  457. echo.
  458. echo (q) Quit now
  459. echo.
  460. set /p omfgprompt=Choose (default quit):
  461. if /i %omfgprompt%==c goto gs_backup
  462. if /i %omfgprompt%==r goto configure
  463. if /i %omfgprompt%==q goto end
  464. goto cs_err2
  465. :cs_db_ok
  466. cls
  467. set communityprompt=u
  468. call :colors 17
  469. title L2JDP Installer - Community Server DataBase WARNING!
  470. echo.
  471. echo COMMUNITY SERVER DATABASE install type:
  472. echo.
  473. echo (f) Full: WARNING! I'll destroy ALL of your existing community
  474. echo data (i really mean it: mail, forum, memo.. ALL)
  475. echo.
  476. echo (u) Upgrade: I'll do my best to preserve all of your community
  477. echo data.
  478. echo.
  479. echo (s) Skip: I'll take you to the gameserver database
  480. echo installation and upgrade options.
  481. echo.
  482. echo (r) Reconfigure: You'll be able to redefine MySQL path,
  483. echo user and database information and start over with
  484. echo those fresh values.
  485. echo.
  486. echo (q) Quit
  487. echo.
  488. set /p communityprompt=Choose (default upgrade):
  489. if /i %communityprompt%==f goto cs_cleanup
  490. if /i %communityprompt%==u goto cs_upgrade
  491. if /i %communityprompt%==s goto gs_backup
  492. if /i %communityprompt%==r goto configure
  493. if /i %communityprompt%==q goto end
  494. goto cs_db_ok
  495. :cs_cleanup
  496. call :colors 17
  497. set cmdline=
  498. title L2JDP Installer - Community Server DataBase Full Install
  499. echo.
  500. echo Deleting Community Server tables for new content.
  501. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< cs_cleanup.sql 2^> NUL
  502. %cmdline%
  503. if not %ERRORLEVEL% == 0 goto omfg
  504. set full=1
  505. echo.
  506. echo Community Server tables has been deleted.
  507. goto cs_install
  508. :cs_upgrade
  509. cls
  510. echo.
  511. echo Upgrading structure of Community Server tables.
  512. echo.
  513. echo @echo off> temp.bat
  514. if exist cs_errors.log del cs_errors.log
  515. for %%i in (..\sql\community\updates\*.sql) do echo "%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% --force ^< %%i 2^>^> cs_errors.log >> temp.bat
  516. call temp.bat> nul
  517. del temp.bat
  518. move cs_errors.log %workdir%
  519. goto cs_install
  520. :cs_install
  521. cls
  522. set cmdline=
  523. if %full% == 1 (
  524. title L2JDP Installer - Community Server DataBase Installing...
  525. echo.
  526. echo Installing new Community Server content.
  527. echo.
  528. ) else (
  529. title L2JDP Installer - Community Server DataBase Upgrading...
  530. echo.
  531. echo Upgrading Community Server content.
  532. echo.
  533. )
  534. if %logging% == 0 set output=NUL
  535. set dest=cb
  536. for %%i in (..\sql\community\*.sql) do call :dump %%i
  537. echo done...
  538. echo.
  539. goto gs_backup
  540. :gs_backup
  541. cls
  542. call :colors 17
  543. set cmdline=
  544. set stage=5
  545. title L2JDP Installer - Game Server DataBase Backup
  546. echo.
  547. echo Trying to make a backup of your Game Server DataBase.
  548. set cmdline="%mysqldumpPath%" --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% ^> "%backup%\gs_backup.sql" 2^> NUL
  549. %cmdline%
  550. if %ERRORLEVEL% == 0 goto gs_db_ok
  551. :gs_err1
  552. cls
  553. set gsdbprompt=y
  554. call :colors 47
  555. title L2JDP Installer - Game Server DataBase Backup ERROR!
  556. echo.
  557. echo Backup attempt failed! A possible reason for this to
  558. echo happen, is that your DB doesn't exist yet. I could
  559. echo try to create %gsdb% for you, but maybe you prefer to
  560. echo continue with last part of the script.
  561. echo.
  562. echo ATTEMPT TO CREATE GAME SERVER DATABASE?
  563. echo.
  564. echo (y) Yes
  565. echo.
  566. echo (n) No
  567. echo.
  568. echo (r) Reconfigure
  569. echo.
  570. echo (q) Quit
  571. echo.
  572. set /p gsdbprompt=Choose (default yes):
  573. if /i %gsdbprompt%==y goto gs_db_create
  574. if /i %gsdbprompt%==n goto eof
  575. if /i %gsdbprompt%==r goto configure
  576. if /i %gsdbprompt%==q goto end
  577. goto gs_err1
  578. :gs_db_create
  579. cls
  580. call :colors 17
  581. set stage=6
  582. set cmdline=
  583. title L2JDP Installer - Game Server DataBase Creation
  584. echo.
  585. echo Trying to create a Game Server DataBase...
  586. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -e "CREATE DATABASE %gsdb%" 2^> NUL
  587. %cmdline%
  588. if %ERRORLEVEL% == 0 goto gs_db_ok
  589. if %safe_mode% == 1 goto omfg
  590. :gs_err2
  591. cls
  592. set omfgprompt=q
  593. call :colors 47
  594. title L2JDP Installer - Game Server DataBase Creation ERROR!
  595. echo.
  596. echo An error occured while trying to create a database for
  597. echo your Game Server.
  598. echo.
  599. echo Possible reasons:
  600. echo 1-You provided inaccurate info, check username, pass, etc.
  601. echo 2-User %gsuser% don't have enough privileges for
  602. echo database creation.
  603. echo 3-Database exists already...?
  604. echo.
  605. echo I'd suggest you to look for correct values and try this
  606. echo script again later. But you can try to reconfigure it now.
  607. echo.
  608. echo (r) Reconfigure
  609. echo.
  610. echo (q) Quit now
  611. echo.
  612. set /p omfgprompt=Choose (default quit):
  613. if /i %omfgprompt%==r goto configure
  614. if /i %omfgprompt%==q goto end
  615. goto gs_err2
  616. :gs_db_ok
  617. cls
  618. set installtype=u
  619. call :colors 17
  620. title L2JDP Installer - Game Server DataBase WARNING!
  621. echo.
  622. echo GAME SERVER DATABASE install:
  623. echo.
  624. echo (f) Full: WARNING! I'll destroy ALL of your existing character
  625. echo data (i really mean it: items, pets.. ALL)
  626. echo.
  627. echo (u) Upgrade: I'll do my best to preserve all of your character
  628. echo data.
  629. echo.
  630. echo (s) Skip: We'll get into the last set of questions (cummulative
  631. echo updates, custom stuff...)
  632. echo.
  633. echo (q) Quit
  634. echo.
  635. set /p installtype=Choose (default upgrade):
  636. if /i %installtype%==f goto gs_cleanup
  637. if /i %installtype%==u goto gs_upgrade
  638. if /i %installtype%==s goto custom_ask
  639. if /i %installtype%==q goto end
  640. goto gs_db_ok
  641. :gs_cleanup
  642. call :colors 17
  643. set cmdline=
  644. title L2JDP Installer - Game Server DataBase Full Install
  645. echo.
  646. echo Deleting all Game Server tables for new content.
  647. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< gs_cleanup.sql 2^> NUL
  648. %cmdline%
  649. if not %ERRORLEVEL% == 0 goto omfg
  650. set full=1
  651. echo.
  652. echo Game Server tables has been deleted.
  653. goto gs_install
  654. :gs_upgrade
  655. cls
  656. echo.
  657. echo Upgrading structure of Game Server tables (this could take awhile, be patient).
  658. echo.
  659. echo @echo off> temp.bat
  660. if exist gs_errors.log del gs_errors.log
  661. for %%i in (..\sql\game\updates\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% --force ^< %%i 2^>^> gs_errors.log >> temp.bat
  662. call temp.bat> nul
  663. del temp.bat
  664. move gs_errors.log %workdir%
  665. goto gs_install
  666. :gs_install
  667. cls
  668. set cmdline=
  669. if %full% == 1 (
  670. title L2JDP Installer - Game Server DataBase Installing...
  671. echo.
  672. echo Installing new Game Server content.
  673. echo.
  674. ) else (
  675. title L2JDP Installer - Game Server DataBase Upgrading...
  676. echo.
  677. echo Upgrading Game Server content.
  678. echo.
  679. )
  680. if %logging% == 0 set output=NUL
  681. set dest=gs
  682. for %%i in (..\sql\game\*.sql) do call :dump %%i
  683. echo done...
  684. echo.
  685. goto custom_ask
  686. :dump
  687. set cmdline=
  688. if /i %full% == 1 (set action=Installing) else (set action=Upgrading)
  689. echo %action% %1>>"%output%"
  690. echo %action% %~nx1
  691. if "%dest%"=="ls" set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% ^< %1 2^>^>"%output%"
  692. if "%dest%"=="cb" set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< %1 2^>^>"%output%"
  693. if "%dest%"=="gs" set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %1 2^>^>"%output%"
  694. %cmdline%
  695. if %logging%==0 if NOT %ERRORLEVEL%==0 call :omfg2 %1
  696. goto :eof
  697. :omfg2
  698. cls
  699. set ntpebcak=c
  700. call :colors 47
  701. title L2JDP Installer - Potential DataBase Issue at stage %stage%
  702. echo.
  703. echo Something caused an error while executing instruction :
  704. echo %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb%
  705. echo.
  706. echo with file %~nx1
  707. echo.
  708. echo What we should do now?
  709. echo.
  710. echo (l) Log it: I will create a log for this file, then continue
  711. echo with the rest of the list in non-logging mode.
  712. echo.
  713. echo (c) Continue: Let's pretend that nothing happened and continue with
  714. echo the rest of the list.
  715. echo.
  716. echo (r) Reconfigure: Perhaps these errors were caused by a typo.
  717. echo you can restart from scratch and redefine paths, databases
  718. echo and user info again.
  719. echo.
  720. echo (q) Quit now
  721. echo.
  722. set /p ntpebcak=Choose (default continue):
  723. if /i %ntpebcak%==c (call :colors 17 & goto :eof)
  724. if /i %ntpebcak%==l (call :logginon %1 & goto :eof)
  725. if /i %ntpebcak%==r (call :configure & exit)
  726. if /i %ntpebcak%==q (call :end)
  727. goto omfg2
  728. :logginon
  729. cls
  730. call :colors 17
  731. title L2JDP Installer - Game Server Logging Options turned on
  732. set logging=1
  733. if %full% == 1 (
  734. set output=%logdir%\install-%~nx1.log
  735. ) else (
  736. set output=%logdir%\upgrade-%~nx1.log
  737. )
  738. echo.
  739. echo Per your request, i'll create a log file for your reading pleasure.
  740. echo.
  741. echo I'll call it %output%
  742. echo.
  743. echo If you already have such a file and would like to keep a copy.
  744. echo go now and read it or back it up, because it's not going to be rotated
  745. echo or anything, instead i'll just overwrite it.
  746. echo.
  747. pause
  748. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^<..\sql\%1 2^>^>"%output%"
  749. date /t >"%output%"
  750. time /t >>"%output%"
  751. %cmdline%
  752. echo Log file created, resuming normal operations...
  753. call :colors 17
  754. set logging=0
  755. set output=NUL
  756. goto :eof
  757. :custom_ask
  758. title L2JDP Installer - Custom Server Tables
  759. cls
  760. set cstprompt=n
  761. echo.
  762. echo L2J provides some "Custom Server Tables" for non-retail modifications
  763. echo in order to avoid override the original Server Tables.
  764. echo.
  765. echo Remember that in order to get these additions actually working
  766. echo you need to edit your configuration files.
  767. echo.
  768. set /p cstprompt=Install Custom Server Tables: (y) yes or (n) no (default no):
  769. if /i %cstprompt%==y goto custom_install
  770. if /i %cstprompt%==n goto mod_ask
  771. :custom_install
  772. cls
  773. echo.
  774. echo Installing Custom content.
  775. echo @echo off> temp.bat
  776. if exist custom_errors.log del custom_errors.log
  777. for %%i in (..\sql\game\custom\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %%i 2^>^> custom_errors.log >> temp.bat
  778. call temp.bat> nul
  779. del temp.bat
  780. move custom_errors.log %workdir%
  781. goto mod_ask
  782. :mod_ask
  783. title L2JDP Installer - Mod Server Tables
  784. cls
  785. set cstprompt=n
  786. echo.
  787. echo L2J provides a basic infraestructure for some non-retail features
  788. echo (aka L2J mods) to get enabled with a minimum of changes.
  789. echo.
  790. echo Some of these mods would require extra tables in order to work
  791. echo and those tables could be created now if you wanted to.
  792. echo.
  793. echo Remember that in order to get these additions actually working
  794. echo you need to edit your configuration files.
  795. echo.
  796. set /p cstprompt=Install Mod Server Tables: (y) yes or (n) no (default no):
  797. if /i %cstprompt%==y goto mod_install
  798. if /i %cstprompt%==n goto end
  799. :mod_install
  800. cls
  801. echo.
  802. echo Installing Mods content.
  803. echo @echo off> temp.bat
  804. if exist mods_errors.log del mods_errors.log
  805. for %%i in (..\sql\game\mods\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %%i 2^>^> mods_errors.log >> temp.bat
  806. call temp.bat> nul
  807. del temp.bat
  808. move mods_errors.log %workdir%
  809. goto end
  810. :omfg
  811. set omfgprompt=q
  812. call :colors 57
  813. cls
  814. title L2JDP Installer - Potential PICNIC detected at stage %stage%
  815. echo.
  816. echo There was some problem while executing:
  817. echo.
  818. echo "%cmdline%"
  819. echo.
  820. echo I'd suggest you to look for correct values and try this
  821. echo script again later. But maybe you'd prefer to go on now.
  822. if %stage% == 1 set label=ls_err1
  823. if %stage% == 2 set label=ls_err2
  824. if %stage% == 3 set label=cs_err1
  825. if %stage% == 4 set label=cs_err2
  826. if %stage% == 5 set label=gs_err1
  827. if %stage% == 6 set label=gs_err2
  828. echo.
  829. echo (c) Continue running the script
  830. echo.
  831. echo (r) Reconfigure
  832. echo.
  833. echo (q) Quit now
  834. echo.
  835. set /p omfgprompt=Choose (default quit):
  836. if /i %omfgprompt%==c goto %label%
  837. if /i %omfgprompt%==r goto configure
  838. if /i %omfgprompt%==q goto end
  839. goto omfg
  840. :binaryfind
  841. if EXIST "%mysqlBinPath%" (echo Found) else (echo Not Found)
  842. goto :eof
  843. :end
  844. call :colors 17
  845. title L2JDP Installer - Script Execution Finished
  846. cls
  847. echo.
  848. echo L2JDP Database Installer
  849. echo.
  850. echo Thanks for using our software.
  851. echo visit http://www.l2jdp.com for more info about
  852. echo the L2J DataPack Project.
  853. echo.
  854. pause