Quake II dedicated server for Debian
====================================

Game data
---------

The Quake II engine requires game data to run.  The data is not freely
redistributable.  You should use the 'game-data-packager' tool to install it.

For the full game, you will need at least baseq2/pak0.pak and
baseq2/videos/ from a Quake II installation or CD-ROM; everything
else can be downloaded by game-data-packager. See
/usr/share/games/game-data-packager/quake2.yaml for full details,
including the sizes and checksums of the required files.

Demo files are freely downloadable and can also be packaged using
game-data-packager.

Running one server instance
---------------------------

By default, quake2-server adds a user under which to run the dedicated server
(quake2-server) and sets it up to be run by an init script in the conventional
Debian way. This is a simple setup suitable for running one server on a
machine; by default it will run a deathmatch game.

The quake2-server user's home directory is /var/games/quake2-server, so you
can find Quake files in /var/games/quake2-server/.yq2 or similar.

The /etc/quake2-server directory is symlinked into the game engine's
search path as etc/quake2-server, so you can place files there and execute
them with commands like "exec etc/quake2-server/ctf.cfg".

In addition, debian_server.cfg in the engine's search path is also a symlink
to either /etc/quake2-server/debian_server.cfg or
/etc/quake2-server/demo/debian_server.cfg, depending whether you
are using the demo data or the full game. By default, the init script will
execute debian_server.cfg.

To set options that can only be configured via the command-line,
such as game and port, set the variable DAEMON_OPTS
in /etc/default/quake2-server.

The server can be managed in the usual way, e.g. via service(8)
and update-rc.d(8) commands like

    service quake2-server stop
    service quake2-server start
    update-rc.d quake2-server disable
    update-rc.d quake2-server enable

which should work for all of Debian's supported init systems.

Running multiple server instances with systemd
----------------------------------------------

Under systemd, quake2-server supports additional instances of the server,
so you can run a deathmatch server and a cooperative server,
or servers with different mods or mission packs, such as a Quake II server
and a Capture the Flag server.

Each instance quake2-server@INSTANCE.service has configuration and state in
/var/games/quake2-server/INSTANCE.home/.yq2 (or similar), and will execute
/etc/quake2-server/INSTANCE.cfg on startup.

To set a parameter that can only be given on the command line, such as
game or port, you can create /etc/default/quake2-server@INSTANCE
or a systemd "drop-in" file, and set DAEMON_OPTS there. Setting a
unique port for each server is recommended: if you do not, each
server will try ports above its configured port until it finds one
that is not in use, so the mapping between servers and ports will be arbitrary.

The instance name "debian_server" cannot be used without disabling and
stopping quake2-server.service, since it shares its configuration with that
service.

For instance, these shell commands (as root) would set up a cooperative
server on port 27920 and a Capture the Flag server on port 27930:

    cat > /etc/default/quake2-server@coop
    DAEMON_OPTS="+set port 27920"
    EOF
    cat > /etc/quake2-server/coop.cfg <<EOF
    set hostname "My Co-op Server"
    set coop 1
    set deathmatch 0
    set skill 2
    // no friendly fire if you use the same model as other players
    set dmflags 5520
    map base1
    EOF
    systemctl daemon-reload
    systemctl enable quake2-server@coop.service
    systemctl start quake2-server@coop.service

    cat > /etc/default/quake2-server@ctf
    DAEMON_OPTS="+set port 27930 +set game ctf"
    EOF
    cat > /etc/quake2-server/ctf.cfg <<EOF
    set hostname "My CTF Server"
    exec server.cfg
    EOF
    systemctl daemon-reload
    systemctl enable quake2-server@ctf.service
    systemctl start quake2-server@ctf.service
