Start script cleanup

This commit is contained in:
crop 2020-11-02 20:30:13 -08:00
parent c7d5b94045
commit a26291b1b1
2 changed files with 33 additions and 49 deletions

View file

@ -10,11 +10,9 @@ If you're a developer and you want to take over the Windows Singleplayer Edition
* 1: Download or clone this repository.
* 2: After you unpack the .zip (if you just downloaded it) or it finishes cloning (if you cloned it), open up the folder that it created.
* 3: In this folder there will be a **run-windows.cmd**, execute this to start everything up.
* 4: What you need to do *first* before you can run the game is initialize the database. You only have to do this once.
* 5: Once that's finished, you can safely run the game with option 1.
* 5: You can simply run the game with option 1.
* 6: When you're done, make sure to use the "exit" option in the menu to properly shut everything down.
# Getting Started: Linux
See https://github.com/2009scape/Singleplayer-Edition

View file

@ -1,37 +1,37 @@
@echo off
:# Thanks to the OpenRSC team who I adapted this script from, much love <3
:: Thanks to the OpenRSC team who I adapted this script from, much love <3
SET mariadbpath="%~dp0\database\bin\"
SET data="%~dp0\data\"
SET database="%~dp0\database\"
SET home=%~dp0
:<------------Begin Start------------>
REM Initial menu displayed to the user
:start
:: Initial menu displayed to the user
cls
if not exist %database%\data\ goto initDB
echo:
echo What would you like to do?
echo:
echo Choices:
echo 1. Run the game
echo 2. Initialize the database. (Only needs to be run once!)
echo 3. Reset the database.
echo 4. Grant a player admin rights.
echo 5. Exit.
SET /P action=Please enter a number choice from above:
echo 2. Reset the database.
echo 3. Grant a player admin rights.
echo 4. Exit.
SET /P action=Please enter a number choice from above:
echo:
if /i "%action%"=="1" goto run
if /i "%action%"=="2" goto initDB
if /i "%action%"=="3" goto reset
if /i "%action%"=="4" goto role
if /i "%action%"=="5" goto exit
if /i "%action%"=="2" goto reset
if /i "%action%"=="3" goto role
if /i "%action%"=="4" goto exit
echo Error! %action% is not a valid option. Press enter to try again.
echo:
SET /P action=""
goto start
:<------------End Start------------>
:<------------Begin Role----------->
:role
:: Grant player admin rights
taskkill /F /IM mysqld*
taskkill /F /IM java*
cls
@ -42,51 +42,40 @@ cls
SET /p username=Please enter the user to make an admin:
call %mariadbpath%mysql.exe -uroot -e "USE global; UPDATE `members` SET `rights` = '2' WHERE `members`.`username` = '%username%';"
PING localhost -n 3 >NUL
echo:
echo
echo %username% is now an Administrator!
call %mariadbpath%mysqladmin.exe -uroot shutdown
echo:
echo
pause
goto start
:<------------End Role------------->
:<------------Begin Exit------------>
:exit
REM Shuts down existing processes
:: Shuts down existing processes
taskkill /F /IM Java*
taskkill /F /IM mysqld*
exit
:<------------End Exit------------>
:<------------Begin Run------------>
:run
:: Launch Client and Server
cls
cd %database%
start /b "Database" %mariadbpath%mysqld.exe --console --skip-grant-tables --lc-messages-dir="%CD%\share\english" --datadir="%CD%\data"
PING localhost -n 6 >NUL
start /min "Database" %mariadbpath%mysqld.exe --console --skip-grant-tables --lc-messages-dir="%CD%\share\english" --datadir="%CD%\data"
cls
echo:
echo Starting 2009scape.
echo:
cd %home%
start /b "Management Server" java -Xms1024m -Xmx1024m -jar ms.jar
PING localhost -n 3 >NUL
echo "Starting server-------------------------"
start "Server - Press CTRL+C to close correctly" java -Xms1024m -Xmx1024m -cp server.jar core.Server %home%\worldprops\default.json
PING localhost -n 10 >NUL
echo "Starting client-------------------------"
start "" java -Xms1024m -Xmx1024m -jar client.jar
start /min "Management Server" java -Xms1024m -Xmx1024m -jar ms.jar
start /min "Server - CTRL+C to close" java -Xms1024m -Xmx1024m -cp server.jar core.Server %home%\worldprops\default.json
start /min "Client - CTRL+C to close" java -Xms1024m -Xmx1024m -jar client.jar
echo:
goto start
:<------------End Run------------>
:<------------Begin initDB------------>
:initDB
REM Shuts down existing processes
:: Setup mysql tables
taskkill /F /IM Java*
taskkill /F /IM mysqld*
cd %home%
@ -102,17 +91,14 @@ call %mariadbpath%mysql.exe -uroot global < "%data%\global.sql"
echo:
echo Databases initialized!
taskkill /F /IM mysqld*
echo:
pause
goto start
:<------------End initDB------------>
:<------------Begin Reset------------>
:reset
REM Shuts down existing processes
:: Confirmation menu for reset
taskkill /F /IM Java*
taskkill /F /IM mysqld*
REM Verifies the user wishes to clear existing player data
cls
echo:
echo Are you ABSOLUTELY SURE that you want to reset all game databases?
@ -122,15 +108,15 @@ echo:
SET /P confirmwipe=""
echo:
if /i "%confirmwipe%"=="yes" goto wipe
if /i "%confirmwipe%"=="no" goto start
echo Error! %confirmwipe% is not a valid option.
pause
goto start
REM Starts up the database server and imports both server and player database files to replace anything previously existing
:wipe
:: Delete database and re-init
cls
cd %database%
rm -fr data
mkdir data
goto initDB
:<------------End Reset------------>
goto initDB