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) 2012 L2J DataPack
  8. REM This program is free software; you can redistribute it and/or modify
  9. REM it under the terms of the GNU General Public License as published by
  10. REM the Free Software Foundation; either version 3 of the License, or (at
  11. REM your option) any later version.
  12. REM
  13. REM This program is distributed in the hope that it will be useful, but
  14. REM WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15. REM or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  16. REM for more details.
  17. REM
  18. REM You should have received a copy of the GNU General Public License along
  19. REM with this program; if not, write to the Free Software Foundation, Inc.,
  20. REM 675 Mass Ave, Cambridge, MA 02139, USA. Or contact the Official L2J
  21. REM DataPack Project at http://www.l2jdp.com, http://www.l2jdp.com/forum or
  22. REM #l2j @ irc://irc.freenode.net
  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) Ignose 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.5\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 I 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 I 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 I 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 contunue 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_install
  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 innacurate 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. echo.
  355. echo Upgrading structure of Login Server tables.
  356. echo.
  357. echo @echo off> temp.bat
  358. if exist ls_errors.log del ls_errors.log
  359. 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
  360. call temp.bat> nul
  361. del temp.bat
  362. move ls_errors.log %workdir%
  363. goto ls_install
  364. :ls_install
  365. set cmdline=
  366. if %full% == 1 (
  367. title L2JDP Installer - Login Server DataBase Installing...
  368. echo.
  369. echo Installing new Login Server content.
  370. echo.
  371. ) else (
  372. title L2JDP Installer - Login Server DataBase Upgrading...
  373. echo.
  374. echo Upgrading Login Server content.
  375. echo.
  376. )
  377. if %logging% == 0 set output=NUL
  378. set dest=ls
  379. for %%i in (..\sql\login\*.sql) do call :dump %%i
  380. echo done...
  381. echo.
  382. goto cs_backup
  383. :cs_backup
  384. cls
  385. call :colors 17
  386. set cmdline=
  387. set stage=3
  388. title L2JDP Installer - Community Server DataBase Backup
  389. echo.
  390. echo Trying to make a backup of your Comunity Server DataBase.
  391. set cmdline="%mysqldumpPath%" --add-drop-table -h %cbhost% -u %cbuser% --password=%cbpass% %cbdb% ^> "%backup%\cs_backup.sql" 2^> NUL
  392. %cmdline%
  393. if %ERRORLEVEL% == 0 goto cs_db_ok
  394. :cs_err1
  395. cls
  396. set cbdbprompt=y
  397. call :colors 47
  398. title L2JDP Installer - Community Server DataBase Backup ERROR!
  399. echo.
  400. echo Backup attempt failed! A possible reason for this to
  401. echo happen, is that your DB doesn't exist yet. I could
  402. echo try to create %cbdb% for you, or maybe you prefer to
  403. echo continue with the GameServer part of this tool.
  404. echo.
  405. echo ATTEMPT TO CREATE COMMUNITY SERVER DATABASE:
  406. echo.
  407. echo (y) Yes
  408. echo.
  409. echo (n) No
  410. echo.
  411. echo (r) Reconfigure
  412. echo.
  413. echo (q) Quit
  414. echo.
  415. set /p cbdbprompt=Choose (default yes):
  416. if /i %cbdbprompt%==y goto cs_db_create
  417. if /i %cbdbprompt%==n goto gs_backup
  418. if /i %cbdbprompt%==r goto configure
  419. if /i %cbdbprompt%==q goto end
  420. goto cs_err1
  421. :cs_db_create
  422. cls
  423. call :colors 17
  424. set cmdline=
  425. set stage=4
  426. title L2JDP Installer - Community Server DataBase Creation
  427. echo.
  428. echo Trying to create a Community Server DataBase...
  429. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -e "CREATE DATABASE %cbdb%" 2^> NUL
  430. %cmdline%
  431. if %ERRORLEVEL% == 0 goto cs_install
  432. if %safe_mode% == 1 goto omfg
  433. :cs_err2
  434. cls
  435. set omfgprompt=q
  436. call :colors 47
  437. title L2JDP Installer - Community Server DataBase Creation ERROR!
  438. echo.
  439. echo An error occured while trying to create a database for
  440. echo your Community Server.
  441. echo.
  442. echo Possible reasons:
  443. echo 1-You provided innacurate info , check user, password, etc.
  444. echo 2-User %cbuser% don't have enough privileges for
  445. echo database creation. Check your MySQL privileges.
  446. echo 3-Database exists already...?
  447. echo.
  448. echo Unless you're sure that the pending actions of this tool
  449. echo could work, i'd suggest you to look for correct values
  450. echo and try this script again later.
  451. echo.
  452. echo (c) Continue running
  453. echo.
  454. echo (r) Reconfigure
  455. echo.
  456. echo (q) Quit now
  457. echo.
  458. set /p omfgprompt=Choose (default quit):
  459. if /i %omfgprompt%==c goto gs_backup
  460. if /i %omfgprompt%==r goto configure
  461. if /i %omfgprompt%==q goto end
  462. goto cs_err2
  463. :cs_db_ok
  464. cls
  465. set communityprompt=u
  466. call :colors 17
  467. title L2JDP Installer - Community Server DataBase WARNING!
  468. echo.
  469. echo COMMUNITY SERVER DATABASE install type:
  470. echo.
  471. echo (f) Full: WARNING! I'll destroy ALL of your existing community
  472. echo data (i really mean it: mail, forum, memo.. ALL)
  473. echo.
  474. echo (u) Upgrade: I'll do my best to preserve all of your community
  475. echo data.
  476. echo.
  477. echo (s) Skip: I'll take you to the gameserver database
  478. echo installation and upgrade options.
  479. echo.
  480. echo (r) Reconfigure: You'll be able to redefine MySQL path,
  481. echo user and database information and start over with
  482. echo those fresh values.
  483. echo.
  484. echo (q) Quit
  485. echo.
  486. set /p communityprompt=Choose (default upgrade):
  487. if /i %communityprompt%==f goto cs_cleanup
  488. if /i %communityprompt%==u goto cs_upgrade
  489. if /i %communityprompt%==s goto gs_backup
  490. if /i %communityprompt%==r goto configure
  491. if /i %communityprompt%==q goto end
  492. goto cs_db_ok
  493. :cs_cleanup
  494. call :colors 17
  495. set cmdline=
  496. title L2JDP Installer - Community Server DataBase Full Install
  497. echo.
  498. echo Deleting Community Server tables for new content.
  499. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< cs_cleanup.sql 2^> NUL
  500. %cmdline%
  501. if not %ERRORLEVEL% == 0 goto omfg
  502. set full=1
  503. echo.
  504. echo Community Server tables has been deleted.
  505. goto cs_install
  506. :cs_upgrade
  507. echo.
  508. echo Upgrading structure of Community Server tables.
  509. echo.
  510. echo @echo off> temp.bat
  511. if exist cs_errors.log del cs_errors.log
  512. 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
  513. call temp.bat> nul
  514. del temp.bat
  515. move cs_errors.log %workdir%
  516. goto cs_install
  517. :cs_install
  518. set cmdline=
  519. if %full% == 1 (
  520. title L2JDP Installer - Community Server DataBase Installing...
  521. echo.
  522. echo Installing new Community Server content.
  523. echo.
  524. ) else (
  525. title L2JDP Installer - Community Server DataBase Upgrading...
  526. echo.
  527. echo Upgrading Community Server content.
  528. echo.
  529. )
  530. if %logging% == 0 set output=NUL
  531. set dest=cb
  532. for %%i in (..\sql\community\*.sql) do call :dump %%i
  533. echo done...
  534. echo.
  535. goto gs_backup
  536. :gs_backup
  537. cls
  538. call :colors 17
  539. set cmdline=
  540. set stage=5
  541. title L2JDP Installer - Game Server DataBase Backup
  542. echo.
  543. echo Trying to make a backup of your Game Server DataBase.
  544. set cmdline="%mysqldumpPath%" --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% ^> "%backup%\gs_backup.sql" 2^> NUL
  545. %cmdline%
  546. if %ERRORLEVEL% == 0 goto gs_db_ok
  547. :gs_err1
  548. cls
  549. set gsdbprompt=y
  550. call :colors 47
  551. title L2JDP Installer - Game Server DataBase Backup ERROR!
  552. echo.
  553. echo Backup attempt failed! A possible reason for this to
  554. echo happen, is that your DB doesn't exist yet. I could
  555. echo try to create %gsdb% for you, but maybe you prefer to
  556. echo continue with last part of the script.
  557. echo.
  558. echo ATTEMPT TO CREATE GAME SERVER DATABASE?
  559. echo.
  560. echo (y) Yes
  561. echo.
  562. echo (n) No
  563. echo.
  564. echo (r) Reconfigure
  565. echo.
  566. echo (q) Quit
  567. echo.
  568. set /p gsdbprompt=Choose (default yes):
  569. if /i %gsdbprompt%==y goto gs_db_create
  570. if /i %gsdbprompt%==n goto eof
  571. if /i %gsdbprompt%==r goto configure
  572. if /i %gsdbprompt%==q goto end
  573. goto gs_err1
  574. :gs_db_create
  575. cls
  576. call :colors 17
  577. set stage=6
  578. set cmdline=
  579. title L2JDP Installer - Game Server DataBase Creation
  580. echo.
  581. echo Trying to create a Game Server DataBase...
  582. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -e "CREATE DATABASE %gsdb%" 2^> NUL
  583. %cmdline%
  584. if %ERRORLEVEL% == 0 goto gs_install
  585. if %safe_mode% == 1 goto omfg
  586. :gs_err2
  587. cls
  588. set omfgprompt=q
  589. call :colors 47
  590. title L2JDP Installer - Game Server DataBase Creation ERROR!
  591. echo.
  592. echo An error occured while trying to create a database for
  593. echo your Game Server.
  594. echo.
  595. echo Possible reasons:
  596. echo 1-You provided innacurate info, check username, pass, etc.
  597. echo 2-User %gsuser% don't have enough privileges for
  598. echo database creation.
  599. echo 3-Database exists already...?
  600. echo.
  601. echo I'd suggest you to look for correct values and try this
  602. echo script again later. But you can try to reconfigure it now.
  603. echo.
  604. echo (r) Reconfigure
  605. echo.
  606. echo (q) Quit now
  607. echo.
  608. set /p omfgprompt=Choose (default quit):
  609. if /i %omfgprompt%==r goto configure
  610. if /i %omfgprompt%==q goto end
  611. goto gs_err2
  612. :gs_db_ok
  613. cls
  614. set installtype=u
  615. call :colors 17
  616. title L2JDP Installer - Game Server DataBase WARNING!
  617. echo.
  618. echo GAME SERVER DATABASE install:
  619. echo.
  620. echo (f) Full: WARNING! I'll destroy ALL of your existing character
  621. echo data (i really mean it: items, pets.. ALL)
  622. echo.
  623. echo (u) Upgrade: I'll do my best to preserve all of your character
  624. echo data.
  625. echo.
  626. echo (s) Skip: We'll get into the last set of questions (cummulative
  627. echo updates, custom stuff...)
  628. echo.
  629. echo (q) Quit
  630. echo.
  631. set /p installtype=Choose (default upgrade):
  632. if /i %installtype%==f goto gs_cleanup
  633. if /i %installtype%==u goto gs_upgrade
  634. if /i %installtype%==s goto custom_ask
  635. if /i %installtype%==q goto end
  636. goto gs_db_ok
  637. :gs_cleanup
  638. call :colors 17
  639. set cmdline=
  640. title L2JDP Installer - Game Server DataBase Full Install
  641. echo.
  642. echo Deleting all Game Server tables for new content.
  643. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< gs_cleanup.sql 2^> NUL
  644. %cmdline%
  645. if not %ERRORLEVEL% == 0 goto omfg
  646. set full=1
  647. echo.
  648. echo Game Server tables has been deleted.
  649. goto gs_install
  650. :gs_upgrade
  651. echo.
  652. echo Upgrading structure of Game Server tables (this could take awhile, be patient).
  653. echo.
  654. echo @echo off> temp.bat
  655. if exist gs_errors.log del gs_errors.log
  656. 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
  657. call temp.bat> nul
  658. del temp.bat
  659. move gs_errors.log %workdir%
  660. goto gs_install
  661. :gs_install
  662. set cmdline=
  663. if %full% == 1 (
  664. title L2JDP Installer - Game Server DataBase Installing...
  665. echo.
  666. echo Installing new Game Server content.
  667. echo.
  668. ) else (
  669. title L2JDP Installer - Game Server DataBase Upgrading...
  670. echo.
  671. echo Upgrading Game Server content.
  672. echo.
  673. )
  674. if %logging% == 0 set output=NUL
  675. set dest=gs
  676. for %%i in (..\sql\game\*.sql) do call :dump %%i
  677. echo done...
  678. echo.
  679. goto custom_ask
  680. :dump
  681. set cmdline=
  682. if /i %full% == 1 (set action=Installing) else (set action=Upgrading)
  683. echo %action% %1>>"%output%"
  684. echo %action% %~nx1
  685. if "%dest%"=="ls" set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% ^< %1 2^>^>"%output%"
  686. if "%dest%"=="cb" set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< %1 2^>^>"%output%"
  687. if "%dest%"=="gs" set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %1 2^>^>"%output%"
  688. %cmdline%
  689. if %logging%==0 if NOT %ERRORLEVEL%==0 call :omfg2 %1
  690. goto :eof
  691. :omfg2
  692. cls
  693. set ntpebcak=c
  694. call :colors 47
  695. title L2JDP Installer - Potential DataBase Issue at stage %stage%
  696. echo.
  697. echo Something caused an error while executing instruction :
  698. echo %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb%
  699. echo.
  700. echo with file %~nx1
  701. echo.
  702. echo What we should do now?
  703. echo.
  704. echo (l) Log it: I will create a log for this file, then continue
  705. echo with the rest of the list in non-logging mode.
  706. echo.
  707. echo (c) Continue: Let's pretend that nothing happened and continue with
  708. echo the rest of the list.
  709. echo.
  710. echo (r) Reconfigure: Perhaps these errors were caused by a typo.
  711. echo you can restart from scratch and redefine paths, databases
  712. echo and user info again.
  713. echo.
  714. echo (q) Quit now
  715. echo.
  716. set /p ntpebcak=Choose (default continue):
  717. if /i %ntpebcak%==c (call :colors 17 & goto :eof)
  718. if /i %ntpebcak%==l (call :logginon %1 & goto :eof)
  719. if /i %ntpebcak%==r (call :configure & exit)
  720. if /i %ntpebcak%==q (call :end)
  721. goto omfg2
  722. :logginon
  723. cls
  724. call :colors 17
  725. title L2JDP Installer - Game Server Logging Options turned on
  726. set logging=1
  727. if %full% == 1 (
  728. set output=%logdir%\install-%~nx1.log
  729. ) else (
  730. set output=%logdir%\upgrade-%~nx1.log
  731. )
  732. echo.
  733. echo Per your request, i'll create a log file for your reading pleasure.
  734. echo.
  735. echo I'll call it %output%
  736. echo.
  737. echo If you already have such a file and would like to keep a copy.
  738. echo go now and read it or back it up, because it's not going to be rotated
  739. echo or anything, instead i'll just overwrite it.
  740. echo.
  741. pause
  742. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^<..\sql\%1 2^>^>"%output%"
  743. date /t >"%output%"
  744. time /t >>"%output%"
  745. %cmdline%
  746. echo Log file created, resuming normal operations...
  747. call :colors 17
  748. set logging=0
  749. set output=NUL
  750. goto :eof
  751. :custom_ask
  752. title L2JDP Installer - Custom Server Tables
  753. cls
  754. set cstprompt=n
  755. echo.
  756. echo L2J provides some "Custom Server Tables" for non-retail modifications
  757. echo in order to avoid override the original Server Tables.
  758. echo.
  759. echo Remember that in order to get these additions actually working
  760. echo you need to edit your configuration files.
  761. echo.
  762. set /p cstprompt=Install Custom Server Tables: (y) yes or (n) no (default no):
  763. if /i %cstprompt%==y goto custom_install
  764. if /i %cstprompt%==n goto mod_ask
  765. :custom_install
  766. cls
  767. echo.
  768. echo Installing Custom content.
  769. echo @echo off> temp.bat
  770. if exist custom_errors.log del custom_errors.log
  771. 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
  772. call temp.bat> nul
  773. del temp.bat
  774. move custom_errors.log %workdir%
  775. goto mod_ask
  776. :mod_ask
  777. title L2JDP Installer - Mod Server Tables
  778. cls
  779. set cstprompt=n
  780. echo.
  781. echo L2J provides a basic infraestructure for some non-retail features
  782. echo (aka L2J mods) to get enabled with a minimum of changes.
  783. echo.
  784. echo Some of these mods would require extra tables in order to work
  785. echo and those tables could be created now if you wanted to.
  786. echo.
  787. echo Remember that in order to get these additions actually working
  788. echo you need to edit your configuration files.
  789. echo.
  790. set /p cstprompt=Install Mod Server Tables: (y) yes or (n) no (default no):
  791. if /i %cstprompt%==y goto mod_install
  792. if /i %cstprompt%==n goto end
  793. :mod_install
  794. cls
  795. echo.
  796. echo Installing Mods content.
  797. echo @echo off> temp.bat
  798. if exist mods_errors.log del mods_errors.log
  799. 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
  800. call temp.bat> nul
  801. del temp.bat
  802. move mods_errors.log %workdir%
  803. goto end
  804. :omfg
  805. set omfgprompt=q
  806. call :colors 57
  807. cls
  808. title L2JDP Installer - Potential PICNIC detected at stage %stage%
  809. echo.
  810. echo There was some problem while executing:
  811. echo.
  812. echo "%cmdline%"
  813. echo.
  814. echo I'd suggest you to look for correct values and try this
  815. echo script again later. But maybe you'd prefer to go on now.
  816. if %stage% == 1 set label=ls_err1
  817. if %stage% == 2 set label=ls_err2
  818. if %stage% == 3 set label=cs_err1
  819. if %stage% == 4 set label=cs_err2
  820. if %stage% == 5 set label=gs_err1
  821. if %stage% == 6 set label=gs_err2
  822. echo.
  823. echo (c) Continue running the script
  824. echo.
  825. echo (r) Reconfigure
  826. echo.
  827. echo (q) Quit now
  828. echo.
  829. set /p omfgprompt=Choose (default quit):
  830. if /i %omfgprompt%==c goto %label%
  831. if /i %omfgprompt%==r goto configure
  832. if /i %omfgprompt%==q goto end
  833. goto omfg
  834. :binaryfind
  835. if EXIST "%mysqlBinPath%" (echo Found) else (echo Not Found)
  836. goto :eof
  837. :end
  838. call :colors 17
  839. title L2JDP Installer - Script Execution Finished
  840. cls
  841. echo.
  842. echo L2JDP Database Installer 2012
  843. echo.
  844. echo (C) 2004-2012 L2J DataPack Team
  845. echo L2JDP Database Installer comes with ABSOLUTELY NO WARRANTY
  846. echo This is free software, and you are welcome to redistribute it
  847. echo under certain conditions; See the file gpl.txt for further
  848. echo details.
  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