Difference between revisions of "How to setup a local QuakeJS server under Debian 9 or Debian 10"
(→Finalize the Setup) |
|||
| Line 61: | Line 61: | ||
=Finalize the Setup= | =Finalize the Setup= | ||
| − | # | + | #Configure Debian to autorun our server on boot |
##Run <pre>sudo nano /etc/init.d/quakejs</pre> | ##Run <pre>sudo nano /etc/init.d/quakejs</pre> | ||
##Fill the file with the following <pre>### BEGIN INIT INFO # Provides: quakejs # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: QuakeJs Server # Description: Starts/Stops/Restarts the QuakeJS Server Daemon ### END INIT INFO set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="QuakeJS Server" NAME=quakejs-server USER=quake DIR=/home/quake/quakejs DAEMON=node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg #PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 sleep 2 sudo -u $USER $DAEMON $1 $OPTIONS | ##Fill the file with the following <pre>### BEGIN INIT INFO # Provides: quakejs # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: QuakeJs Server # Description: Starts/Stops/Restarts the QuakeJS Server Daemon ### END INIT INFO set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="QuakeJS Server" NAME=quakejs-server USER=quake DIR=/home/quake/quakejs DAEMON=node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg #PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 sleep 2 sudo -u $USER $DAEMON $1 $OPTIONS | ||
| + | ##Make our new file executable by running <pre>sudo chmod +x /etc/init.d/quakejs</pre> | ||
| + | ##Enable it by running <pre>sudo update-rc.d quakejs defauts</pre> | ||
Revision as of 22:19, 6 July 2019
TLDR: This how to will show you how to setup a local QuakeJS server, local Play page (for users to connect to the local server), and a local content server to provide files to the clients.
I found myself in a situation where I was going to be on a LAN without internet access for an extended period of time along with multiple people and multiple computers. I wanted a fun, fast paced, multiplayer game for us. The catch? I didn't want anyone to have to install anything since these computers didn't belong to us. That's a pretty tall order. What I found was QuakeJS. Quake 3 was open sourced at the beginning of 2012 and some awesome dudes based ioquake3 off of it. Another awesome dude created QuakeJS around 2013/2014. QuakeJS allows you to play Quake 3 entirely in a browser.
The source code has instructions for creating a dedicated server as well as building from source & generating assets for a content server. Unfortunately the Emscripten tool used to build the project has changed the way it operates in since 2014 and the current version of the QuakeJS source doesn't build with modern versions of Emscripten. I've found some work-arounds. Some helpful discussion on how to setup a local webpage to connect to the server (as well as providing the content necessary to play) can be found here.
The theory is pretty simple
- Follow Inolen's original instructions for setting up a QuakeJS server
- Download everything we might need from the content server http://content.quakejs.com and rehost it locally
- Download the source code (and referenced CSS & JS files) from http://www.quakejs.com/play, modify them for local use, and rehost them locally
- Frag
Below I'm going to break it down step by step
NOTE: This guide assumes your local server's hostname is "quakejs"
Contents
Prepare your Machine
- Make sure our system is up to date before we start by running
sudo apt update
andsudo apt upgrade
- Create a dedicated user to run our server with
sudo adduser quake
- Temporarily give quake sudo access to make setup easier (we'll remove it later) by running
sudo usermod -aG sudo quake
- Switch to our new quake user and start in his home directory by running
su - quake
Setup a Local QuakeJS Server
- Install curl by running
sudo apt install curl
- Add the repo for node.js by running
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
- Install the tools we need to setup our server by running
sudo apt install git build-essential nodejs
- Make sure we're in our home directory by running
cd ~
- Clone the original QuakeJS git repository (along with the ioq3 repository sub-module) by running
git clone --recurse-submodules https://github.com/inolen/quakejs.git
- Move into the newly created quakejs directory by running
cd quakejs
- Install the necessary node.js packages by running
npm install
- Fix the vulnerabilities that can be easily addressed by running
npm audit fix
- To download BASE3Q files, run the server for the 1st time by executing the following command. Hold down enter to get through the EULA, agree to the EULA by hitting y and game files will be downloaded. Once all files have been downloaded (you'll see the line ignoring setsockopt command) quit the server by hitting Ctrl+C
node build/ioq3ded.js +set fs_game baseq3 +set dedicated 1
- Optionally run the following command to download additional CPMA files. Again hit Ctrl+C to quit the server once all files have been downloaded (you'll see the line ignoring setsockopt command)
node build/ioq3ded.js +set fs_game cpma +set dedicated 1
- Create a baseq3 server config file by running the following command
nano base/baseq3/server.cfg
and fill in the body with the followingseta sv_hostname "quakejs" seta sv_maxclients 12 seta g_motd "Welcome to the Local baseq3 QuakeJS Server" seta g_quadfactor 3 seta g_gametype 0 seta timelimit 15 seta fraglimit 25 seta g_weaponrespawn 3 seta g_inactivity 3000 seta g_forcerespawn 0 seta rconpassword "quakejs" set d1 "map q3dm7 ; set nextmap vstr d2" set d2 "map q3dm17 ; set nextmap vstr d1" vstr d1
- Optionally create a cpma server config file by running the following command
nano base/cpma/server.cfg
and fill in the body with the followingseta sv_hostname "quakejs" seta sv_maxclients 12 seta g_motd "Welcome to the Local cpma QuakeJS Server" seta g_quadfactor 3 seta g_gametype 0 seta timelimit 15 seta fraglimit 25 seta g_weaponrespawn 3 seta g_inactivity 3000 seta g_forcerespawn 0 seta rconpassword "quakejs" set d1 "map q3dm7 ; set nextmap vstr d2" set d2 "map q3dm17 ; set nextmap vstr d1" vstr d1
Make sure you change the password in seta rconpassword
- You can run your server with the following command, but the isn't much point until we setup the Content Server and Play Page.
node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg
Setup a Local Content Server
- Setup a webserver to host our content and install jq to help with downloading assets by running
sudo apt install apache2 jq
- change directories to where our web files are hosted by running
cd /var/www/html/
- Download a script that I wrote to simplify getting the assets from http://content.quakejs.com by Running
sudo wget https://raw.githubusercontent.com/begleysm/quakejs/master/assets/get_assets.sh
- Make the script executable by running
sudo chmod +x get_assets.sh
- Run the script to grab all of the assets from http://content.quakejs.com and put them where they can be accessed by clients. (Technically you already downloaded a couple of the files earlier but we'll do everything in 1 go to simplify things).
sudo bash get_assets.sh
This will put all of the asset files where they need to go in /assets. - Optionally remove get_assets.sh by running
sudo rm get_assets.sh
Setup a Local Play Page
- If you didn't already install Apache2 for the content server, do it now by running
sudo apt install apache2
- Delete the default index.html that comes with Apache2 by running
sudo rm /var/www/html/index.html
- Download a copy of the Play Page from the QuakeJS website and put it where it can be accessed locally by running
sudo wget -O /var/www/html/index.html http://www.quakejs.com/play
- Download a copy of the CSS used to format the Play Page and it where it goes by running
sudo wget -O /var/www/html/game.css http://www.quakejs.com/css/ff3bfe05fa66a6c5418f2f02b0e55e36-game.css
- Download a copy of the JS and put it where it goes by running
sudo wget -O /var/www/html/ioquake3.js http://www.quakejs.com/js/38cbed8aa9a0bda4736d1aede69b4867-ioquake3.js
- Modify the Play Page you downloaded to make it suitable for running locally by running the following command and making the change specified below
sudo nano /var/www/html/index.html
- Change Line 4 to say whatever you want, something like
<title>QuakeJS Local</title>
- Change Line 5 to
<link rel="stylesheet" href="/game.css"></link>
- Change Line 6 to
<script type="text/javascript" src="/ioquake3.js"></script>
- Comment out Lines 7 through 16 to disable Google Analytics
- Change Line 7 to
<!-- <script type="text/javascript">
- Change Line 16 to
</script> -->
- Change Line 7 to
- Change Line 75 to
var args = ['+set', 'fs_cdn', 'quakejs:80', '+connect', 'quakejs:27960'];
- Change Line 4 to say whatever you want, something like
Finalize the Setup
- Configure Debian to autorun our server on boot
- Run
sudo nano /etc/init.d/quakejs
- Fill the file with the following
### BEGIN INIT INFO # Provides: quakejs # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: QuakeJs Server # Description: Starts/Stops/Restarts the QuakeJS Server Daemon ### END INIT INFO set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="QuakeJS Server" NAME=quakejs-server USER=quake DIR=/home/quake/quakejs DAEMON=node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg #PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 sleep 2 sudo -u $USER $DAEMON $1 $OPTIONS
- Run
- Enable it by running
sudo update-rc.d quakejs defauts
- Enable it by running