database_installer.bat 28 KB

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