Skip to content

Commit

Permalink
Updated development scripts to restore single-player Linux functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ipkpjersi authored and Hubcapp committed Sep 13, 2023
1 parent ea31939 commit 833e14e
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo ""
cd server

# runs server with the configuration found in "server/default.conf"
bash ./ant_launcher.sh default
bash ./ant_launcher.sh default g1gc

# uncomment to run additional servers with different configurations. Prod use: uncomment all below
#bash ./ant_launcher.sh openrsc && \
Expand Down
150 changes: 149 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include .env

#########################################
##### Production Scripts #####
#########################################
# Creates a database export of the specified database and saves to the output directory specified in the .env file. Good for utilizing as a crontab.
# Call via "make backup-mariadb db=cabbage"
backup-mariadb:
Expand All @@ -9,3 +11,149 @@ backup-mariadb:
mkdir -p $(MYSQL_DUMPS_DIR)/`date "+%Y%m"`
chmod -R 777 $(MYSQL_DUMPS_DIR)/`date "+%Y%m"`
mysqldump -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} --single-transaction --quick --lock-tables=false | gzip > $(MYSQL_DUMPS_DIR)/`date "+%Y%m"`/`date "+%Y%m%d-%H%M-%Z"`-${db}.sql.gz

#########################################
##### End of Production Scripts #####
#########################################
#########################################
##### Development Scripts #####
#########################################
start-linux:
`pwd`/Start-Linux.sh

run-server:
`pwd`/Deployment_Scripts/run.sh

run-client:
ant -f Client_Base/build.xml runclient

combined-install:
`pwd`/Deployment_Scripts/combined-install.sh

get-updates:
`pwd`/Deployment_Scripts/get-updates.sh

compile:
`pwd`/Deployment_Scripts/get-updates.sh

# Sets a specified username to be in a specified group in a specified database
# Call via "make rank-mariadb db=cabbage group=0 username=wolf"
rank-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${group}" ] || ( echo ">> group is not set"; exit 1 )
@[ "${username}" ] || ( echo ">> username is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} -e "USE ${db}; UPDATE players SET group_id = '${group}' WHERE players.username = '${username}';"

# Sets a specified username to be in a specified group in a specified database
# Call via "make rank-sqlite db=cabbage group=0 username=wolf"
rank-sqlite:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${group}" ] || ( echo ">> group is not set"; exit 1 )
@[ "${username}" ] || ( echo ">> username is not set"; exit 1 )
sqlite3 server/inc/sqlite/${db}.db "UPDATE players SET group_id = '${group}' WHERE players.username = '${username}';" ".exit"

# Changes a specified username to be a new username in a specified database
# Call via "make namechange-mariadb db=cabbage oldname=wolf newname=wolf2"
namechange-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${oldname}" ] || ( echo ">> oldname is not set"; exit 1 )
@[ "${newname}" ] || ( echo ">> newname is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} -e "USE ${db}; UPDATE players SET username = '${newname}' WHERE players.username = '${oldname}';"

# Changes a specified username to be a new username in a specified database
# Call via "make namechange-sqlite db=cabbage oldname=wolf newname=wolf2"
namechange-sqlite:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${oldname}" ] || ( echo ">> oldname is not set"; exit 1 )
@[ "${newname}" ] || ( echo ">> newname is not set"; exit 1 )
sqlite3 server/inc/sqlite/${db}.db "UPDATE players SET username = '${newname}' WHERE players.username = '${oldname}';" ".exit"

# Creates a database that the user specifies the name of
# Call via "make create-mariadb db=cabbage"
create-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} -e "create database ${db};"

# Imports the core.sql file to a specified database
# Call via "make import-authentic-mariadb db=preservation"
import-authentic-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/core.sql

# Imports the core.sqlite file to a specified database
# Call via "make import-authentic-sqlite db=preservation"
import-authentic-sqlite:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
cat server/database/sqlite/core.sqlite | sqlite3 server/inc/sqlite/${db}.db

# Imports the addon sql files to a specified database
# Call via "make import-custom-mariadb db=cabbage"
import-custom-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/core.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_auctionhouse.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_bank_presets.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_clans.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_equipment_tab.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_harvesting.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_npc_kill_counting.sql
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/addons/add_runecraft.sql

# Imports the addon sqlite files to a specified database
# Call via "make import-custom-sqlite db=cabbage"
import-custom-sqlite:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
cat server/database/sqlite/core.sqlite | sqlite3 server/inc/sqlite/${db}.db
cat server/database/sqlite/addons/add_auctionhouse.sqlite | sqlite3 server/inc/sqlite/${db}.db
cat server/database/sqlite/addons/add_bank_presets.sqlite | sqlite3 server/inc/sqlite/${db}.db
cat server/database/sqlite/addons/add_clans.sqlite | sqlite3 server/inc/sqlite/${db}.db
cat server/database/sqlite/addons/add_equipment_tab.sqlite | sqlite3 server/inc/sqlite/${db}.db
cat server/database/sqlite/addons/add_npc_kill_counting.sqlite | sqlite3 server/inc/sqlite/${db}.db

# Imports the retro.sql file to a specified database
# Call via "make import-retro-mariadb db=2001scape"
import-retro-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < server/database/mysql/retro.sql

# Imports the retro.sqlite file to a specified database
# Call via "make import-retro-sqlite db=2001scape"
import-retro-sqlite:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
rm server/inc/sqlite/${db}.db
cat server/database/sqlite/retro.sqlite | sqlite3 server/inc/sqlite/${db}.db

# Creates a database export of the specified database and saves to the output directory specified in the .env file. Good for utilizing as a crontab.
# Call via "make backup-mariadb-local db=cabbage"
backup-mariadb-local:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mkdir -p $(MYSQL_DUMPS_DIR)
chmod -R 777 $(MYSQL_DUMPS_DIR)
mysqldump -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} --single-transaction --quick --lock-tables=false | zip > $(MYSQL_DUMPS_DIR)/`date "+%Y%m%d-%H%M-%Z"`-${db}.zip

# Creates a database export of the specified database and saves to the output directory specified in the .env file. Good for utilizing as a crontab.
# Call via "make backup-sqlite-local db=cabbage"
backup-sqlite-local:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mkdir -p $(MYSQL_DUMPS_DIR)
chmod -R 777 $(MYSQL_DUMPS_DIR)
echo .dump | sqlite3 server/inc/sqlite/${db}.db | zip > $(MYSQL_DUMPS_DIR)/`date "+%Y%m%d-%H%M-%Z"`-${db}.zip

# Unzips a database backup zip file in the output directory specified in the .env file and then imports it into the specified database as a database restoration from backup method
# Call via "make restore-mariadb-local name=20191017-0226-EDT-cabbage.zip db=cabbage"
restore-mariadb-local:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
unzip -p $(MYSQL_DUMPS_DIR)/${name} | mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db}

# Unzips a database backup zip file in the output directory specified in the .env file and then imports it into the specified database as a database restoration from backup method
# Call via "make restore-mariadb-local name=20191017-0226-EDT-cabbage.zip db=cabbage"
restore-sqlite-local:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
rm server/inc/sqlite/${db}.db
echo .read | unzip -p $(MYSQL_DUMPS_DIR)/${name} | sqlite3 server/inc/sqlite/${db}.db

#########################################
##### End of Development Scripts #####
#########################################
8 changes: 4 additions & 4 deletions Start-Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ Choices:
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make backup-sqlite db=$db
make backup-sqlite-local db=$db
elif [ "$sql" == "2" ]; then
make backup-mariadb db=$db
make backup-mariadb-local db=$db
fi
clear
echo "Database $db backup complete."
Expand All @@ -179,9 +179,9 @@ Choices:
${RED}2${NC} - MariaDB (production game hosting)"
read -r sql
if [ "$sql" == "1" ]; then
make restore-sqlite name=$filename db=$db
make restore-sqlite-local name=$filename db=$db
elif [ "$sql" == "2" ]; then
make restore-mariadb name=$filename db=$db
make restore-mariadb-local name=$filename db=$db
fi
clear
echo "File $filename was restored to database $db."
Expand Down
15 changes: 14 additions & 1 deletion server/ant_launcher.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#!/bin/bash

# If we didn't specify a config name, give an error message.
# We could default to default.conf, but we may not want this.
if [[ -z $1 ]]; then
echo "You must specify a config name, like this: ant_launcher.sh default"
exit 1
fi

# Run the game server
echo "Running the game server with config named \"$1.conf\"."

command="ant runserver -DconfFile=$1"
# Default to ZGC for production use
command="ant runserverzgc -DconfFile=$1"
# Use Java 8 if we specify it, like from single player run_server.sh
if [[ -n $2 && $2 == "g1gc" ]]; then
command="ant runserver -DconfFile=$1"
fi

screen -dmS $1 $command
4 changes: 2 additions & 2 deletions server/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

<property name="confFile" value="default" />
<property name="coloredLogging" value="false" />
<target name="runserver">
<target name="runserverzgc">
<!-- java 17+ recommended for mature ZGC implementation -->
<echo message="Using JVM 17+ launch arguments"/>
<java classname="com.openrsc.server.Server" fork="true">
Expand All @@ -99,7 +99,7 @@
</java>
</target>

<target name="runserverg1gc">
<target name="runserver">
<!-- java 8 compatible jvm args. Add more heap if you can. -->
<echo message="Using JVM arguments for Java 8 minimum."/>
<echo message="Upgrade to Java 17 or later for better garbage collection."/>
Expand Down
Empty file modified server/compile_server.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion server/run_server.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ echo "Type 'screen -r' to access the game server screen."
echo "Use CTRL + A + D to detach the live server screen so it runs in the background."
echo ""
echo ""
screen -dmS name ./ant_launcher.sh
screen -dmS name ./ant_launcher.sh g1gc

0 comments on commit 833e14e

Please sign in to comment.