Advertisement
Guest User

Untitled

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