Info

Bandnudel is a Perl script to create statistics for Sauerbraten, an opensource first person shooter. Bandnudel expects two commandline arguments: the hostname or ip address of the Sauerbraten masterserver, and the filename of a local html page to save the statistics. For example:

./bandnudel.pl sauerbraten.org /var/www/html/bandnudel.html

It will then run in foreground and ask the masterserver (sauerbraten.org) for all connected gameservers. After all game servers have been queried for the current gamemode, the current map, for all players' state, and so on, this data is saved as a single html page (/var/www/html/bandnudel.html). After pausing for 10 seconds, bandnudel will start over again asking the masterserver, querying all gameservers, ...

Masterserver

A Sauerbraten masterserver is used to locate gameservers. If a gameserver wants to register with a masterserver, the masterserver connects to the gameserver to check whether it is running. In the sauerbraten client, if you click on "update server list from master server" (in the servers' browser menu), then your client will also query the masterserver to get a list of all gameservers. The default masterserver is sauerbraten.org. Running bandnudel against the sauerbraten.org masterserver is not a wise idea. Also the servers' browser is quite confusing in my eyes. The Sauerbraten package for Linux also contains sources for the masterserver (sauer_master). As it is not build by default, you have to gmake master in sauerbraten/src. sauer_master runs in foreground and logs to master.log in the current directory. If you start sauer_master with an argument, it will use this argument as prefix for the logfile. If the logfile can not be opened, it will log to stdout. To use your own masterserver, you have to start the Sauerbraten client with the -m option, followed directly by the hostname or ip address, e.g.:

sauerbraten -m192.168.0.17
or add this to your autoexec.cfg (under options in the GUI):
mastername 192.168.0.17
Additionally, you have to edit server-init.cfg:
updatemaster 1
mastername 192.168.0.17
Otherwise, the dedicated gameserver won't use your masterserver.

Installing a dedicated Sauerbraten gameserver and masterserver on FreeBSD

As all Sauerbraten servers (including Bandnudel ;-)) don't daemonize themselfs, we will use Daniel J. Bernstein's daemontools. For security reasons, we will run all servers as a unprivileged user. You should also install a webserver like Apache so that clients on your LAN can access Bandnudel's statistics.

Install Sauerbraten

  1. cd /usr/ports/games/sauerbraten
  2. make install
  3. Deselect "CLIENT - Build client", just select "DEDICATED - Build dedicated server" in the options menu
  4. cd work/sauerbraten/src
  5. gmake master
  6. cp sauer_master /usr/local/libexec/
  7. cd -
  8. make clean

Install daemontools

  1. cd /usr/ports/sysutils/daemontools
  2. make install clean
  3. Leave options for daemontools untouched
  4. echo svscan_enable=YES >>/etc/rc.conf
  5. echo svscan_logdir="/var/log/svscan" >>/etc/rc.conf
  6. mkdir -p /var/log/svscan /var/service

Install Bandnudel

  1. cd /usr/local/libexec
  2. fetch http://ogris.de/bandnudel/bandnudel.pl
  3. chmod 0755 bandnudel.pl

Setting up an unprivileged Sauerbraten user

  1. pw groupadd braten
  2. pw useradd sauer -g braten -c "Sauerbraten pseudo-user" -s /sbin/nologin -m
  3. rm -r /home/sauer/.[a-z]*

Setting up the Sauerbraten masterserver

  1. mkdir /home/sauer/master
  2. chown sauer:braten /home/sauer/master
  3. mkdir -p /var/service/sauermaster
  4. cat >/var/service/sauermaster/run
    #!/bin/sh
    
    cd /home/sauer/master && \
    exec setuidgid sauer /usr/local/libexec/sauer_master
    ^D
  5. chmod 0755 /var/service/sauermaster/run

Setting up the Sauerbraten gameserver

  1. mkdir /home/sauer/server1
  2. chown sauer:braten /home/sauer/server1
  3. mkdir -p /var/service/sauerserver1/log
  4. cat >/var/service/sauerserver1/run
    #!/bin/sh
    
    cd /home/sauer/server1 && \
    exec setuidgid sauer /usr/local/libexec/sauer_server
    ^D
  5. chmod 0755 /var/service/sauerserver1/run
  6. cat >/var/service/sauerserver1/log/run
    #!/bin/sh
    
    cd /home/sauer/server1 && \
    exec setuidgid sauer multilog t ./log
    ^D
  7. chmod 0755 /var/service/sauerserver1/log/run
  8. cat >/home/sauer/server1/server-init.cfg
    serverip 0.0.0.0
    serverport 28785
    maxclients 32
    serverbotlimit 8
    publicserver 1
    serverdesc "My precious Sauerserver"
    serverpass ""
    adminpass "secret"
    updatemaster 1
    servermotd "Welcome to my precious Sauerserver"
    mastername LAN- or public IP address of your server
    ^D

Setting up Bandnudel

  1. mkdir /var/service/bandnudel
  2. cat >/var/service/bandnudel/run
    #!/bin/sh
    
    cd /home/sauer && \
    exec setuidgid sauer /usr/local/libexec/bandnudel.pl LAN- or public IP address of your server \
    /usr/local/www/apache22/data/index.html
    ^D
  3. chmod 0755 /var/service/bandnudel/run

Starting svscan

  1. /usr/local/etc/rc.d/svscan.sh start
  2. Check /var/log/svscan/current for errors
  3. Check ps aux to see if sauer_server, sauer_master, bandnudel, and two multilog processes are running

Download

Bandnudel

Other stuff

Bandnudel, first try

Bandnudel started as a Sauerbraten masterserver that uses MySQL to store all currently connected gameservers. That was before I discovered that Sauerbraten comes with its own masterserver. Bandnudel was also able to start gameservers and parse their output to create statistics. That was before I decided to use daemontools and before I discovered that you can directly get statistics from the gameservers without patching the source code.