Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- cls
- echo #=============================================================================#
- echo Welcome to Database Installation.
- echo This script will help you to install a database server.
- echo To continue press SpaceBar, or Ctrl+C to Exit.
- echo #=============================================================================#
- pause > nul
- echo Checking System Environment
- mysql --help >nul 2>nul
- if errorlevel 1 goto nomysql
- echo # - MySQL [OK]
- echo #=============================================================================#
- echo Database is ready to Install.
- echo Please, initialize the configuration's.
- echo #=============================================================================#
- set DO_INSTALL=Y
- echo -
- set /P DO_INSTALL=# Install login server [Y/n] ?
- echo -
- if "%DO_INSTALL%"=="N" goto installgame
- if "%DO_INSTALL%"=="n" goto installgame
- set INSTALL_MODE=login
- :prepare
- set DB_HOST=localhost
- set DB_USER=root
- set DB_PASSWORD=
- set DB_NAME=dream
- :step2
- set /P DB_HOST=# Databe Host [%DB_HOST%]:
- set /P DB_USER=# Databse User [%DB_USER%]:
- set /P DB_PASSWORD=# Database Password %DB_USER%:
- set /P DB_NAME=# Database Name [%DB_NAME%]:
- SET MYSQL_PARAM=-u %DB_USER% -h %DB_HOST%
- if NOT "%DB_PASSWORD%"=="" SET MYSQL_PARAM=%MYSQL_PARAM% --password=%DB_PASSWORD%
- echo exit | mysql %MYSQL_PARAM% >nul 2>nul
- if errorlevel 1 goto dberror
- echo exit | mysql %MYSQL_PARAM% %DB_NAME% >nul 2>nul
- if errorlevel 1 goto dbnotexists
- goto install
- :dbnotexists
- echo #=============================================================================#
- echo -
- echo ! Database [%DB_NAME%] does not exist.
- echo -
- echo #=============================================================================#
- set ANSWER=Y
- echo -
- set /P ANSWER=# Do you want create it [Y/n] ?
- echo -
- if "%ANSWER%"=="y" goto createdb
- if "%ANSWER%"=="Y" goto createdb
- goto step2
- :createdb
- echo create database %DB_NAME% charset=utf8; | mysql %MYSQL_PARAM%
- echo # Creating Database [%DB_NAME%] [OK]
- echo -
- if errorlevel 1 goto dberror
- goto install
- :dberror
- echo #=============================================================================#
- echo ! Can't connect to database, checks if the settings are correct.
- goto step2
- :install
- echo #=============================================================================#
- echo # Verify if the Settings are correct.
- echo # - The server will be installed on:
- echo # - Database Host [%DB_HOST%[
- echo # - Database Name [%DB_NAME%]
- set ANSWER=Y
- echo -
- set /P ANSWER=# All settings are correct [Y/n] ?
- echo -
- if "%ANSWER%"=="n" goto step1
- if "%ANSWER%"=="N" goto step1
- echo # - Installing Database, please wait.
- echo -
- for %%i in (%INSTALL_MODE%\*.sql) do mysql %MYSQL_PARAM% %DB_NAME% < %%i
- if "%INSTALL_MODE%"=="login" goto installgame
- goto end
- :installgame
- set DO_INSTALL=Y
- echo -
- set /P DO_INSTALL=# Install game server [Y/n] ?
- echo -
- if "%DO_INSTALL%"=="N" goto end
- if "%DO_INSTALL%"=="n" goto end
- set INSTALL_MODE=server
- goto prepare
- :nomysql
- echo #=============================================================================#
- echo ! MySQL Unavailable
- echo Make sure that the mysql.exe is in the PATH environment variable
- echo or in the current directory with the script installation
- echo #=============================================================================#
- goto end
- :end
- echo #=============================================================================#
- echo Installation completed, thank you for choosing our product
- echo For Complete Installation type Ctrl+C.
- echo #=============================================================================#
- pause > nul
- del %TMP%\java.ver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement