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 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.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.