Setting up a dgamelaunch game server

Installing Games

Installing the original Rogue seems appropriate for this article. Roguelike Gallery hosts builds for many early Roguelikes. John "Elwin" Edwards, Roguelike Gallery's creator, has done an amazing job of keeping and updating these antique games' source code to ensure they can run on modern operating systems. Roguelike Gallery also provides precompiled binaries [5].

I keep a convenient copy of Elwin's Roguelike collection on a personal server. You may download it with the following command:

$ curl -LO gopher:// Roguelikes/

Compile Rogue v3 (the earliest version of Rogue that was widely available) with:

$ unzip
$ cd ElwinR-rl-74351bf23e5e/rogue3
$ autoreconf
$ ./configure --enable-savedir=/var/games/rogue3/save--enable-scorefile=/var/games/rogue3/rogue.scr --enable-logfile=/var/games/rogue3/rogue.log
$ make

The enable-savedir, enable-scorefile, and enable-logfile switches are necessary to compile a game for systemwide installation. Keep in mind that Rogue will live in a chroot and won't be able to modify the rest of the operating system: For the game, the chroot directory will be all there is to the operating system.

Create the appropriate directories in the chroot and move the binary file to its final destination:

# cd /var/dgl
# mkdir -p var/games/rogue3/save
# mkdir -p usr/games
# mkdir -p dgldir/inprogress-rogue3
# cp $user_home/ElwinR-rl-74351bf23e5e/rogue3/rogue3 usr/games/
# chown -R games:games var/games dgldir

You can install additional games using similar steps. Keep in mind that you also must copy the libraries required by those games inside the chroot folder.

Rogue requires the appropriate ncurses library to live within the chroot.

# cp /lib/x86_64-linux-gnu/ /var/dgl/lib/x86_64-linux-gnu/

Configuring dgamelaunch

The game launcher's main configuration file resides in /var/dgl/etc/dgamelaunch.conf. Listing 2 shows an example to get you started. You may find more example configuration files in dgamelaunch's source code tarball, with the meaning of the variables properly explained.

Listing 2


chroot_path = "/var/dgl"
dglroot = "/dgldir/"
banner = "/dgl-banner"
shed_uid = 5
shed_gid = 60
commands[register] = mkdir "%ruserdata/%n",
  mkdir "%ruserdata/%n/ttyrec",
  mkdir "%ruserdata/%n/ttyrec/rogue3"
commands[login] = mkdir "%ruserdata/%n",
  mkdir "%ruserdata/%n/ttyrec",
  mkdir "%ruserdata/%n/ttyrec/rogue3"
menu["mainmenu_anon"] {
  bannerfile = "/dgl_menu_main_anon.txt"
  commands["l"] = ask_login
  commands["r"] = ask_register
  commands["w"] = watch_menu
  commands["q"] = quit
menu["mainmenu_user"] {
  bannerfile = "/dgl_menu_main_user.txt"
  commands["c"] = chpasswd
  commands["e"] = chmail
  commands["w"] = watch_menu
  commands["3"] = play_game "RogueV3"
  commands["q"] = quit
menu["watchmenu_help"] {
  bannerfile = "/dgl_menu_watchmenu_help.txt"
  commands["qQ "] = return
  game_path = "/usr/games/rogue3"
  game_name = "Rogue V3 (3.6)"
  short_name = "RogueV3"
  game_args = "rogue3", "-n", "%n"
  inprogressdir = "%rinprogress-rogue3/"
  ttyrecdir = "%ruserdata/%n/ttyrec/rogue3/"
  commands = cp "/var/games/rogue3/save/%u-%n.r3sav" "/var/games/rogue3/save/%u-%n.r3sav.bak"

The shed_uid and shed_gid variables define the user ID and group ID that dgamelaunch will drop privileges to after chrooting. In the example shown in Listing 2, this would be equivalent to games:games in a default Debian install. commands[login] and commands[register] tell dgamelaunch which actions to perform when a player logs in or registers, respectively. In Listing 2, they build a directory tree when the user registers and rebuild it if the user logs in and the tree does not exist.

The DEFINE clause provides a configuration for loading Rogue, game_path defines the location of the rogue3 binary within the chroot, while commands backs up each player's saved files each time the game is launched. ttyrecdir sets the directory in which the game session is recorded, just in case you want to watch your games later.

The final step is to configure the menus the users will see when logged into the game server. The default configuration suffices for testing, with the exception of the menu located at /var/dgl/dgl_menu_main_user.txt. By default, the menu is NetHack-centric. Listing 3 provides you with an appropriate alternative.

Listing 3


## $VERSION - network console game launcher
## Copyright (c) 2000-2009 The Dgamelaunch Team
## See for more info
## Games on this server are recorded for in-progress viewing and playback!
Logged in as: $USERNAME
c) Change password                e) Change email address
w) Watch games in progress
3) Play Rogue V3
q) Quit

Making the Service Available

You can test whether dgamelaunch works by invoking the dgamelaunch command as any regular user:

$ /usr/bin/dgamelaunch

If everything works as intended, dgamelaunch will chroot into /var/dgl, and you'll be presented with a menu (Figure 2), from which you can create a user account for the game service, play games, and watch other players.

Figure 2: The dgamelaunch menu.

In order to make the game available over Telnet, you must install the appropriate Telnet daemon and configure it. Dgamelaunch's README file offers instructions to do this. Begin by installing an inetd daemon and a Telnet server:

# apt-get install openbsd-inetd telnetd

OpenBSD's inetd is a superserver that takes incoming connections and passes them to the appropriate server, in this case telnetd. In order to make this configuration work, edit /etc/inetd.conf and ensure the line shown in Listing 4 is its only content.

Listing 4


telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /var/dgl/dgamelaunch

This line instructs OpenBSD's inetd to call the Telnet daemon when a Telnet connection is received. In turn, the Telnet daemon is configured to use /var/dgl/dgamelaunch as a shell. Remember to reload the inetd daemon for the configuration to take effect:

# systemctl reload inetd

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Gaming

    Try your luck with Rocket League, Fear Equation, and Master of Orion.

  • FOSSPicks

    This month, Graham discovered the spontaneous knotting of an agitated string while trying to untangle the mess of wires behind his PC and quickly gave up.

  • FOSSPicks

    Calibre 3.0, WereSync 1.0b, COLMAP 3.1, Tor Browser 7.0, Dungeon Crawl Stone Soup 0.20, and much more!

  • Command Line – Jailkit

    Setting up chroot jails is no simple task. Jailkit can make this job a little easier by automating setup and configuration.

  • FOSSPicks

    This month Graham looks at Cardinal, Celestia 1.7.0, Friture, Wavetable, Helix Editor, Brogue CE, and more!

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More