# User:Paxed/HowTo setup dgamelaunch
Note: This applies to NetHack 3.4.3 and the git-version of dgamelaunch, on linux. These instructions should be complete, but I haven't tested it lately.

Contents

1 Setup

1.1 Compile NetHack
1.2 Compile dgamelaunch
1.3 Testing the setup

Setup
To set up a public NetHack server using dgamelaunch git version:

Compile NetHack
Make sure you can compile NetHack (the Linux TTY version).
Edit src/cmd.c and change function enter_explore_mode() so users cannot do that.
Edit src/topten.c:
Change NAMSZ if you want to use longer usernames.
Change ENTRYMAX if you want the highscore list have more entries.
Comment out #define PERS_IS_UID, so that NetHack distinguishes users by their name, not by their UID.
If you want watchers to be able to send mail scrolls, get dgamelaunch sources and apply the nh343-simple_mail.diff patch that comes with it.
Edit include/config.h and change HACKDIR to "/nh343" (Note that there are more than one definition of HACKDIR in there!)
Edit include/unixconf.h and change VAR_PLAYGROUND to "/nh343/var"
Edit top Makefile by commenting all lines that reference $SHELLDIR (We don't need to install the shellscript that is usually used to launch NetHack)
Edit top Makefile by changing PREFIX to the directory which will be the chroot environment and contain all the files the server needs. We'll be using "/opt/nethack/nethack.alt.org" here as an example.
Edit top Makefile by changing GAMEDIR to $(PREFIX)/nh343 (This must match HACKDIR in include/config.h)
Edit top Makefile by changing VARDIR to $(GAMEDIR)/var (This must match VAR_PLAYGROUND in include/unixconf.h)
Edit top Makefile by changing GAMEUID and GAMEGRP to the user and group you will run nethack as; by default these are games and games in dgl settings.
Create the binaries with "make all". If things went smoothly, do "make install" (or "make update" if you've already installed NetHack once to the chroot dir)
Continue on to dgamelaunch compiling.
Compile dgamelaunch
You need:
git to get the dgamelaunch sources
autoconf -packages
SQLite development libraries
bison (or yacc or byacc) (You should already have this if you compiled NetHack)
flex (or lex) (You should already have this if you compiled NetHack)
ncurses and ncurses development libraries (You should already have these if you compiled NetHack)
get the newest version of dgamelaunch:
git clone https://github.com/paxed/dgamelaunch.git

Prepare for compilation:
cd dgamelaunch
./autogen.sh --enable-sqlite --enable-shmem --with-config-file=/opt/nethack/nethack.alt.org/etc/dgamelaunch.conf

Make dgamelaunch with "make"
Edit dgl-create-chroot and change the default settings to match your chroot location and so on, then execute dgl-create-chroot. It should copy all the necessary files and put them into the chroot environment.
Test that you can run dgamelaunch (as root):
cd /opt/nethack/nethack.alt.org
./dgamelaunch

Edit /opt/nethack/nethack.alt.org/etc/dgamelaunch.conf to suit your needs:
'max_nick_len' should be kept at 10, unless you changed NAMSZ in NetHack's src/topten.c.
'chroot_path' should be whatever you used as the chroot location in dgl-create-chroot.
Testing the setup
Test that you can run the nethack inside the chroot environment, by doing the following as root:
cd /opt/nethack/nethack.alt.org
chroot ./ nh343/nethack

If NetHack doesn't start but you get a complaint about missing file or directory:
chroot: cannot run command `nh343/nethack': No such file or directory

That usually means some dynamic library isn't present in the chroot. Use "ldd nethack" to see what dynamic link libraries are needed.

If you get a complaint about unknown terminal type, that means there's some problem with the terminfo files. Check that there is a terminfo file in the chroot that corresponds to your $TERM setting.
Set up the telnetd to accept incoming connections, for example if you're using xinetd, you might put this in /etc/xinetd.d/dgl:
service telnet
{
       socket_type     = stream
       protocol        = tcp
       user            = root
       wait            = no
       server          = /usr/sbin/in.telnetd
       server_args     = -L /opt/nethack/nethack.alt.org/dgamelaunch
       rlimit_cpu      = 120
}

Or if you're using inetd, add the following line to /etc/inetd.conf:

telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /opt/nethack/nethack.alt.org/dgamelaunch