Advertisement
Guest User

Untitled

a guest
Dec 24th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. @Echo off
  2. cls
  3. echo #=============================================================================#
  4. echo Welcome to Database Installation.
  5. echo This script will help you to install a database server.
  6. echo To continue press SpaceBar, or Ctrl+C to Exit.
  7. echo #=============================================================================#
  8. pause > nul
  9. echo Checking System Environment
  10. mysql --help >nul 2>nul
  11. if errorlevel 1 goto nomysql
  12. echo # - MySQL [OK]
  13. echo #=============================================================================#
  14. echo Database is ready to Install.
  15. echo Please, initialize the configuration's.
  16. echo #=============================================================================#
  17. set DO_INSTALL=Y
  18. echo -
  19. set /P DO_INSTALL=# Install login server [Y/n] ?
  20. echo -
  21. if "%DO_INSTALL%"=="N" goto installgame
  22. if "%DO_INSTALL%"=="n" goto installgame
  23. set INSTALL_MODE=login
  24. :prepare
  25. set DB_HOST=localhost
  26. set DB_USER=root
  27. set DB_PASSWORD=
  28. set DB_NAME=dream
  29. :step2
  30.  
  31. set /P DB_HOST=# Databe Host [%DB_HOST%]:
  32.  
  33. set /P DB_USER=# Databse User [%DB_USER%]:
  34.  
  35. set /P DB_PASSWORD=# Database Password %DB_USER%:
  36.  
  37. set /P DB_NAME=# Database Name [%DB_NAME%]:
  38. SET MYSQL_PARAM=-u %DB_USER% -h %DB_HOST%
  39. if NOT "%DB_PASSWORD%"=="" SET MYSQL_PARAM=%MYSQL_PARAM% --password=%DB_PASSWORD%
  40. echo exit | mysql %MYSQL_PARAM% >nul 2>nul
  41. if errorlevel 1 goto dberror
  42. echo exit | mysql %MYSQL_PARAM% %DB_NAME% >nul 2>nul
  43. if errorlevel 1 goto dbnotexists
  44. goto install
  45. :dbnotexists
  46. echo #=============================================================================#
  47. echo -
  48. echo ! Database [%DB_NAME%] does not exist.
  49. echo -
  50. echo #=============================================================================#
  51. set ANSWER=Y
  52. echo -
  53. set /P ANSWER=# Do you want create it [Y/n] ?
  54. echo -
  55. if "%ANSWER%"=="y" goto createdb
  56. if "%ANSWER%"=="Y" goto createdb
  57. goto step2
  58. :createdb
  59. echo create database %DB_NAME% charset=utf8; | mysql %MYSQL_PARAM%
  60. echo # Creating Database [%DB_NAME%] [OK]
  61. echo -
  62. if errorlevel 1 goto dberror
  63. goto install
  64. :dberror
  65. echo #=============================================================================#
  66. echo ! Can't connect to database, checks if the settings are correct.
  67. goto step2
  68.  
  69. :install
  70. echo #=============================================================================#
  71. echo # Verify if the Settings are correct.
  72. echo # - The server will be installed on:
  73. echo # - Database Host [%DB_HOST%[
  74. echo # - Database Name [%DB_NAME%]
  75. set ANSWER=Y
  76. echo -
  77. set /P ANSWER=# All settings are correct [Y/n] ?
  78. echo -
  79. if "%ANSWER%"=="n" goto step1
  80. if "%ANSWER%"=="N" goto step1
  81. echo # - Installing Database, please wait.
  82. echo -
  83. for %%i in (%INSTALL_MODE%\*.sql) do mysql %MYSQL_PARAM% %DB_NAME% < %%i
  84. if "%INSTALL_MODE%"=="login" goto installgame
  85. goto end
  86. :installgame
  87. set DO_INSTALL=Y
  88. echo -
  89. set /P DO_INSTALL=# Install game server [Y/n] ?
  90. echo -
  91. if "%DO_INSTALL%"=="N" goto end
  92. if "%DO_INSTALL%"=="n" goto end
  93. set INSTALL_MODE=server
  94. goto prepare
  95. :nomysql
  96. echo #=============================================================================#
  97. echo ! MySQL Unavailable
  98. echo Make sure that the mysql.exe is in the PATH environment variable
  99. echo or in the current directory with the script installation
  100. echo #=============================================================================#
  101. goto end
  102. :end
  103. echo #=============================================================================#
  104. echo Installation completed, thank you for choosing our product
  105. echo For Complete Installation type Ctrl+C.
  106. echo #=============================================================================#
  107. pause > nul
  108. del %TMP%\java.ver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement