database_installer.bat 26 KB

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