database_installer.bat 26 KB

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