database_installer.bat 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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) 2010 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. title L2JDP Installer - Reading Configuration from File...
  37. cls
  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_section
  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_section
  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. call :colors 17
  81. title L2JDP Installer - Setup
  82. cls
  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-LoginServer settings
  146. echo --------------------
  147. echo I will connect to the MySQL server you specify, and setup a
  148. echo Loginserver database there, most people use a single MySQL
  149. echo server and database for both Login and Gameserver tables.
  150. echo.
  151. set /P lsuser="MySQL Username (default is '%lsuser%'): "
  152. set /P lspass="Password (default is '%lspass%'): "
  153. set /P lsdb="Database (default is '%lsdb%'): "
  154. set /P lshost="Host (default is '%lshost%'): "
  155. echo.
  156. cls
  157. echo.
  158. echo 3-Community Board Server settings
  159. echo --------------------
  160. echo I will connect to the MySQL server you specify, and setup a
  161. echo Community Board server database there, most people use a single MySQL
  162. echo server for both Login and Gameserver which CBserver can use too,
  163. echo but CBserver requires a different database!
  164. echo.
  165. set /P cbuser="MySQL Username (default is '%cbuser%'): "
  166. set /P cbpass="Password (default is '%cbpass%'): "
  167. set /P cbdb="Database (default is '%cbdb%'): "
  168. set /P cbhost="Host (default is '%cbhost%'): "
  169. echo.
  170. cls
  171. echo.
  172. echo 4-GameServer settings
  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. echo.
  194. if "%mysqlBinPath%" == "use path" (
  195. set mysqlBinPath=
  196. set mysqldumpPath=mysqldump
  197. set mysqlPath=mysql
  198. ) else (
  199. set mysqldumpPath=%mysqlBinPath%\mysqldump.exe
  200. set mysqlPath=%mysqlBinPath%\mysql.exe
  201. )
  202. echo @echo off > %config_file%
  203. echo set config_version=%config_version% >> %config_file%
  204. echo set cmode=%cmode%>> %config_file%
  205. echo set safe_mode=%safe_mode% >> %config_file%
  206. echo set mysqlPath=%mysqlPath%>> %config_file%
  207. echo set mysqlBinPath=%mysqlBinPath%>> %config_file%
  208. echo set mysqldumpPath=%mysqldumpPath%>> %config_file%
  209. echo set lsuser=%lsuser%>> %config_file%
  210. echo set lspass=%lspass%>> %config_file%
  211. echo set lsdb=%lsdb%>> %config_file%
  212. echo set lshost=%lshost% >> %config_file%
  213. echo set cbuser=%cbuser%>> %config_file%
  214. echo set cbpass=%cbpass%>> %config_file%
  215. echo set cbdb=%cbdb%>> %config_file%
  216. echo set cbhost=%cbhost% >> %config_file%
  217. echo set gsuser=%gsuser%>> %config_file%
  218. echo set gspass=%gspass%>> %config_file%
  219. echo set gsdb=%gsdb%>> %config_file%
  220. echo set gshost=%gshost%>> %config_file%
  221. echo set logdir=%logdir%>> %config_file%
  222. echo set backup=%backup%>> %config_file%
  223. echo.
  224. echo Script setup complete, your settings were saved in the
  225. echo '%config_file%' file. Remember: your passwords are stored
  226. echo as clear text.
  227. echo.
  228. pause
  229. goto loadconfig
  230. :ls_section
  231. cls
  232. call :colors 17
  233. set cmdline=
  234. set stage=1
  235. title L2JDP Installer - Login Server DataBase Setup
  236. echo.
  237. echo Trying to make a backup of your Login Server database.
  238. set cmdline="%mysqldumpPath%" --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% ^> "%backup%\ls_backup.sql" 2^> NUL
  239. %cmdline%
  240. if %ERRORLEVEL% == 0 goto ls_db_ok
  241. :ls_err1
  242. call :colors 47
  243. title L2JDP Installer - Login Server DataBase Setup ERROR!
  244. cls
  245. echo.
  246. echo Backup attempt failed! A possible reason for this to
  247. echo happen, is that your DB doesn't exist yet. I could
  248. echo try to create %lsdb% for you, or maybe you prefer to
  249. echo proceed with the CommunityServer part of this tool.
  250. echo.
  251. :ls_ask1
  252. set lsdbprompt=y
  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 lsdbcreate
  265. if /i %lsdbprompt%==n goto cb_backup
  266. if /i %lsdbprompt%==r goto configure
  267. if /i %lsdbprompt%==q goto end
  268. goto ls_ask1
  269. :omfg
  270. cls
  271. call :colors 57
  272. title L2JDP Installer - Potential PICNIC detected at stage %stage%
  273. echo.
  274. echo There was some problem while executing:
  275. echo.
  276. echo "%cmdline%"
  277. echo.
  278. echo I'd suggest you to look for correct values and try this
  279. echo script again later. But maybe you'd prefer to go on now.
  280. echo.
  281. if %stage% == 1 set label=ls_err1
  282. if %stage% == 2 set label=ls_err2
  283. if %stage% == 3 set label=cb_backup
  284. if %stage% == 4 set label=cb_err1
  285. if %stage% == 5 set label=cb_err2
  286. if %stage% == 6 set label=gs_backup
  287. if %stage% == 7 set label=gs_err1
  288. if %stage% == 8 set label=gs_err2
  289. if %stage% == 9 set label=horrible_end
  290. if %stage% == 10 set label=horrible_end
  291. :omfgask1
  292. set omfgprompt=q
  293. echo (c) Continue running the script
  294. echo.
  295. echo (r) Reconfigure
  296. echo.
  297. echo (q) Quit now
  298. echo.
  299. set /p omfgprompt= Choose (default quit):
  300. if /i %omfgprompt%==c goto %label%
  301. if /i %omfgprompt%==r goto configure
  302. if /i %omfgprompt%==q goto horrible_end
  303. goto omfgask1
  304. :lsdbcreate
  305. cls
  306. call :colors 17
  307. set cmdline=
  308. set stage=2
  309. title L2JDP Installer - Login Server DataBase Setup - DB Creation
  310. echo.
  311. echo Trying to create a Login Server database...
  312. set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -e "CREATE DATABASE %lsdb%" 2^> NUL
  313. %cmdline%
  314. if %ERRORLEVEL% == 0 goto ls_install
  315. if %safe_mode% == 1 goto omfg
  316. :ls_err2
  317. call :colors 47
  318. title L2JDP Installer - Login Server DataBase Setup - DB Creation ERROR!
  319. cls
  320. echo An error occured while trying to create a database for
  321. echo your login server.
  322. echo.
  323. echo Possible reasons:
  324. echo 1-You provided innacurate info , check user, password, etc.
  325. echo 2-User %lsuser% don't have enough privileges for
  326. echo database creation. Check your MySQL privileges.
  327. echo 3-Database exists already...?
  328. echo.
  329. echo Unless you're sure that the pending actions of this tool
  330. echo could work, i'd suggest you to look for correct values
  331. echo and try this script again later.
  332. echo.
  333. :ls_ask2
  334. set omfgprompt=q
  335. echo (c) Continue running
  336. echo.
  337. echo (r) Reconfigure
  338. echo.
  339. echo (q) Quit now
  340. echo.
  341. set /p omfgprompt= Choose (default quit):
  342. if /i %omfgprompt%==c goto cb_backup
  343. if /i %omfgprompt%==q goto horrible_end
  344. if /i %omfgprompt%==r goto configure
  345. goto ls_ask2
  346. :ls_db_ok
  347. call :colors 17
  348. title L2JDP Installer - Login Server DataBase Setup - WARNING!
  349. :ls_ask
  350. cls
  351. set loginprompt=u
  352. echo.
  353. echo LOGINSERVER DATABASE install type:
  354. echo.
  355. echo (f) Full: I will destroy data in your `accounts` tables.
  356. echo.
  357. echo (u) Upgrade: I'll do my best to preserve all login data.
  358. echo.
  359. echo (s) Skip: I'll take you to the communityserver database
  360. echo installation and upgrade options.
  361. echo.
  362. echo (r) Reconfigure: You'll be able to redefine MySQL path,
  363. echo user and database information and start over with
  364. echo those fresh values.
  365. echo.
  366. echo (q) Quit
  367. echo.
  368. set /p loginprompt= Choose (default upgrade):
  369. if /i %loginprompt%==f goto ls_cleanup
  370. if /i %loginprompt%==u goto ls_upgrade
  371. if /i %loginprompt%==s goto cb_backup
  372. if /i %loginprompt%==r goto configure
  373. if /i %loginprompt%==q goto end
  374. goto ls_ask
  375. :ls_cleanup
  376. set stage=3
  377. call :colors 17
  378. set cmdline=
  379. title L2JDP Installer - Login Server DataBase Setup - Full Install
  380. echo.
  381. echo Deleting Login Server tables for new content.
  382. set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% ^< ls_cleanup.sql 2^> NUL
  383. %cmdline%
  384. if not %ERRORLEVEL% == 0 goto omfg
  385. set full=1
  386. echo.
  387. echo Login Server tables has been deleted.
  388. goto ls_install
  389. :ls_upgrade
  390. echo.
  391. echo Upgrading structure of Login Server tables.
  392. echo.
  393. echo @echo off> temp.bat
  394. if exist ls_errors.txt del ls_errors.txt
  395. for %%i in (..\sql\login\updates\*.sql) do echo "%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% --force ^< %%i 2^>^> ls_errors.txt >> temp.bat
  396. call temp.bat> nul
  397. del temp.bat
  398. move ls_errors.txt %workdir%
  399. goto ls_install
  400. :ls_install
  401. set stage=3
  402. set cmdline=
  403. if %full% == 1 (
  404. title L2JDP Installer - Login Server DataBase Setup - Installing...
  405. echo.
  406. echo Installing new Login Server content.
  407. echo.
  408. ) else (
  409. title L2JDP Installer - Login Server DataBase Setup - Upgrading...
  410. echo.
  411. echo Upgrading Login Server content.
  412. echo.
  413. )
  414. if %logging% == 0 set output=NUL
  415. set dest=ls
  416. for %%i in (..\sql\login\*.sql) do call :dump %%i
  417. echo done...
  418. echo.
  419. goto cb_backup
  420. :cb_backup
  421. cls
  422. call :colors 17
  423. set cmdline=
  424. set stage=4
  425. title L2JDP Installer - Community Server DataBase Setup
  426. echo.
  427. echo Trying to make a backup of your Comunity Server database.
  428. set cmdline="%mysqldumpPath%" --add-drop-table -h %cbhost% -u %cbuser% --password=%cbpass% %cbdb% ^> "%backup%\cs_backup.sql" 2^> NUL
  429. %cmdline%
  430. if %ERRORLEVEL% == 0 goto cs_db_ok
  431. :cb_err1
  432. call :colors 47
  433. title L2JDP Installer - Community Server DataBase Setup ERROR!
  434. cls
  435. echo.
  436. echo Backup attempt failed! A possible reason for this to
  437. echo happen, is that your DB doesn't exist yet. I could
  438. echo try to create %cbdb% for you, or maybe you prefer to
  439. echo proceed with the GameServer part of this tool.
  440. echo.
  441. :cb_ask1
  442. set cbdbprompt=y
  443. echo ATTEMPT TO CREATE COMMUNITY SERVER DATABASE:
  444. echo.
  445. echo (y) Yes
  446. echo.
  447. echo (n) No
  448. echo.
  449. echo (r) Reconfigure
  450. echo.
  451. echo (q) Quit
  452. echo.
  453. set /p cbdbprompt= Choose (default yes):
  454. if /i %cbdbprompt%==y goto cbdbcreate
  455. if /i %cbdbprompt%==n goto gs_backup
  456. if /i %cbdbprompt%==r goto configure
  457. if /i %cbdbprompt%==q goto end
  458. goto cb_ask1
  459. :cbdbcreate
  460. call :colors 17
  461. set cmdline=
  462. set stage=5
  463. title L2JDP Installer - Communty Server DataBase Setup - DB Creation
  464. echo.
  465. echo Trying to create a Community Server database...
  466. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -e "CREATE DATABASE %cbdb%" 2^> NUL
  467. %cmdline%
  468. if %ERRORLEVEL% == 0 goto cs_install
  469. if %safe_mode% == 1 goto omfg
  470. :cb_err2
  471. call :colors 47
  472. title L2JDP Installer - Community Board Server DataBase Setup - DB Creation ERROR!
  473. cls
  474. echo An error occured while trying to create a database for
  475. echo your Community Board server.
  476. echo.
  477. echo Possible reasons:
  478. echo 1-You provided innacurate info , check user, password, etc.
  479. echo 2-User %cbuser% don't have enough privileges for
  480. echo database creation. Check your MySQL privileges.
  481. echo 3-Database exists already...?
  482. echo.
  483. echo Unless you're sure that the pending actions of this tool
  484. echo could work, i'd suggest you to look for correct values
  485. echo and try this script again later.
  486. echo.
  487. :cb_ask2
  488. set omfgprompt=q
  489. echo (c) Continue running
  490. echo.
  491. echo (r) Reconfigure
  492. echo.
  493. echo (q) Quit now
  494. echo.
  495. set /p omfgprompt= Choose (default quit):
  496. if /i %omfgprompt%==c goto gs_backup
  497. if /i %omfgprompt%==q goto horrible_end
  498. if /i %omfgprompt%==r goto configure
  499. goto cb_ask2
  500. :cs_db_ok
  501. call :colors 17
  502. title L2JDP Installer - Community Server DataBase Setup - WARNING!
  503. :cs_ask
  504. cls
  505. set communityprompt=u
  506. echo.
  507. echo COMMUNITY SERVER DATABASE install type:
  508. echo.
  509. echo (f) Full: WARNING! I'll destroy ALL of your existing community
  510. echo data (i really mean it: mail, forum, memo.. ALL)
  511. echo.
  512. echo (u) Upgrade: I'll do my best to preserve all of your community
  513. echo data.
  514. echo.
  515. echo (s) Skip: I'll take you to the gameserver database
  516. echo installation and upgrade options.
  517. echo.
  518. echo (r) Reconfigure: You'll be able to redefine MySQL path,
  519. echo user and database information and start over with
  520. echo those fresh values.
  521. echo.
  522. echo (q) Quit
  523. echo.
  524. set /p communityprompt= Choose (default upgrade):
  525. if /i %communityprompt%==f goto cs_cleanup
  526. if /i %communityprompt%==u goto cs_upgrade
  527. if /i %communityprompt%==s goto gs_backup
  528. if /i %communityprompt%==r goto configure
  529. if /i %communityprompt%==q goto end
  530. goto cs_ask
  531. :cs_cleanup
  532. set stage=6
  533. call :colors 17
  534. set cmdline=
  535. title L2JDP Installer - Community Server DataBase Setup - Full Install
  536. echo.
  537. echo Deleting Community Server tables for new content.
  538. set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< cs_cleanup.sql 2^> NUL
  539. %cmdline%
  540. if not %ERRORLEVEL% == 0 goto omfg
  541. set full=1
  542. echo.
  543. echo Community Server tables has been deleted.
  544. goto cs_install
  545. :cs_upgrade
  546. echo.
  547. echo Upgrading structure of Community Server tables.
  548. echo.
  549. echo @echo off> temp.bat
  550. if exist cs_errors.txt del cs_errors.txt
  551. for %%i in (..\sql\community\updates\*.sql) do echo "%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% --force ^< %%i 2^>^> cs_errors.txt >> temp.bat
  552. call temp.bat> nul
  553. del temp.bat
  554. move cs_errors.txt %workdir%
  555. goto cs_install
  556. :cs_install
  557. set stage=6
  558. set cmdline=
  559. if %full% == 1 (
  560. title L2JDP Installer - Community Server DataBase Setup - Installing...
  561. echo.
  562. echo Installing new Community Server content.
  563. echo.
  564. ) else (
  565. title L2JDP Installer - Community Server DataBase Setup - Upgrading...
  566. echo.
  567. echo Upgrading Community Server content.
  568. echo.
  569. )
  570. if %logging% == 0 set output=NUL
  571. set dest=cb
  572. for %%i in (..\sql\community\*.sql) do call :dump %%i
  573. echo done...
  574. echo.
  575. goto gs_backup
  576. :gs_backup
  577. cls
  578. call :colors 17
  579. set cmdline=
  580. set stage=7
  581. title L2JDP Installer - Game Server DataBase Setup
  582. cls
  583. echo.
  584. echo Trying to make a backup of your Game Server database.
  585. set cmdline="%mysqldumpPath%" --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% ^> "%backup%\gs_backup.sql" 2^> NUL
  586. %cmdline%
  587. if %ERRORLEVEL% == 0 goto gs_db_ok
  588. :gs_err1
  589. call :colors 47
  590. title L2JDP Installer - Game Server DataBase Setup - Backup ERROR!
  591. cls
  592. echo.
  593. echo Backup attempt failed! A possible reason for this to happen,
  594. echo is that your DB doesn't exist yet. I could try to create
  595. echo %gsdb% for you, but maybe you prefer me to continue with
  596. echo last part of the script.
  597. echo.
  598. :askgsdb
  599. set gsdbprompt=y
  600. echo ATTEMPT TO CREATE GAME SERVER DATABASE?
  601. echo.
  602. echo (y) Yes
  603. echo.
  604. echo (n) No
  605. echo.
  606. echo (r) Reconfigure
  607. echo.
  608. echo (q) Quit
  609. echo.
  610. set /p gsdbprompt= Choose (default yes):
  611. if /i %gsdbprompt%==y goto gsdbcreate
  612. if /i %gsdbprompt%==n goto horrible_end
  613. if /i %gsdbprompt%==r goto configure
  614. if /i %gsdbprompt%==q goto end
  615. goto askgsdb
  616. :gsdbcreate
  617. call :colors 17
  618. set stage=8
  619. set cmdline=
  620. title L2JDP Installer - Game Server DataBase Setup - DB Creation
  621. cls
  622. echo Trying to create a Game Server database...
  623. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -e "CREATE DATABASE %gsdb%" 2^> NUL
  624. %cmdline%
  625. if %ERRORLEVEL% == 0 goto gs_install
  626. if %safe_mode% == 1 goto omfg
  627. :gs_err2
  628. call :colors 47
  629. title L2JDP Installer - Game Server DataBase Setup - DB Creation ERROR!
  630. cls
  631. echo.
  632. echo An error occured while trying to create a database for
  633. echo your game server.
  634. echo.
  635. echo Possible reasons:
  636. echo 1-You provided innacurate info, check username, pass, etc.
  637. echo 2-User %gsuser% don't have enough privileges for
  638. echo database creation.
  639. echo 3-Database exists already...?
  640. echo.
  641. echo I'd suggest you to look for correct values and try this
  642. echo script again later. But you can try to reconfigure it now.
  643. echo.
  644. :askgsdbcreate
  645. set omfgprompt=q
  646. echo (r) Restart script with fresh configuration values
  647. echo.
  648. echo (q) Quit now
  649. echo.
  650. set /p omfgprompt= Choose (default quit):
  651. if /i %omfgprompt%==r goto configure
  652. if /i %omfgprompt%==q goto horrible_end
  653. goto askgsdbcreate
  654. :gs_db_ok
  655. call :colors 17
  656. title L2JDP Installer - Game Server DataBase Setup - WARNING!
  657. cls
  658. :gs_ask
  659. cls
  660. set installtype=u
  661. echo.
  662. echo GAME SERVER DATABASE install:
  663. echo.
  664. echo (f) Full: WARNING! I'll destroy ALL of your existing character
  665. echo data (i really mean it: items, pets.. ALL)
  666. echo.
  667. echo (u) Upgrade: I'll do my best to preserve all of your character
  668. echo data.
  669. echo.
  670. echo (s) Skip: We'll get into the last set of questions (cummulative
  671. echo updates, custom stuff...)
  672. echo.
  673. echo (q) Quit
  674. echo.
  675. set /p installtype= Choose (default upgrade):
  676. if /i %installtype%==f goto gs_cleanup
  677. if /i %installtype%==u goto gs_upgrade
  678. if /i %installtype%==s goto custom_ask
  679. if /i %installtype%==q goto end
  680. goto gs_ask
  681. :gs_cleanup
  682. call :colors 17
  683. set stage=9
  684. set cmdline=
  685. title L2JDP Installer - Game Server DataBase Setup - Full Install
  686. echo.
  687. echo Deleting all Game Server tables for new content...
  688. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< gs_cleanup.sql 2^> NUL
  689. %cmdline%
  690. if not %ERRORLEVEL% == 0 goto omfg
  691. set full=1
  692. echo.
  693. echo Game Server tables has been deleted.
  694. goto gs_install
  695. :gs_upgrade
  696. echo.
  697. echo Upgrading structure of Game Server tables.
  698. echo.
  699. echo @echo off> temp.bat
  700. if exist gs_errors.txt del gs_errors.txt
  701. for %%i in (..\sql\game\updates\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% --force ^< %%i 2^>^> gs_errors.txt >> temp.bat
  702. call temp.bat> nul
  703. del temp.bat
  704. move gs_errors.txt %workdir%
  705. goto gs_install
  706. :gs_install
  707. set stage=9
  708. set cmdline=
  709. if %full% == 1 (
  710. title L2JDP Installer - Game Server DataBase Setup - Installing...
  711. echo.
  712. echo Installing new Game Server content.
  713. echo.
  714. ) else (
  715. title L2JDP Installer - Game Server DataBase Setup - Upgrading...
  716. echo.
  717. echo Upgrading Game Server content.
  718. echo.
  719. )
  720. if %logging% == 0 set output=NUL
  721. set dest=gs
  722. for %%i in (..\sql\game\*.sql) do call :dump %%i
  723. echo done...
  724. echo.
  725. goto custom_ask
  726. :dump
  727. set cmdline=
  728. if /i %full% == 1 (set action=Installing) else (set action=Upgrading)
  729. echo %action% %1>>"%output%"
  730. echo %action% %~nx1
  731. if "%dest%"=="ls" set cmdline="%mysqlPath%" -h %lshost% -u %lsuser% --password=%lspass% -D %lsdb% ^< %1 2^>^>"%output%"
  732. if "%dest%"=="cb" set cmdline="%mysqlPath%" -h %cbhost% -u %cbuser% --password=%cbpass% -D %cbdb% ^< %1 2^>^>"%output%"
  733. if "%dest%"=="gs" set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %1 2^>^>"%output%"
  734. %cmdline%
  735. if %logging%==0 if NOT %ERRORLEVEL%==0 call :omfg2 %1
  736. goto :eof
  737. :omfg2
  738. cls
  739. call :colors 47
  740. title L2JDP Installer - Potential DataBase Issue at stage %stage%
  741. echo.
  742. echo Something caused an error while executing instruction :
  743. echo %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb%
  744. echo.
  745. echo with file %~nx1
  746. echo.
  747. echo What we should do now?
  748. echo.
  749. :askomfg2
  750. set ntpebcak=c
  751. echo (l) Log it: I will create a log for this file, then continue
  752. echo with the rest of the list in non-logging mode.
  753. echo.
  754. echo (c) Continue: Let's pretend that nothing happened and continue with
  755. echo the rest of the list.
  756. echo.
  757. echo (r) Reconfigure: Perhaps these errors were caused by a typo.
  758. echo you can restart from scratch and redefine paths, databases
  759. echo and user info again.
  760. echo.
  761. echo (q) Quit now
  762. echo.
  763. set /p ntpebcak= Choose (default continue):
  764. if /i %ntpebcak%==c (call :colors 17 & goto :eof)
  765. if /i %ntpebcak%==l (call :logginon %1 & goto :eof)
  766. if /i %ntpebcak%==r (call :configure & exit)
  767. if /i %ntpebcak%==q (call :horrible_end & exit)
  768. goto askomfg2
  769. :logginon
  770. cls
  771. call :colors 17
  772. title L2JDP Installer - Game Server DataBase Setup - Logging Options turned on
  773. set logging=1
  774. if %full% == 1 (
  775. set output=%logdir%\install-%~nx1.log
  776. ) else (
  777. set output=%logdir%\upgrade-%~nx1.log
  778. )
  779. echo.
  780. echo Per your request, i'll create a log file for your reading pleasure.
  781. echo.
  782. echo I'll call it %output%
  783. echo.
  784. echo If you already have such a file and would like to keep a copy.
  785. echo go now and read it or back it up, because it's not going to be rotated
  786. echo or anything, instead i'll just overwrite it.
  787. echo.
  788. pause
  789. set cmdline="%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^<..\sql\%1 2^>^>"%output%"
  790. date /t >"%output%"
  791. time /t >>"%output%"
  792. %cmdline%
  793. echo Log file created, resuming normal operations...
  794. call :colors 17
  795. set logging=0
  796. set output=NUL
  797. goto :eof
  798. :custom_ask
  799. title L2JDP Installer - Custom Server Tables
  800. cls
  801. set cstprompt=n
  802. echo.
  803. echo L2J provides some "Custom Server Tables" for non-retail modifications
  804. echo in order to avoid override the original Server Tables.
  805. echo.
  806. set /p cstprompt=Install Custom Server Tables: (y) yes or (n) no (default no):
  807. if /i %cstprompt%==y goto custom_install
  808. if /i %cstprompt%==n goto mod_ask
  809. :custom_install
  810. cls
  811. echo.
  812. echo Installing Custom content.
  813. echo @echo off> temp.bat
  814. if exist custom_errors.txt del custom_errors.txt
  815. for %%i in (..\sql\game\custom\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %%i 2^>^> custom_errors.txt >> temp.bat
  816. call temp.bat> nul
  817. del temp.bat
  818. move custom_errors.txt %workdir%
  819. title L2JDP Installer - Custom Server Tables Process Complete
  820. cls
  821. echo Database structure for L2J Custom finished.
  822. echo.
  823. echo Remember that in order to get these additions actually working
  824. echo you need to edit your configuration files.
  825. echo.
  826. pause
  827. goto mod_ask
  828. :mod_ask
  829. title L2JDP Installer - Mod Server Tables
  830. cls
  831. set cstprompt=n
  832. echo.
  833. echo L2J provides a basic infraestructure for some non-retail features
  834. echo (aka L2J mods) to get enabled with a minimum of changes.
  835. echo.
  836. echo Some of these mods would require extra tables in order to work
  837. echo and those tables could be created now if you wanted to.
  838. echo.
  839. set /p cstprompt=Install Mod Server Tables: (y) yes or (n) no (default no):
  840. if /i %cstprompt%==y goto mod_install
  841. if /i %cstprompt%==n goto end
  842. :mod_install
  843. cls
  844. echo.
  845. echo Installing Mods content.
  846. echo @echo off> temp.bat
  847. if exist mods_errors.txt del mods_errors.txt
  848. for %%i in (..\sql\game\mods\*.sql) do echo "%mysqlPath%" -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% ^< %%i 2^>^> mods_errors.txt >> temp.bat
  849. call temp.bat> nul
  850. del temp.bat
  851. move mods_errors.txt %workdir%
  852. title L2JDP Installer - Mod Server Tables Process Complete
  853. cls
  854. echo Database structure for L2J Mods finished.
  855. echo.
  856. echo Remember that in order to get these additions actually working
  857. echo you need to edit your configuration files.
  858. echo.
  859. pause
  860. goto end
  861. :binaryfind
  862. if EXIST "%mysqlBinPath%" (echo Found) else (echo Not Found)
  863. goto :eof
  864. :horrible_end
  865. call :colors 47
  866. title L2JDP Installer - Oops!
  867. cls
  868. echo This wasn't a clean run, but don't worry.
  869. echo You can get help and support:
  870. echo.
  871. echo 1-Read the L2J Datapack project wiki :
  872. echo (http://www.l2jdp.com/trac/wiki)
  873. echo 2-Search for a similar problem in our forums
  874. echo (http://www.l2jdp.com/forum)
  875. echo.
  876. echo You can ask for support in our forums or irc channel:
  877. echo irc://irc.freenode.net channel: #l2j
  878. echo.
  879. echo I'll try to gather some versioning information that you
  880. echo may find useful when asking for support :
  881. echo.
  882. echo Datapack revision reported by 'SVN version':
  883. svnversion -n 2>NUL
  884. echo.
  885. if %ERRORLEVEL% == 9009 (
  886. echo SVN commandline tools not found!
  887. echo Please download and install "Windows installer with
  888. echo the basic win32 binaries" (or something that fits our
  889. echo binaries needs) from :
  890. echo http://goo.gl/c0uyh
  891. echo.
  892. )
  893. set dpvf="..\config\l2jdp-version.properties"
  894. echo Datapack revision reported by properties file :
  895. if NOT EXIST %dpvf% (
  896. echo Your %dpvf% file is missing!
  897. echo Use eclipse/ant to build one from your DP SVN copy.
  898. echo With it we'll be able to help you better.
  899. ) else (
  900. type %dpvf% | find "version" 2> NUL
  901. if not %ERRORLEVEL% == 0 (
  902. echo An error occured while trying to read
  903. echo your %dpvf% file!
  904. echo Make sure you keep it up to date
  905. echo and in the correct place.
  906. echo %ERRORLEVEL%
  907. ))
  908. echo.
  909. rem del %config_file%
  910. pause
  911. goto end
  912. :end
  913. call :colors 17
  914. title L2JDP Installer - Script Execution Finished
  915. cls
  916. echo.
  917. echo L2JDP Database Installer 2011
  918. echo.
  919. echo (C) 2007-2011 L2J DataPack Team
  920. echo Database Installer comes with ABSOLUTELY NO WARRANTY;
  921. echo This is free software, and you are welcome to redistribute it
  922. echo under certain conditions; See the file gpl.txt for further
  923. echo details.
  924. echo.
  925. echo Thanks for using our software.
  926. echo visit http://www.l2jdp.com for more info about
  927. echo the L2J DataPack Project.
  928. echo.
  929. pause
  930. color