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
Direct Download
Read full article as PDF:
Price $2.95
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
-
Armbian 23.05 is Now Available
Based on Debian 12, the latest version of the ARM/RISC-V distribution is now available to download and install.
-
Linux Mint Finally Receiving Support for Gestures
If you use the Linux Mint Cinnamon desktop, you'll be thrilled to know that 21.2 is getting support for gestures on touchscreen devices and touchpads.
-
An All-Snap Version of Ubuntu is In The Works
Along with the standard deb version of the open-source operating system, Canonical will release an-all snap version.
-
Mageia 9 Beta 2 Ready for Testing
The latest beta of the popular Mageia distribution now includes the latest kernel and plenty of updated applications.
-
KDE Plasma 6 Looks to Bring Basic HDR Support
The KWin piece of KDE Plasma now has HDR support and color management geared for the 6.0 release.
-
Bodhi Linux 7.0 Beta Ready for Testing
The latest iteration of the Bohdi Linux distribution is now available for those who want to experience what's in store and for testing purposes.
-
Changes Coming to Ubuntu PPA Usage
The way you manage Personal Package Archives will be changing with the release of Ubuntu 23.10.
-
AlmaLinux 9.2 Now Available for Download
AlmaLinux has been released and provides a free alternative to upstream Red Hat Enterprise Linux.
-
An Immutable Version of Fedora Is Under Consideration
For anyone who's a fan of using immutable versions of Linux, the Fedora team is currently considering adding a new spin called Fedora Onyx.
-
New Release of Br OS Includes ChatGPT Integration
Br OS 23.04 is now available and is geared specifically toward web content creation.