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://gopher.operationalsecurity.es/9/Software/Early Roguelikes/ElwinR-rl-74351bf23e5e.zip
Compile Rogue v3 (the earliest version of Rogue that was widely available) with:
$ unzip ElwinR-rl-74351bf23e5e.zip $ 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/libncurses.so.6 /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
dgamelaunch.conf
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 } DEFINE { 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
dgl_menu_main_user.txt
## ## $VERSION - network console game launcher ## Copyright (c) 2000-2009 The Dgamelaunch Team ## See http://nethack.wikia.com/wiki/dgamelaunch 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.
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
inetd.conf
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
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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.
News
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.