How to setup a local QuakeJS server under Debian 9 or Debian 10
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).
If you want to setup a server under Windows 10 instead visit my guide on How to setup a local QuakeJS server under Windows 10.
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. Luckily Inolen provided the precompile .js files for those of us just wanting to run a server. Between those .js files, the QuakeJS README, some helpful discussion on how to setup a local webpage to connect to the server (as well as providing the content necessary to play) and a bit of tinkering, I've been successful in creating a server environment that I'm happy with.
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
- Setup Debian to launch our server on boot
- Frag
Below I'm going to break it down step by step
If Docker is more your thing then check out Trey Yoder's Dockerized Local QuakeJS Server on GitHub.
Checkout digidigital's "one step" QuakeJS Installer for Linux on GitHub.
NOTE: There are 2 version of this guide below. "The Simpler Method" uses my forked QuakeJS repo which includes all of the necessary file modifications already done. "The Original Method" shows how to get eveything setup starting with Inolen's original QuakeJS repo
NOTE: This guide assumes your local server's hostname is "quakejs"
NOTE: currently the content server address of content.quakejs.com is hard coded into some compiled code. I'm working on being able to recompile but in the meantime there is a "hack" to redirect content.quakejs.com to your localhost address. See the "Redirect content.quakejs.com" section
The Simpler Method
The instructions below show you have to setup a Local QuakeJS server using my updated forked repo. This will save you time because I've already created and modified all the files you'd need to if using Inolen's original repo. If you'd prefer to work from Inolen's original repo and make all of the file modifications yourself jump to #The Original Method
Prepare your Machine
- Make sure our system is up to date before we start by running
sudo apt update sudo 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
DEBIAN 9: sudo apt install git nodejs
orDEBIAN 10: sudo apt install git nodejs npm
- Make sure we're in our home directory by running
cd ~
- Clone my updated QuakeJS git repository (along with the ioq3 repository sub-module) by running
git clone --recurse-submodules https://github.com/begleysm/quakejs.git
- Move into the newly created quakejs directory by running
cd quakejs
- Install the necessary node.js packages by running
npm install
You'll see some warnings about deprecated packages and vulnerabilities. You'll have to just accept it and move on. QuakeJS is from 2013/2014. - 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
- Edit the baseq3 server config file by running the following command
nano base/baseq3/server.cfg
Pay special attention to seta sv_hostname, seta g_motd, and especially seta rconpassword - Optionally edit the cpma server config file by running the following command
nano base/cpma/server.cfg
Pay special attention to seta sv_hostname, seta g_motd, and especially seta rconpassword - You can test (or run) your server with the following command, but there 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
Note that the final line with say something like "Hitch warning: 5584 msec frame time". This is normal.
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/
- Delete the default index.html that comes with Apache2 by running
sudo rm /var/www/html/index.html
- Copy the Local Content Server and Play Page files from the quakejs folder to /var/www/html by running
sudo cp /home/quake/quakejs/html/* /var/www/html/
- Run the get_assets.sh 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 they aren't named quite right and we'll download everything from the "official" content server in one go to simplify things).
sudo bash /var/www/html/get_assets.sh
This will put all of the asset files where they need to go in /var/www/html/assets.
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
- If you didn't already do it, delete the default index.html that comes with Apache2 by running
sudo rm /var/www/html/index.html
- If you didn't already do it, copy the Local Content Server and Play Page files from the quakejs folder to /var/www/html by running
sudo cp /home/quake/quakejs/html/* /var/www/html/
Redirect content.quakejs.com
Currently the content server address (content.quakejs.com) is hard coded into the compile ioq3 code. Because QuakeJS is so old, the version of Empscripten used to compile it is no longer available. I'm working on figuring out how to recompile the program. In the meantime, the easiest hack (and it is a hack) I've found to be able to run a local QuakeJS server, without an internet connection, is to edit your hosts file to redirect content.quakejs.com to your localhost. The below instructions will explain how to do this.
- Edit your hosts file by running the following
sudo nano /etc/hosts
- Add the following line to the bottom of the file
127.0.0.1 content.quakejs.com # quakejs local content server redirect
At this point you can visit http://quakejs/ and it will download a couple files to your browser from your local content server and connect to your server (if it is running, which it isn't if you're following this guide).
Run the server manually by runningcd /home/quake/quakejs node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfgor finish off this guide to create a service that you can start with
sudo systemctl start quakejsand that will auto start on boot.
Finalize the Setup
- Configure Debian to autorun our server on boot
- Install daemonize (for use in our init.d script) by running
sudo apt install daemonize
- Copy the service script to where it goes by running
sudo cp /home/quake/quakejs/init.d/quakejs /etc/init.d/quakejs
- Enable it by running
sudo update-rc.d quakejs defaults
- You can test this by running
sudo systemctl start quakejs systemctl status quakejs
and then connecting to the server; and/or rebooting your machine by runningsudo reboot
and then runningsystemctl status quakejs
and then connecting to your server.
- Install daemonize (for use in our init.d script) by running
- Lastly we need to remove sudo privileges from user quake
- Get back to our original sudo user (not quake) by running the following command which undoes su - quake
exit
- Remove quake from the sudo group by running
sudo gpasswd -d quake sudo
- Get back to our original sudo user (not quake) by running the following command which undoes su - quake
That's it! Whenever your quakejs server boots up it will automatically start the quakejs game server and Apache2 webserver. When a computer on your LAN visits http://quakejs/ they'll automatically download the files they need from http://quakejs/assets/ and then connect to the QuakeJS server at quakejs:27960.
Get a few friends together, have them point their browsers to http://quakejs/ and start fragging!
The Original Method
The instructions below show you have to setup a Local QuakeJS server using Inolen's original QuakeJS repo. You'll have to make a few modifications to some files in order to get it running locally. If you'd like to download the project from my forked repo instead, with the modifications already having been done for you, then jump to #The Simpler Method.
Prepare your Machine
- Make sure our system is up to date before we start by running
sudo apt update sudo 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
DEBIAN 9: sudo apt install git nodejs
orDEBIAN 10: sudo apt install git nodejs npm
- 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
You'll see some warnings about deprecated packages and vulnerabilities. You'll have to just accept it and move on. QuakeJS is from 2013/2014. - 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 Server" 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
Make sure you change the password in seta rconpassword - 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 Server" 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 test (or run) your server with the following command, but there 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://steamforge.net/files/quakejs/get_assets.sh
- Make the script executable by running
sudo chmod +x /var/www/html/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 they aren't named quite right and we'll download everything from the "official" content server in one go to simplify things).
sudo bash /var/www/html/get_assets.sh
This will put all of the asset files where they need to go in /var/ww/html/assets. - Optionally remove get_assets.sh by running
sudo rm /var/www/html/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
- Download a copy of the favicons by running
sudo wget -O /var/www/html/quakejs_favicons.tar.gz http://steamforge.net/files/quakejs/quakejs_favicons.tar.gz
- Extract the favicons by running
sudo tar -xvzf /var/www/html/quakejs_favicons.tar.gz
- Remove the compressed file by running
sudo rm /var/www/html/quakejs_favicons.tar.gz
- 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'];
- Add the following between lines 6 and 7
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="manifest" href="/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff">
- Change Line 4 to say whatever you want, something like
Redirect content.quakejs.com
Currently the content server address (content.quakejs.com) is hard coded into the compiled ioq3 code. Because QuakeJS is so old, the version of Empscripten used to compile it is no longer available. I'm working on figuring out how to recompile the program. In the meantime, the easiest hack (and it is a hack) I've found to be able to run a local QuakeJS server, without an internet connection, is to edit your hosts file to redirect content.quakejs.com to your localhost. The below instructions will explain how to do this.
- Edit your hosts file by running the following
sudo nano /etc/hosts
- Add the following line to the bottom of the file
127.0.0.1 content.quakejs.com # quakejs local content server redirect
At this point you can visit http://quakejs/ and it will download a couple files to your browser from your local content server and connect to your server (if it is running, which it isn't if you're following this guide).
Run the server manually by runningcd /home/quake/quakejs node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfgor finish off this guide to create a service that you can start with
sudo systemctl start quakejsand that will auto start on boot.
Finalize the Setup
- Configure Debian to autorun our server on boot
- Install daemonize (for use in our init.d script) by running
sudo apt install daemonize
- Create a new service file by running
sudo nano /etc/init.d/quakejs
- Fill the file with the following
#!/bin/sh # ### BEGIN INIT INFO # Provides: quakejs # Required-Start: $network # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: QuakeJS Server Daemon ### END INIT INFO # # /etc/init.d/quakejs # Subsystem file for "quakejs" server # # chkconfig: 2345 95 05 # description: QuakeJS server daemon # # processname: quakejs # pidfile: /var/run/quakejs.pid RETVAL=0 prog="quakejs" start() { echo "Starting $prog:" daemonize -v -p /var/run/$prog.pid -c /home/quake/quakejs -u quake /usr/bin/node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/$prog echo } stop() { echo "Stopping $prog:" killproc $prog -TERM RETVAL=$? [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/$prog echo } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 3 start ;; condrestart) if [ -f /var/lock/subsys/$prog ] ; then stop # avoid race sleep 3 start fi ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL
- Make our new file executable by running
sudo chmod +x /etc/init.d/quakejs
- Enable it by running
sudo update-rc.d quakejs defaults
- You can test this by running
sudo systemctl start quakejs systemctl status quakejs
and then connecting to the server; and/or rebooting your machine by runningsudo reboot
and then runningsystemctl status quakejs
and then connecting to your server.#Lastly we need to remove sudo privileges from user quake - Get back to our original sudo user (not quake) by running the following command which undoes su - quake
exit
- Remove quake from the sudo group by running
sudo gpasswd -d quake sudo
- Install daemonize (for use in our init.d script) by running
That's it! Whenever your quakejs server boots up it will automatically start the quakejs game server and Apache2 webserver. When a computer on your LAN visits http://quakejs/ they'll automatically download the files they need from http://quakejs/assets/ and then connect to the QuakeJS server at quakejs:27960.
Get a few friends together, have them point their browsers to http://quakejs/ and start fragging!
Notes on Customization
Changing the Hostname
If you want to use a hostname other than "quakejs" you'll need to update the linevar args = ['+set', 'fs_cdn', 'quakejs:80', '+connect', 'quakejs:27960']; //custom args list targeting a local content server and local game server both at the address 'quakejs'in
/var/www/html/index.htmlto your new hostname (instead of quakejs).
Understanding Server Settings in server.cfg
Parameter | Description |
---|---|
seta sv_hostname "DM Server All Maps" | What players will see on the join server window |
seta sv_maxclients 16 | Maximum number of players on the server |
seta g_motd "Welcome to our Quake3 server" | Message players will see while joining the server |
seta g_quadfactor 3 | Quad Damage strength. 3 is normal |
seta g_gametype 0 | Sets the type of game: 0 - Free for all 1 - Tournament 2 - Free for all(again) 3 - Team Deathmatch 4 - Capture the Flag |
seta timelimit 15 | Sets the timelimit |
seta fraglimit 25 | |
seta g_weaponrespawn 3 | Number of seconds before weapons respawn |
seta g_inactivity 3000 | Number of seconds before an inactive player is kicked |
seta g_forcerespawn 0 | Forces players to respawn: 0 - off 1 - on |
seta rconpassword "password" | Sets the password to allow client control of the server |
set d1 "map q3dm1 ; set nextmap vstr d2" set d2 "map q3dm2 ; set nextmap vstr d3" set d3 "map q3dm3 ; set nextmap vstr d1" vstr d1 |
These last few lines of this example set up a simple map rotation |
Visit https://www.quake3world.com/q3guide/servers.html for details on these settings.
Using the Full Quake 3 Game
This guide (and Inolen's original project) targets the Demo version of Quake 3. If you'd like to try your hand at hosting a node.js version of the full Quake 3 game ronfar623 over at reddit figured out how to do it. You can read his instructions at the link below. Note that he starts by following my instructions above to set up a working Demo version so you'll need to do that first.
https://www.reddit.com/r/quake/comments/cpn4rp/how_to_setup_your_own_local_quakejs_server/ezr8m3c?utm_source=share&utm_medium=web2x
Adding your own Maps & Content
digidigital has written a guide and a couple tools to help add custom content. They have now been merged into the repo in a folder called cctools. The guide can be viewed directly at https://github.com/begleysm/quakejs/blob/master/cctools/README.md
Also this GitHub Issue might help https://github.com/inolen/quakejs/issues/19#issuecomment-570895962