]> skyeroc.xyz Git - dgamelaunch/commitdiff
Add scripts and files peculiar to this repo
authorsbkelley <sb24kelley@gmail.com>
Mon, 1 Jun 2026 19:42:43 +0000 (15:42 -0400)
committersbkelley <sb24kelley@gmail.com>
Mon, 15 Jun 2026 21:35:16 +0000 (17:35 -0400)
 * install-dgl-nh500
 * dgl.patch
 * dgl.-nh500.patch
 * cpbin
 * findlibs
 * sanepath
 * README.md
 * README -> README.bak
 * dgl_menu_main_user.txt.orig
 * dgamelaunch.conf.orig

 Modifications to:
 * dgamelaunch.conf
 * dgl_menu_main_user.txt.orig

13 files changed:
README [deleted file]
README.bak [new file with mode: 0644]
README.md [new file with mode: 0644]
cpbin [new file with mode: 0644]
dgl-nh500.patch [new file with mode: 0644]
dgl.patch [new file with mode: 0644]
examples/dgamelaunch.conf
examples/dgamelaunch.conf.orig [new file with mode: 0644]
examples/dgl_menu_main_user.txt
examples/dgl_menu_main_user.txt.orig [new file with mode: 0644]
findlibs [new file with mode: 0644]
install-dgl-nh500 [new file with mode: 0755]
sanepath [new file with mode: 0644]

diff --git a/README b/README
deleted file mode 100644 (file)
index 241b804..0000000
--- a/README
+++ /dev/null
@@ -1,247 +0,0 @@
-dgamelaunch
-===========
-
-dgamelaunch is a network-based game shell where anyone can sign up for an
-account and start playing any game which suits your fancy - games known to
-work with dgamelaunch are for example NetHack (http://www.nethack.org) and
-Crawl (http://crawl.develz.org).
-
-
-DGAMELAUNCH VERSIONS
-====================
-
-Development version can be fetched from the source repository with git:
-
-  git clone git://github.com/paxed/dgamelaunch.git
-
-Releases are downloadable at http://alt.org/nethack/dgamelaunch/
-
-
-REQUIREMENTS
-============
-
-- normal development tools (make, etc)
-- autotools (autogen, autoconf, automake)
-- ncurses library and development files
-- bison (or yacc or byacc)
-- flex (or lex)
-- optionally sqlite3 library and development files
-
-
-COMPILING
-=========
-
-Basically all you have to do is:
-
-  ./autogen.sh && make
-
-Some options you might want give to autogen:
-
- --with-config-file=/absolute/path/to/dgamelaunch.config
- --enable-shmem
- --enable-sqlite
-
-
-Dgamelaunch should compile without issue on Linux, Solaris, FreeBSD 4 and 5.
-(Whether it _runs_ on all of these platforms is a different issue. We'd
-like to hear about it.)
-
-dgamelaunch was originally developed by M. Drew Streib <dtype@dtype.org> but
-is now a collaborative project. Copyright and contact information is in the
-COPYING file, included with this package.
-
-
-BASIC SETUP INSTRUCTIONS
-========================
-
-These instructions are not current. For a more up-to-date ones, see
-http://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch
-
-
-
-
-1) Setup a chroot jail. There is a helpful script included to accomplish this,
-called dgl-create-chroot, in the source directory. The default settings are
-viewable by editing the script; to customize the installation, look at
-dgl-create-chroot.conf.example.* (also in the source directory) and edit it to
-suit your needs, and save it into the same directory as dgl-create-chroot as
-dgl-create-chroot.conf. It's very likely you need to run the script as root.
-The script will not work with the very limited System V /bin/sh, such found on
-Solaris; start it with ksh instead.
-
-If you decide to not use dgl-create-chroot, you're on your own and we assume
-you have enough clue to figure out exactly what's needed for the chroot to
-operate correctly.
-
-2) Compile nethack. Make sure the directories in the chroot match up with
-where nethack thinks everything is. You may need to edit the VAR_PLAYGROUND
-variable in include/unixconf.h and/or the HACKDIR variable in include/config.h.
-
-(Note: Try not to, for security, to put anything else in the chroot. You may
-need to put gzip in there though if you compile nethack to use it for 
-compression.)
-
-3) Make a copy of dgamelaunch.conf and edit it. This will contain information
-for dgamelaunch about what uid/username, gid/group to shed privileges to at
-runtime. It must also contain the path to nethack, and needs to know certain
-aspects of your chroot.
-
-Note that using a username in dgamelaunch.conf will cause (part of) your
-passwd database to be loaded into dgamelaunch's memory space. If you use BSD,
-this will also include encrypted passwords. Therefore, it's recommended to
-put the uid in the dgamelaunch.conf. The same applies to groups, but openpty(3)
-often looks up the tty group anyway.
-
-4) Setup dgamelaunch as one of the following:
-        a) The shell for a single login.
-        b) An (x)inetd service.
-
-If you choose a login shell make sure dgamelaunch is setuid root. (that is,
-chmod 4755 dgamelaunch.) It will shed privs right after entering the chroot
-jail though.
-
-Example xinetd lines:
-
-service telnet
-{
-  socket_type     = stream
-  protocol  = tcp
-  wait      = no
-  user      = root
-  server    = /usr/sbin/in.telnetd
-  server_args     = -h -L /opt/nethack/nethack.dtype.org/dgamelaunch -q -f /etc/dgamelaunch.conf
-  rlimit_cpu      = 3600
-  bind      = 64.71.163.206
-}
-
-A classic inetd line would look like this:
-
-telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch -q -f /etc/dgamelaunch.conf
-
-In both cases, the -L specifies an alternate login program (telnetlogin is
-invoked by default) and -h prevents revealing of a login banner (for 
-example, "Debian GNU/Linux testing/unstable influx") before starting the
-login shell.
-
-It goes without saying that the argument after -L must point to dgamelaunch's
-exact location. Also, the location of dgamelaunch.conf is variable and of
-course should be customized by you.
-
-NOTE: It appears that the -L option is not very widely supported. FreeBSD's
-telnetd uses -p instead, and you can't give arguments (arguments appropriate
-to standard login are used). Some other telnetds do not support anything
-like this at all.
-
-The -f option, followed by a filename, specifies the path to the config file
-to use for dgamelaunch.  If you specify the right path for DEFCONFIG in the
-Makefile, you may be able to omit this.
-
-For dgamelaunch, the -q option will silence errors pertaining to the server
-configuration. This is recommended for use within inetd to prevent spamming
-the clients, but when testing and setting up we strongly suggest you leave it
-off until running dgamelaunch produces no error output on stderr.
-
-5) Test your compilation of dgamelaunch by running it as root. If this
-works, a shell login or (x)inetd will work with the correct configuration.
-If you have problems with dgamelaunch's display make sure that your chroot's
-/etc/terminfo directory (or whatever directory your ncurses uses) is
-populated.
-
-
-COMMANDLINE PARAMETERS
-======================
-
- -a            Ignored.
- -c            Shows error message and exits. (login shell command)
- -e            Ignored.
- -h            Ignored.
- -i user       Autologin and run the register -command hook for "user"
-               (with password "user").
- -p            Ignored.
- -q            Be quiet, suppress errors.
- -s            Show players currently playing.
- -W user:msg   Send message "msg" to all players. The message seems
-               to come from "user".
- -S            Free the shared memory block.
- -D            Show contents of the shared memory block.
-
-
-ENVIRONMENT VARIABLES
-=====================
-
- Linux telnetd allows importing the USER environment variables via telnet,
- while FreeBSD does not.  FreeBSD, on the other hand, does allow the LOGNAME
- environment variable.  Dgamelaunch will first check USER, then LOGNAME,
- for "username:password", and tries autologin if either exists.
- Dgamelaunch-specific DGLAUTH is checked before either of those.
-
-
-ERROR CODES
-===========
-
-   1   Could not terminate stale processes
-   2   Cannot chroot()
-   3   Cannot chdir()
-   4   Cannot setgroups()
-   5   Cannot setgid()
-   6   Cannot setuid()
-   7   Caught HUP
-   8   Cannot run as root: Config file has shed_user = "root"
-   9   Cannot run as root: Config file has shed_user set to UID 0 user.
-  10   Could not setup player
-  11   Cannot run as root: Config file has shed_uid = 0
-  12   Config file has an unrecognized token
-  13   Config file: Negative value not accepted
-  14   Cannot unshare()
-  15   dgamelaunch called with -c (login shell command); exited
-  20   No menu defined, or no banner found for menu
-  60   Cannot create a new terminal, or no termcap files.
-  61   Cannot openpty()
-  62   Cannot open /dev/ptmx
-  65   Cannot open master ptsname
-  68   Cannot fcntl inprogress-lock
-  70   Cannot write to inprogress-lock
-  71   ftok() error for shm_key, no "dgamelaunch" file found?
-  72   ftok() error for shm_sem_key, no "dgamelaunch" file found?
-  73   shmget() error, cannot connect to shared memory
-  74   smat() error, cannot attach to shared memory
-  75   Nothing in shared memory?
-  76   sem_init() error, could not initialize shared memory
-  77   sem_wait() error
-  78   sem_post() error
-  95   Cannot fnctl lockfile
-  96   sqlite3_open() failed when checking user existence: could not open login database
-  97   sqlite3_open() failed in writefile()
-  98   sqlite3_exec() failed in writefile()
-  99   Could not open password file
- 100   Username field too long in login file
- 101   Email field too long in login file
- 102   password field too long in login file
- 103   env field too long in login file
- 104   Cannot read config file
- 105   Cannot read default config file
- 106   Cannot open lockfile or password file
- 107   fcntl failed on login database in writefile()
- 108   sqlite3_exec() failed when checking user existence.
- 109   Too many registered users. (see maxusers setting in config file)
- 110   Login failed
- 111   Two users trying to register at the same time
- 112   Error changing password: cannot have ':' in password
- 113   Error parsing configuration file
- 114   exec-command fork failed
- 115   could not read lock file in writefile()
- 116   Too many registered users. (see maxusers setting in config file)
- 117   wall error: no message to send
- 118   wall error: no players
- 119   User has a retarded terminal
- 120   wall error: message too long
- 121   wall error: "from" username is too short
- 122   Error changing password: struct "me" does not exist
- 123   chdir() failed in dgl commands.
- 140   populate_games(): Cannot open inprogress-dir
- 145   populate_games(): Inprogress-filename does not have ':' in it
- 146   populate_games(): Inprogress-filename does not have ': in it (pt. 2)
- 200   purge_stale_locks(): could not open inprogress-dir
- 201   purge_stale_locks(): inprogress-file did not have ':' in it
- 202   purge_stale_locks(): could not read inprogress-file
- 203   purge_stale_locks(): could not get inprogress-file contents
diff --git a/README.bak b/README.bak
new file mode 100644 (file)
index 0000000..241b804
--- /dev/null
@@ -0,0 +1,247 @@
+dgamelaunch
+===========
+
+dgamelaunch is a network-based game shell where anyone can sign up for an
+account and start playing any game which suits your fancy - games known to
+work with dgamelaunch are for example NetHack (http://www.nethack.org) and
+Crawl (http://crawl.develz.org).
+
+
+DGAMELAUNCH VERSIONS
+====================
+
+Development version can be fetched from the source repository with git:
+
+  git clone git://github.com/paxed/dgamelaunch.git
+
+Releases are downloadable at http://alt.org/nethack/dgamelaunch/
+
+
+REQUIREMENTS
+============
+
+- normal development tools (make, etc)
+- autotools (autogen, autoconf, automake)
+- ncurses library and development files
+- bison (or yacc or byacc)
+- flex (or lex)
+- optionally sqlite3 library and development files
+
+
+COMPILING
+=========
+
+Basically all you have to do is:
+
+  ./autogen.sh && make
+
+Some options you might want give to autogen:
+
+ --with-config-file=/absolute/path/to/dgamelaunch.config
+ --enable-shmem
+ --enable-sqlite
+
+
+Dgamelaunch should compile without issue on Linux, Solaris, FreeBSD 4 and 5.
+(Whether it _runs_ on all of these platforms is a different issue. We'd
+like to hear about it.)
+
+dgamelaunch was originally developed by M. Drew Streib <dtype@dtype.org> but
+is now a collaborative project. Copyright and contact information is in the
+COPYING file, included with this package.
+
+
+BASIC SETUP INSTRUCTIONS
+========================
+
+These instructions are not current. For a more up-to-date ones, see
+http://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch
+
+
+
+
+1) Setup a chroot jail. There is a helpful script included to accomplish this,
+called dgl-create-chroot, in the source directory. The default settings are
+viewable by editing the script; to customize the installation, look at
+dgl-create-chroot.conf.example.* (also in the source directory) and edit it to
+suit your needs, and save it into the same directory as dgl-create-chroot as
+dgl-create-chroot.conf. It's very likely you need to run the script as root.
+The script will not work with the very limited System V /bin/sh, such found on
+Solaris; start it with ksh instead.
+
+If you decide to not use dgl-create-chroot, you're on your own and we assume
+you have enough clue to figure out exactly what's needed for the chroot to
+operate correctly.
+
+2) Compile nethack. Make sure the directories in the chroot match up with
+where nethack thinks everything is. You may need to edit the VAR_PLAYGROUND
+variable in include/unixconf.h and/or the HACKDIR variable in include/config.h.
+
+(Note: Try not to, for security, to put anything else in the chroot. You may
+need to put gzip in there though if you compile nethack to use it for 
+compression.)
+
+3) Make a copy of dgamelaunch.conf and edit it. This will contain information
+for dgamelaunch about what uid/username, gid/group to shed privileges to at
+runtime. It must also contain the path to nethack, and needs to know certain
+aspects of your chroot.
+
+Note that using a username in dgamelaunch.conf will cause (part of) your
+passwd database to be loaded into dgamelaunch's memory space. If you use BSD,
+this will also include encrypted passwords. Therefore, it's recommended to
+put the uid in the dgamelaunch.conf. The same applies to groups, but openpty(3)
+often looks up the tty group anyway.
+
+4) Setup dgamelaunch as one of the following:
+        a) The shell for a single login.
+        b) An (x)inetd service.
+
+If you choose a login shell make sure dgamelaunch is setuid root. (that is,
+chmod 4755 dgamelaunch.) It will shed privs right after entering the chroot
+jail though.
+
+Example xinetd lines:
+
+service telnet
+{
+  socket_type     = stream
+  protocol  = tcp
+  wait      = no
+  user      = root
+  server    = /usr/sbin/in.telnetd
+  server_args     = -h -L /opt/nethack/nethack.dtype.org/dgamelaunch -q -f /etc/dgamelaunch.conf
+  rlimit_cpu      = 3600
+  bind      = 64.71.163.206
+}
+
+A classic inetd line would look like this:
+
+telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch -q -f /etc/dgamelaunch.conf
+
+In both cases, the -L specifies an alternate login program (telnetlogin is
+invoked by default) and -h prevents revealing of a login banner (for 
+example, "Debian GNU/Linux testing/unstable influx") before starting the
+login shell.
+
+It goes without saying that the argument after -L must point to dgamelaunch's
+exact location. Also, the location of dgamelaunch.conf is variable and of
+course should be customized by you.
+
+NOTE: It appears that the -L option is not very widely supported. FreeBSD's
+telnetd uses -p instead, and you can't give arguments (arguments appropriate
+to standard login are used). Some other telnetds do not support anything
+like this at all.
+
+The -f option, followed by a filename, specifies the path to the config file
+to use for dgamelaunch.  If you specify the right path for DEFCONFIG in the
+Makefile, you may be able to omit this.
+
+For dgamelaunch, the -q option will silence errors pertaining to the server
+configuration. This is recommended for use within inetd to prevent spamming
+the clients, but when testing and setting up we strongly suggest you leave it
+off until running dgamelaunch produces no error output on stderr.
+
+5) Test your compilation of dgamelaunch by running it as root. If this
+works, a shell login or (x)inetd will work with the correct configuration.
+If you have problems with dgamelaunch's display make sure that your chroot's
+/etc/terminfo directory (or whatever directory your ncurses uses) is
+populated.
+
+
+COMMANDLINE PARAMETERS
+======================
+
+ -a            Ignored.
+ -c            Shows error message and exits. (login shell command)
+ -e            Ignored.
+ -h            Ignored.
+ -i user       Autologin and run the register -command hook for "user"
+               (with password "user").
+ -p            Ignored.
+ -q            Be quiet, suppress errors.
+ -s            Show players currently playing.
+ -W user:msg   Send message "msg" to all players. The message seems
+               to come from "user".
+ -S            Free the shared memory block.
+ -D            Show contents of the shared memory block.
+
+
+ENVIRONMENT VARIABLES
+=====================
+
+ Linux telnetd allows importing the USER environment variables via telnet,
+ while FreeBSD does not.  FreeBSD, on the other hand, does allow the LOGNAME
+ environment variable.  Dgamelaunch will first check USER, then LOGNAME,
+ for "username:password", and tries autologin if either exists.
+ Dgamelaunch-specific DGLAUTH is checked before either of those.
+
+
+ERROR CODES
+===========
+
+   1   Could not terminate stale processes
+   2   Cannot chroot()
+   3   Cannot chdir()
+   4   Cannot setgroups()
+   5   Cannot setgid()
+   6   Cannot setuid()
+   7   Caught HUP
+   8   Cannot run as root: Config file has shed_user = "root"
+   9   Cannot run as root: Config file has shed_user set to UID 0 user.
+  10   Could not setup player
+  11   Cannot run as root: Config file has shed_uid = 0
+  12   Config file has an unrecognized token
+  13   Config file: Negative value not accepted
+  14   Cannot unshare()
+  15   dgamelaunch called with -c (login shell command); exited
+  20   No menu defined, or no banner found for menu
+  60   Cannot create a new terminal, or no termcap files.
+  61   Cannot openpty()
+  62   Cannot open /dev/ptmx
+  65   Cannot open master ptsname
+  68   Cannot fcntl inprogress-lock
+  70   Cannot write to inprogress-lock
+  71   ftok() error for shm_key, no "dgamelaunch" file found?
+  72   ftok() error for shm_sem_key, no "dgamelaunch" file found?
+  73   shmget() error, cannot connect to shared memory
+  74   smat() error, cannot attach to shared memory
+  75   Nothing in shared memory?
+  76   sem_init() error, could not initialize shared memory
+  77   sem_wait() error
+  78   sem_post() error
+  95   Cannot fnctl lockfile
+  96   sqlite3_open() failed when checking user existence: could not open login database
+  97   sqlite3_open() failed in writefile()
+  98   sqlite3_exec() failed in writefile()
+  99   Could not open password file
+ 100   Username field too long in login file
+ 101   Email field too long in login file
+ 102   password field too long in login file
+ 103   env field too long in login file
+ 104   Cannot read config file
+ 105   Cannot read default config file
+ 106   Cannot open lockfile or password file
+ 107   fcntl failed on login database in writefile()
+ 108   sqlite3_exec() failed when checking user existence.
+ 109   Too many registered users. (see maxusers setting in config file)
+ 110   Login failed
+ 111   Two users trying to register at the same time
+ 112   Error changing password: cannot have ':' in password
+ 113   Error parsing configuration file
+ 114   exec-command fork failed
+ 115   could not read lock file in writefile()
+ 116   Too many registered users. (see maxusers setting in config file)
+ 117   wall error: no message to send
+ 118   wall error: no players
+ 119   User has a retarded terminal
+ 120   wall error: message too long
+ 121   wall error: "from" username is too short
+ 122   Error changing password: struct "me" does not exist
+ 123   chdir() failed in dgl commands.
+ 140   populate_games(): Cannot open inprogress-dir
+ 145   populate_games(): Inprogress-filename does not have ':' in it
+ 146   populate_games(): Inprogress-filename does not have ': in it (pt. 2)
+ 200   purge_stale_locks(): could not open inprogress-dir
+ 201   purge_stale_locks(): inprogress-file did not have ':' in it
+ 202   purge_stale_locks(): could not read inprogress-file
+ 203   purge_stale_locks(): could not get inprogress-file contents
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..32f849f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,188 @@
+The main feature of the master branch of this fork is install-dgl-nh500, which does what it says on the tin.
+It will fetch, compile, and install nethack 5.0.0, and do the same for DGL (although it is already fetched
+by the time you're using the script), and put them into a chroot of your choosing.
+
+autoconf branch is for making dgl's configure/makefile stuff work, without having to use these bash scripts
+people have written over the years.
+
+I'm pretty interested in the history of this program -- so much so that I went through pains trying to make
+sure I was forking a version of the repository that contained accurate commit hashes -- crawl's fork has
+somehow mangled them such that its history appears entirely-unrelated to git.
+
+Anyway, if you know anything of the history, reach out.
+
+# install-dgl-nh500 documentation
+```bash
+#!/bin/bash
+
+# install-dgl-nh500
+#
+# Script for setting up Debian DGL/NetHack 5.0.0 environment
+# (hopefully to also set up DCSS 0.34.1 too)
+#
+# You should run this as root.
+#
+# Should be run in the directory it was shipped in.
+#
+# Usage:
+# ./install-dgl-nh500 [options]
+#
+# OPTION [default]                    DESCRIPTION
+# --prefix <dir> [/opt/dgamelaunch]   DGL's chroot. All other locations are
+#                                     relative to this directory! And
+#                                     everything DGL or NetHack need to run
+#                                     is in this directory.
+
+# --var <dir> [/var]                  Location for mutable data. Organized a
+#                                     little strangely in that each game known
+#                                     to dgamelaunch has its own subdirectory,
+#                                     and dgamelaunch's data is just in here.
+
+# --etc <dir> [/etc]                  Location for immutable and config data.
+#                                     Ditto, each game has its own subdirectry.
+#                                     note that NetHack doesn't have one; all
+#                                     of its immutable data lives in hackdir.
+
+# --menudir <dir> [<etc>/menu]         Location for menu files. Really they can
+#                                     be anywhere, but this instructs the
+#                                     script where to put the default ones.
+
+# --hackdir <dir> [/opt/nh500]        NetHack is built wth this as its prefix.
+
+# --playground <dir> [/var/nh500]     NetHack is built with this as its
+#                                     'var playground.'
+
+# --dbfile <sqlite3 db> [<var>/dgamelaunch.db]   The location for the database.
+
+# --without-nano [FLAG]               If you do not set this flag, nano will be
+#                                     installed in the chroot, for use as an
+#                                     editor. The default configuration
+#                                     assumes it is "built" with nano.
+
+# --without-nh500 [FLAG]              If you set without-nh500, the script will
+#                                     not install NetHack. Know what you're
+#                                     doing!
+
+# -q -s --quiet --silent [FLAG]       Causes autogen and make to run quietly.
+
+# --clean                [FLAG]       Skips everything except the clean step.
+#                                     Useful if the process gets interrupted...
+
+
+# Here are some settings which would cause nethack and dgl to be installed
+# in a way that reflects the setup instructions provided by Paxed...
+# for posterity and testing.
+#
+# CHROOT="/opt/nethack/nethack.alt.org"
+# DGLVAR="/dgldir"
+# DGLETC="/."
+# MENUDIR="$DGLETC"
+# HACKDIR="/nh500"
+# PLAYGROUND="/nh500/var"
+#
+# ./install-dgl-nh500 --prefix /opt/nethack/nethack.alt.org --var /dgldir \
+#   --etc /. --menudir /. --hackdir /nh500 --playground /nh500/var --quiet
+```
+
+# step-by-step usage
+To install and use NetHack and dgamelaunch, simply (tested as working on
+Debian 6.12.88-1, with prerequisites already installed):
+
+After downloading this version of dgamelaunch:
+
+```bash
+cd dgamelaunch-nh500
+sudo ./install-dgl-nh500
+```
+dgamelaunch will be installed at `/opt/dgamelaunch`, and NetHack 5.0.0 will be
+installed in `/opt/dgamelaunch/opt/nh500`.
+
+To test the system:
+
+```bash
+sudo /opt/dgamelaunch/bin/dgamelaunch
+```
+
+Try to register a new user, login, and play the game.
+If it works, brilliant! If it doesn't work, try the NetHack binary:
+
+```bash
+sudo chroot /opt/dgamelaunch nh500
+```
+
+If that fails, it might be a missing library. Check `/opt/dgamelaunch/lib/`
+and `.../lib64`, and compare the contents with the results of
+`ldd /opt/dgamelaunch/bin/nh500`. Then copy over libraries as necessary.
+
+
+If it's working, then you may wish to let people connect to the server just
+like other servers you see online.
+
+To do this, you will need to do something pretty dangerous -- let anyone run
+dgamelaunch, even though it has root privileges.
+
+```bash
+sudo chmod a+s /opt/dgamelaunch/bin/dgamelaunch.<date>
+```
+
+Replace <date> with the appropriate string of numbers, obviously. From here,
+any user can run dgamelaunch on your system, which might potentially create
+a vulnerability.
+
+Next, set up a new user. On Debian:
+
+```bash
+sudo adduser nethack
+```
+And follow the prompts. Name the user whatever you like, and give bogus info
+for everything other than password. Now edit `/etc/passwd`. The new user's
+line will look like this:
+
+```bash
+nethack:x:<uid>:<gid>:nethack,1,1,1,1:/home/nethack:/bin/bash
+```
+
+You need to modify the new user's line like so:
+
+```bash
+nethack:x:<uid>:<gid>:nethack,1,1,1,1:/home/nethack:/opt/dgamelaunch/bin/dgamelaunch.<date>
+```
+
+What we are doing there is setting the user nethack's login shell to
+dgamelaunch. This way, when someone uses SSH to connect to your server, and
+logs in as nethack, they will be presented immediately with dgamelaunch, and
+will not see a shell when it exits.
+
+Congrats on your new server...
+
+
+# Dungeon Crawl Stone Soup
+First, though, here's how to install Dungeon Crawl Stone Soup:
+1) obtain the source, navigate to that directory
+2) `sudo make install prefix=/ DATADIR=/etc/dcss0341 SAVEDIR=/var/dcss0341 USE_DGAMELAUNCH=1`
+Note: 2) instead of setting USE_DGAMELAUNCH, you can also edi
+`<src>/crawl-ref/source/AppHdr.h`, and `#define DGAMELAUNCH=1` there. (and tweak
+    other settings which interest you)
+3) navigate to the directory with these scripts (dgamelaunch source dir)
+4) ...
+```bash
+./cpbin -b /bin /bin/crawl /opt/dgamelaunch
+sudo cp /etc/dcss0341 /opt/dgamelaunch/etc/
+sudo cp /var/dcss0341 /opt/dgamelaunch/var/
+```
+5) (clean up in `/bin/crawl`, `/etc/dcss0341`, `/var/dcss0341` if you want to; don't need those files anymore)
+6) Modify `dgamelaunch.conf` to uncomment relevant lines
+7) ...
+```bash
+sudo mkdir /opt/dgamelaunch/var/inprogress-dcss0341
+sudo chown -R games:games /opt/dgamelaunch/var
+```
+8) Modify the main menu (it might help to `dcss-menu.patch` to it)
+
+That's it!
+
+# Resources
+More resources for troubleshooting vis NetHack:
+https://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch
+Vis dgamelaunch and crawl:
+https://github.com/tarballqc/dcss-server-install/
\ No newline at end of file
diff --git a/cpbin b/cpbin
new file mode 100644 (file)
index 0000000..860959b
--- /dev/null
+++ b/cpbin
@@ -0,0 +1,200 @@
+#!/bin/bash
+
+# cpbin copies a binary and its necessary libraries into a given directory.
+# The purpose is to aid in preparing chroots.
+#
+# It doesn't do any other preparation of the directory as a chroot; it only
+# copies bins and libs.
+#
+# refactored out of original dgl-create-chroot
+#
+# cpbin [OPTIONS] BINARY [DIRECTORY]
+#
+# [DIRECTORY] defaults to "$HOME/chroot"
+#
+# OPTIONS
+# --bindir [dir]       Sets BINDIR, the directory for the binary to live.
+#                      Defaults to the binary's dirname.
+#                      Path is from inside the chroot! So -b /bin will
+#                      install binaries in /<DIRECTORY>/bin
+
+# --libdir [dir]       Sets LIBDIR, the directory for libraries to live.
+#                      Defaults to the library's dirname, for each library.
+#                      Path is from inside the chroot! See above.
+
+# --only-libs                  Causes the program to refrain from copying the
+#                      binaries; it only copies libraries. It still makes
+#                       the directory, unless DRYRUN is set.
+
+# --only-bin           Causes the program to refrain from copying the
+#                      libraries; it only copies binaries. It still makes
+#                       the directory, unless DRYRUN is set.
+
+# --only-dirs          Creates the requisite directory structure only. Does
+#                      not copy any files. Equivalent to setting both
+#                      NOBIN and NOLIBS.
+
+# --dry                        Causes the program to output what it would do,
+#                      ie it had not received the --dry option. ie do nothing
+
+# --quiet              Causes the program to refrain from making extraneous
+#                      noises.
+
+# --really-quiet       Causes the program to refrain from even reporting
+#                       errors...
+
+# --help               Display this help message.
+# ^^ line 46
+
+set -e
+umask 022
+
+##### Some other programs
+cpbindir=`dirname $0`
+sanepath=$cpbindir/sanepath
+findlibs=$cpbindir/findlibs
+cpbinname="cpbin"
+
+##### functions
+# Echo a message absent the QUIET env var.
+say() { [ "$QUIET" -lt 2 ] && printf "$cpbinname: $1\n" || :; }
+
+# Echo a message to stderr.
+err() { [ "$QUIET" -lt 1 ] && >&2 echo "$cpbinname - ERROR: $1" || :; }
+
+# Echo to stderr and exit 1.
+errexit() { err "$1"; exit 1; }
+
+# mkdirif <label> <dir>
+# Make <dir> if it doesn't exist. Print an error if it does exist, and wasn't
+# made by this script. <label> is just a name for the printed messages
+# and errors.
+# If DRYRUN is set, only runs checks and prints messages/error. (no mkdir)
+mkdirif() {
+  [ ! -d "$2" ] && {
+    say "Making $1 directory at $2";
+    [ -z "$MKED" ] && MKED=$2 || MKED="$MKED $2";
+  } || {
+    [ -z "`echo $MKED | grep $2`" ] && err "$2/ already exists." || :;
+  }
+  [ -z "$DRYRUN" ] && mkdir -p "$2" || :;
+}
+
+# cpif <source> <dir>
+# Copy <source> to directory <dir> if it doesn't exist there. Print an error
+# if it does exist.
+# If DRYRUN is set, only runs checks and prints messages/errors.
+cpif() {
+  [ ! -e "$2/`basename $1`" ] && {
+    say "Copying $1 to $2.";
+  } || {
+    err "$2/`basename $1` already exists.";
+  }
+  [ -z "$DRYRUN" ] && cp "$1" "$2/" || :;
+}
+
+##### take options
+while [ "$#" -gt 0 ]; do
+  case $1 in
+    --help)
+      printf "`sed -n '3,46p;46q' $0 | tr -d "#"`\n\n"
+      exit 0
+      ;;
+    --bindir)
+      BINDIR=`$sanepath $2`
+      shift
+      shift
+      ;;
+    --libdir)
+      LIBDIR=`$sanepath $2`
+      shift
+      shift
+      ;;
+    -m)
+      CHMOD=$2
+      shift
+      shift
+      ;;
+    --only-libs)
+      NOBIN=1
+      shift
+      ;;
+    --only-bin)
+      NOLIBS=1
+      shift
+      ;;
+    --only-dirs)
+      NOBIN=1
+      NOLIBS=1
+      shift
+      ;;
+    --quiet)
+      QUIET=1
+      shift
+      ;;
+    --really-quiet)
+      QUIET=2
+      shift
+      ;;
+    --dry)
+      DRYRUN=1
+      shift
+      ;;
+    --)
+      set --
+      break
+      ;;
+    -*|--*)
+      echo "Unknown option $1"
+      echo "Try --help"
+      exit 1
+      ;;
+    *)
+      break # (treat this as $1)
+      ;;
+  esac
+done
+# If no options were passed, print help.
+[ -z "$1" ] && { printf "`sed -n '3,29p;29q' $0 | tr -d "#"`\n\n"; exit 0; }
+
+##### set up defaults
+# QUIET=0
+[ -z "$QUIET" ] && QUIET=0 || :;
+# CHROOT=$HOME/chroot
+[ -z "$2" ] && {
+    say "No chroot given; using $HOME/chroot";
+    CHROOT="$HOME/chroot";
+  } || {
+    CHROOT="$2";
+  }
+# Find the bin the user's talking about
+# USEBIN=`which $1`
+USEBIN=`which $1` || errexit "$1 is not executable.";
+# BINDIR=`dirname $USEBIN`
+[ -z "$BINDIR" ] && BINDIR="`dirname $USEBIN`" || :;
+
+#####
+# Make chroot and bin directory
+mkdirif "chroot" "$CHROOT"
+mkdirif "bin" "$CHROOT$BINDIR"
+# Copy binary
+[ -z "$NOBIN" ] && cpif "$USEBIN" "$CHROOT$BINDIR" || :;
+# Run findlibs
+USELIBS=`$findlibs $USEBIN`
+if [ -n "$USELIBS" ]; then
+  # Sort libs and filter out duplicates
+  USELIBS=`for lib in $USELIBS; do echo $lib; done | sort | uniq`
+  for lib in $USELIBS; do
+    # Use LIBDIR if user set it; otherwise, use `dirname $lib`
+    USEDIR=`dirname $lib`
+    [ -n "$LIBDIR" ] && USEDIR=$LIBDIR || :
+    # Make lib dir
+    mkdirif "lib" "$CHROOT$USEDIR"
+    # Copy library
+    [ -z "$NOLIBS" ] && cpif $lib "$CHROOT$USEDIR" || :;
+  done
+fi
+
+if [ -n "$CHMOD" ]; then
+   chmod $CHMOD "$CHROOT$BINDIR`basename $USEBIN`"
+fi
diff --git a/dgl-nh500.patch b/dgl-nh500.patch
new file mode 100644 (file)
index 0000000..140f8a9
--- /dev/null
@@ -0,0 +1,89 @@
+diff -urB NetHack-5.0.0.bak/include/config.h NetHack-5.0.0/include/config.h
+--- NetHack-5.0.0.bak/include/config.h 2026-05-21 17:21:57.837822465 -0400
++++ NetHack-5.0.0/include/config.h     2026-05-21 17:22:19.470437749 -0400
+@@ -340,7 +340,7 @@
+ #endif
+ #ifndef PERS_IS_UID
+ #if !defined(MICRO) && !defined(MACOS9) && !defined(WIN32)
+-#define PERS_IS_UID 1 /* delete for PERSMAX per name; now per uid */
++#define PERS_IS_UID 0 /* delete for PERSMAX per name; now per uid */
+ #else
+ #define PERS_IS_UID 0
+ #endif
+@@ -444,7 +444,7 @@
+  * otherwise it will be the current directory.
+  */
+ #ifndef HACKDIR
+-#define HACKDIR "/usr/games/lib/nethackdir"
++#define HACKDIR "(:hackdir:)"
+ #endif
+ /*
+diff -urB NetHack-5.0.0.bak/include/unixconf.h NetHack-5.0.0/include/unixconf.h
+--- NetHack-5.0.0.bak/include/unixconf.h       2026-05-21 17:21:57.845822692 -0400
++++ NetHack-5.0.0/include/unixconf.h   2026-05-21 17:22:19.478437978 -0400
+@@ -83,7 +83,7 @@
+  * If you want the static parts of your playground on a read-only file
+  * system, define VAR_PLAYGROUND to be where the variable parts are kept.
+  */
+-/* #define VAR_PLAYGROUND "/var/lib/games/nethack" */
++#define VAR_PLAYGROUND "(:playground:)"
+ /*
+  * Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more"
+diff -urB NetHack-5.0.0.bak/sys/unix/hints/include/multiw-1.500 NetHack-5.0.0/sys/unix/hints/include/multiw-1.500
+--- NetHack-5.0.0.bak/sys/unix/hints/include/multiw-1.500      2026-05-21 17:21:57.929825081 -0400
++++ NetHack-5.0.0/sys/unix/hints/include/multiw-1.500  2026-05-21 17:25:44.476492435 -0400
+@@ -5,8 +5,8 @@
+ # 1. Which windowing interface(s) should be included in this binary?
+ # One or more of these can be manually uncommented and/or can be specified
+ # on the 'make' command line.  If none are enabled, tty will be used.
+-#WANT_WIN_TTY=1
+-#WANT_WIN_CURSES=1
++WANT_WIN_TTY=1
++WANT_WIN_CURSES=1
+ #WANT_WIN_X11=1
+ #WANT_WIN_QT=1
+@@ -14,7 +14,7 @@
+ # Exactly one of these can be manually uncommented and/or can be specified
+ # on the 'make' command line.  If none is enabled, the first among
+ # WANT_WIN_{tty,curses,X11,Qt} that is enabled will become default.
+-#WANT_DEFAULT=tty
++WANT_DEFAULT=tty
+ #WANT_DEFAULT=curses
+ #WANT_DEFAULT=Qt
+ #WANT_DEFAULT=X11
+diff -urB NetHack-5.0.0.bak/sys/unix/hints/linux.500 NetHack-5.0.0/sys/unix/hints/linux.500
+--- NetHack-5.0.0.bak/sys/unix/hints/linux.500 2026-05-21 17:21:57.929825081 -0400
++++ NetHack-5.0.0/sys/unix/hints/linux.500     2026-05-21 17:22:19.482438091 -0400
+@@ -40,7 +40,7 @@
+ endif
+ #4. Other
+-GAMEUID  = $(USER)
++GAMEUID  = games
+ GAMEGRP  = games
+ # This gives better backtraces by making all core functions global; this
+@@ -418,16 +418,16 @@
+ MOREALL=$(MAKE) install
+ else #!WANT_SOURCE_INSTALL
+ #PREFIX=/usr
+-PREFIX=$(wildcard ~)/nh/install
+-HACKDIR=$(PREFIX)/games/lib/nethackdir
+-SHELLDIR = $(PREFIX)/games
++PREFIX=/.
++HACKDIR=$(PREFIX)(:hackdir:)
++SHELLDIR = $(PREFIX)
+ VARDIRPERM = 0755
+ VARFILEPERM = 0600
+ GAMEPERM = 0755
+ endif #?WANT_SOURCE_INSTALL
+ INSTDIR=$(HACKDIR)
+-VARDIR = $(HACKDIR)
++VARDIR = $(PREFIX)(:playground:)
+ ifdef MAKEFILE_TOP
+ TESTGDBPATH=/usr/bin/gdb
diff --git a/dgl.patch b/dgl.patch
new file mode 100644 (file)
index 0000000..e677228
--- /dev/null
+++ b/dgl.patch
@@ -0,0 +1,269 @@
+diff -urB dgamelaunch.bak/examples/dgamelaunch.conf dgamelaunch.new/examples/dgamelaunch.conf
+--- dgamelaunch.bak/examples/dgamelaunch.conf  2020-03-07 06:27:35.000000000 -0500
++++ dgamelaunch.new/examples/dgamelaunch.conf  2026-05-23 03:21:19.009017983 -0400
+@@ -1,12 +1,7 @@
+-# This is a sample dgamelaunch configuration file. Only bash-style comments
+-# are allowed, such as this. Each configuration option will be explained
+-# along with its default value.
+-
+-
+-
+-# Global config variables:
+-
++# This is a sample dgamelaunch configuration file.
++# Also, functional.
++### Global config variables:
+ # Max amount of registered users to allow. Has no effect if dgl was
+ # compiled with SQLite
+ maxusers = 64000
+@@ -41,20 +36,20 @@
+ #                 ]
+ # Path to a prepared chroot jail.
+-chroot_path = "/opt/nethack/nethack.alt.org/"
++chroot_path = "/opt/dgamelaunch"
+ # From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
+-dglroot = "/dgldir/"
++dglroot = "/var/"
+ # Server ID string
+-server_id = "nethack.alt.org - http://nethack.alt.org/"
++server_id = "Generic NetHack-Enabled dgamelaunch Server"
+ # From inside the jail, location of a banner file, the topmost line will be
+ # shown in submenus that cannot be defined separately.
+ # Some string substitution is done for the file:
+ # $VERSION   replaced with "dgamelaunch v" + dgl version number.
+ # $SERVERID  replaced with the server_id string, as defined above.
+-banner = "/dgl-banner"
++banner = "/etc/menu/dgl-banner"
+ # The following two options are fairly insecure. They will force us to
+ # load the password/group database into memory while still having root
+@@ -152,7 +147,7 @@
+ # First, the menu shown to anonymous user:
+ menu["mainmenu_anon"] {
+-        bannerfile = "dgl_menu_main_anon.txt"
++        bannerfile = "/etc/menu/dgl_menu_main_anon.txt"
+         cursor = (5,18)
+         commands["l"] = ask_login
+         commands["r"] = ask_register
+@@ -165,7 +160,7 @@
+ menu["mainmenu_user"] {
+ # contents of this file are written to screen.
+ # the file must be inside the chroot.
+-        bannerfile = "dgl_menu_main_user.txt"
++        bannerfile = "/etc/menu/dgl_menu_main_user.txt"
+ # after which cursor is moved to this location
+ # if cursor-definition is missing, the cursor is put
+ # to the end of the last line of the banner.
+@@ -176,15 +171,18 @@
+         commands["c"] = chpasswd
+         commands["e"] = chmail
+         commands["w"] = watch_menu
+-        commands["o"] = ifnxcp "/dgl-default-rcfile.nh343" "%ruserdata/%n/%n.nh343rc",
+-                      exec "/bin/virus" "%ruserdata/%n/%n.nh343rc"
+-        commands["p"] = play_game "NH343"
++        commands["o"] = ifnxcp "/etc/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
++                      exec "/bin/virus" "%ruserdata/%n/%n.nh500rc"
++        commands["O"] = ifnxcp "/etc/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
++                      exec "/bin/nano" "%ruserdata/%n/%n.nh500rc"
++        commands["p"] = play_game "nh500curses"
++      commands["P"] = play_game "nh500tty"
+         commands["q"] = quit
+ }
+ # this menu is shown when user presses '?' in the watching menu
+ menu["watchmenu_help"] {
+-      bannerfile = "dgl_menu_watchmenu_help.txt"
++      bannerfile = "/etc/menu/dgl_menu_watchmenu_help.txt"
+       commands["qQ "] = return
+ }
+@@ -193,29 +191,41 @@
+ # Next, we'll define one game's data:
+-#DEFINE {
++DEFINE {
+ #  # From inside the jail, the location of the binary to be launched.
+-#  game_path = "/bin/nethackstub"
+-#
++  game_path = "/bin/nh500"
++
++#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
++#  # If set to "ask", the game will be run with --print-charset beforehand,
++#  # expected to return one of these values.
++#  encoding = "unicode"
++
+ #  # Full name of the game
+-#  game_name = "NetHack stub"
+-#
++  game_name = "NetHack 5.0.0 (tty)"
++
+ #  # Short name, used in the watching menu
+-#  short_name = "NHstb"
+-#
++  short_name = "nh500tty"
++
+ #  # arguments for when we exec the binary
+-#  game_args = "/bin/nethackstub",
+-#           "foo",
+-#           "user:%n",
+-#           "shed_uid:%u",
+-#           "bar"
+-#
++  game_args = "/bin/nethackstub", "-u", "%n", "-wtty"
++
+ #  # From inside the jail, where dgamelaunch should put mail.
+-#  spooldir = "/var/mail/"
+-#
++  spooldir = "/mail/"
++
+ #  # From inside the jail, the default .nethackrc that is copied for new users.
+-#  # rc_template = "/dgl-default-rcfile"
+-#
++  rc_template = "/etc/dgl-default-rcfile.nh500"
++# Format for writing users' own RC files
++  rc_fmt = "%ruserdata/%n/%n.nh500rc"
++
++#  # Make sure the inprogress dir actually exists. default is "inprogress/"
++#  # Each game you define here must have it's own.
++  inprogressdir = "%rinprogress-nh500/"
++
++# The place where ttyrecs are stored for this game.
++# If this is not defined, ttyrecs are not saved for this game.
++# Leaving this undefined also means the games cannot be spectated.
++  ttyrecdir = "%ruserdata/%n/ttyrec/"
++
+ #  # If player idles longer than max_idle_time seconds, the game will
+ #  # receive a sighup. Default value is 0, which disables the idling timer.
+ #  max_idle_time = 2000
+@@ -229,57 +239,74 @@
+ #  # will be sorted to appear before lower weights.
+ #  # 
+ #  extra_info_file = "%rgamedir/%n.extrainfo"
+-#
+-#  # Make sure the inprogress dir actually exists. default is "inprogress/"
+-#  # Each game you define here must have it's own.
+-#  inprogressdir = "%rinprogress-nethackstub/"
+-#
++
+ #  # We can also define per-game commands, that are executed
+ #  # when the game starts:
+ #  # commands = chdir "/dgldir", mkdir "foo_%u_%g"
+-#
+-#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
+-#  # If set to "ask", the game will be run with --print-charset beforehand,
+-#  # expected to return one of these values.
+-#  encoding = "unicode"
+-#}
++  # back up savefile
++  commands = cp "/var/nh500/save/%u%n.gz" "/var/nh500/save/%u%n.gz.bak",
++  # set NETHACKOPTIONS to point to the rcfile
++             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
++  # set up nethack mail stuff, assuming it's compiled with it...
++             setenv "MAIL" "/mail/%n",
++             setenv "SIMPLEMAIL" "1",
++  # don't let the mail file grow
++             unlink "/mail/%n"
++}
++# Defining it again for the curses option.
++DEFINE {
++  game_path = "/bin/nh500"
++  game_name = "NetHack 5.0.0 (curses)"
++  short_name = "nh500curses"
++  game_args = "/bin/nethackstub", "-u", "%n", "-wcurses"
++  spooldir = "/mail/"
++  rc_template = "/etc/dgl-default-rcfile.nh500"
++  rc_fmt = "%ruserdata/%n/%n.nh500rc"
++  inprogressdir = "%rinprogress-nh500/"
++  ttyrecdir = "%ruserdata/%n/ttyrec/"
++  commands = cp "/var/nh500/save/%u%n.gz" "/var/nh500/save/%u%n.gz.bak",
++             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
++             setenv "MAIL" "/mail/%n",
++             setenv "SIMPLEMAIL" "1",
++             unlink "/mail/%n"
++}
+ #
+ # the second game
+ #
+ #
+-DEFINE {
+-  game_path = "/nh343/nethack"
+-  game_name = "NetHack 3.4.3"
+-  short_name = "NH343"
+-
+-  game_args = "/nh343/nethack", "-u", "%n"
+-
+-  spooldir = "/mail/"
+-  rc_template = "/dgl-default-rcfile.nh343"
+-
+-  rc_fmt = "%ruserdata/%n/%n.nh343rc"
+-
+-  inprogressdir = "%rinprogress-nh343/"
+-
++#DEFINE {
++#  game_path = "/nh343/nethack"
++#  game_name = "NetHack 3.4.3"
++#  short_name = "NH343"
++#
++#  game_args = "/nh343/nethack", "-u", "%n"
++#
++#  spooldir = "/mail/"
++#  rc_template = "/dgl-default-rcfile.nh343"
++#
++#  rc_fmt = "%ruserdata/%n/%n.nh343rc"
++#
++#  inprogressdir = "%rinprogress-nh343/"
++#
+ # The place where ttyrecs are stored for this game.
+ # If this is not defined, ttyrecs are not saved for this game.
+ # Leaving this undefined also means the games cannot be spectated.
+-  ttyrecdir = "%ruserdata/%n/ttyrec/"
+-
+-
++#  ttyrecdir = "%ruserdata/%n/ttyrec/"
++#
++#
+   # back up savefile
+-  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
++#  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
+   # set NETHACKOPTIONS to point to the rcfile
+-             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
++#             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
+   # set up nethack mail stuff, assuming it's compiled with it...
+-             setenv "MAIL" "/mail/%n",
+-             setenv "SIMPLEMAIL" "1",
++#             setenv "MAIL" "/mail/%n",
++#             setenv "SIMPLEMAIL" "1",
+   # don't let the mail file grow
+-             unlink "/mail/%n"
+-}
++#             unlink "/mail/%n"
++#}
+ #
+ # third game
+diff -urB dgamelaunch.bak/examples/dgl_menu_main_user.txt dgamelaunch.new/examples/dgl_menu_main_user.txt
+--- dgamelaunch.bak/examples/dgl_menu_main_user.txt    2020-03-07 06:27:35.000000000 -0500
++++ dgamelaunch.new/examples/dgl_menu_main_user.txt    2026-05-23 03:21:44.601752899 -0400
+@@ -11,8 +11,10 @@
+  c) Change password
+  e) Change email address
+  w) Watch games in progress
+- o) Edit options
+- p) Play NetHack 3.4.3
++ o) Edit options (Virus)
++ O) Edit options (Nano)
++ p) Play NetHack 5.0.0 (curses)
++ P) Play NetHack 5.0.0 (tty)
+  q) Quit
+  =>
index 187d52659b10420a2b08cbef9e7b38618cc958f2..00dca209e50b3e607aaadff73bab3157feff85ad 100644 (file)
@@ -41,10 +41,10 @@ maxnicklen = 10
 #                 ]
 
 # Path to a prepared chroot jail.
-chroot_path = "/opt/nethack/nethack.alt.org/"
+chroot_path = "(:chroot:)"
 
 # From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
-dglroot = "/dgldir/"
+dglroot = "(:var:)/"
 
 # Strings to be replaced in every banner
 # you can have either direct string replacements, like
@@ -63,7 +63,7 @@ bannervars = [ "$MOTDTIME" = "2011.10.08",
 # - $VERSION replaced with "dgamelaunch v" + dgl version number.
 # - $USERNAME replaced with logged-in user's name, or with "[Anonymous]"
 # - $INCLUDE(filename) the named file will be inserted here.
-banner = "/dgl-banner"
+banner = "(:menudir:)/dgl-banner"
 
 # The following two options are fairly insecure. They will force us to
 # load the password/group database into memory while still having root
@@ -203,7 +203,7 @@ filemode = "0666"
 
 # First, the menu shown to anonymous user:
 menu["mainmenu_anon"] {
-        bannerfile = "dgl_menu_main_anon.txt"
+        bannerfile = "(:menudir:)/dgl_menu_main_anon.txt"
         cursor = (5,18)
         commands["l"] = ask_login
         commands["r"] = ask_register
@@ -227,7 +227,7 @@ menu["mainmenu_user"] {
 #       "r" (reverse) or "d" (dim),
 #       or both color number and attribute characters, separated by colon.
 #       Empty param resets color and attributes to default.
-        bannerfile = "dgl_menu_main_user.txt"
+        bannerfile = "(:menudir:)/dgl_menu_main_user.txt"
 # after which cursor is moved to this location
 # if cursor-definition is missing, the cursor is put
 # to the end of the last line of the banner.
@@ -235,18 +235,26 @@ menu["mainmenu_user"] {
 # keys we accept. format is
 #  commands["string_of_keys"] = <commandlist>
 # for example, you could use commands["qQ"] = quit
-        commands["c"] = chpasswd
-        commands["e"] = chmail
-        commands["w"] = watch_menu
-        commands["o"] = ifnxcp "/dgl-default-rcfile.nh343" "%ruserdata/%n/%n.nh343rc",
-                       exec "/bin/virus" "%ruserdata/%n/%n.nh343rc"
-        commands["p"] = play_game "NH343"
+  commands["s"] = chpasswd
+  commands["e"] = chmail
+  commands["w"] = watch_menu
+  commands["o"] = ifnxcp "(:etc:)/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
+      exec "/bin/virus" "%ruserdata/%n/%n.nh500rc"
+#  commands["O"] = ifnxcp "(:etc:)/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
+#      exec "nano" "%ruserdata/%n/%n.nh500rc"
+  commands["p"] = play_game "nh500curses"
+       commands["P"] = play_game "nh500tty"
+# commands["i"] = ifnxcp "/etc/dcss0341/settings/init.txt" "%ruserdata/%n/%n.dcss0341rc",
+#                       exec "/bin/virus" "%ruserdata/%n/%n.dcss0341rc"
+# commands["I"] = ifnxcp "/etc/dcss0341/settings/init.txt" "%ruserdata/%n/%n.dcss0341rc",
+#                       exec "/bin/virus" "%ruserdata/%n/%n.dcss0341rc"
+#      commands["c"] = play_game "dcss0341"
         commands["q"] = quit
 }
 
 # this menu is shown when user presses '?' in the watching menu
 menu["watchmenu_help"] {
-       bannerfile = "dgl_menu_watchmenu_help.txt"
+       bannerfile = "(:menudir:)/dgl_menu_watchmenu_help.txt"
        commands["qQ "] = return
 }
 
@@ -255,33 +263,41 @@ menu["watchmenu_help"] {
 
 # Next, we'll define one game's data:
 
-#DEFINE {
+DEFINE {
 #  # From inside the jail, the location of the binary to be launched.
-#  game_path = "/bin/nethackstub"
-#
+  game_path = "/bin/nh500"
+
+#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
+#  # If set to "ask", the game will be run with --print-charset beforehand,
+#  # expected to return one of these values.
+#  encoding = "unicode"
+
 #  # Full name of the game
-#  game_name = "NetHack stub"
-#
+  game_name = "NetHack 5.0.0 (tty)"
+
 #  # Short name, used in the watching menu
-#  short_name = "NHstb"
-#
-#  # Game ID - should be unique. Defaults to game_name, if not defined.
-#  # Used to determine which game is which for "play_game" and "play_if_exists" commands
-#  game_id = "NHstb"
-#
+  short_name = "nh500tty"
+
 #  # arguments for when we exec the binary
-#  game_args = "/bin/nethackstub",
-#            "foo",
-#            "user:%n",
-#            "shed_uid:%u",
-#            "bar"
-#
+  game_args = "/bin/nh500", "-u", "%n", "-wtty"
+
 #  # From inside the jail, where dgamelaunch should put mail.
-#  spooldir = "/var/mail/"
-#
+  spooldir = "/mail/"
+
 #  # From inside the jail, the default .nethackrc that is copied for new users.
-#  # rc_template = "/dgl-default-rcfile"
-#
+  rc_template = "(:etc:)/dgl-default-rcfile.nh500"
+# Format for writing users' own RC files
+  rc_fmt = "%ruserdata/%n/%n.nh500rc"
+
+#  # Make sure the inprogress dir actually exists. default is "inprogress/"
+#  # Each game you define here must have it's own.
+  inprogressdir = "%rinprogress-nh500tty/"
+
+# The place where ttyrecs are stored for this game.
+# If this is not defined, ttyrecs are not saved for this game.
+# Leaving this undefined also means the games cannot be spectated.
+  ttyrecdir = "%ruserdata/%n/ttyrec/"
+
 #  # If player idles longer than max_idle_time seconds, the game will
 #  # receive a sighup. Default value is 0, which disables the idling timer.
 #  max_idle_time = 2000
@@ -295,24 +311,61 @@ menu["watchmenu_help"] {
 #  # will be sorted to appear before lower weights.
 #  # 
 #  extra_info_file = "%rgamedir/%n.extrainfo"
-#
-#  # Make sure the inprogress dir actually exists. default is "inprogress/"
-#  # Each game you define here must have it's own.
-#  inprogressdir = "%rinprogress-nethackstub/"
-#
+
 #  # We can also define per-game commands, that are executed
 #  # when the game starts:
 #  # commands = chdir "/dgldir", mkdir "foo_%u_%g"
+  # back up savefile
+  commands = cp "(:playground:)/save/%u%n.gz" "(:playground:)/save/%u%n.gz.bak",
+  # set NETHACKOPTIONS to point to the rcfile
+             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
+  # set up nethack mail stuff, assuming it's compiled with it...
+             setenv "MAIL" "/mail/%n",
+             setenv "SIMPLEMAIL" "1",
+  # don't let the mail file grow
+             unlink "/mail/%n"
+
 #
 #  # We can also define per-game commands executed after the game ends,
 #  # but before commands[gameend]
 #  postcommands = chdir "/"
-#
-#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
-#  # If set to "ask", the game will be run with --print-charset beforehand,
-#  # expected to return one of these values.
-#  encoding = "unicode"
-#}
+
+}
+# Defining it again for the curses option.
+DEFINE {
+  game_path = "/bin/nh500"
+  game_name = "NetHack 5.0.0 (curses)"
+  short_name = "nh500curses"
+  game_args = "/bin/nh500", "-u", "%n", "-wcurses"
+  spooldir = "/mail/"
+  rc_template = "(:etc:)/dgl-default-rcfile.nh500"
+  rc_fmt = "%ruserdata/%n/%n.nh500rc"
+  inprogressdir = "%rinprogress-nh500curses/"
+  ttyrecdir = "%ruserdata/%n/ttyrec/"
+  commands = cp "(:playground:)/save/%u%n.gz" "(:playground:)/save/%u%n.gz.bak",
+             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
+             setenv "MAIL" "/mail/%n",
+             setenv "SIMPLEMAIL" "1",
+             unlink "/mail/%n"
+}
+
+# Defining DCSS
+# DEFINE {
+#   game_path = "/bin/crawl"
+#   game_name = "Dungeon Crawl Stone Soup"
+#   short_name = "dcss0341"
+#   game_args = "/bin/crawl", "-name", "%n"
+#   spooldir = "/mail/"
+#   rc_template = "/etc/dcss0341/settings/init.txt"
+#   rc_fmt = "%ruserdata/%n/%n.dcss0341rc"
+#   inprogressdir = "%rinprogress-dcss0341/"
+#   ttyrecdir = "%ruserdata/%n/ttyrec/"
+#   commands = setenv "CRAWL_RC" "@%ruserdata/%n/%n.dcss0341rc",
+#              setenv "MAIL" "/mail/%n",
+#              setenv "SIMPLEMAIL" "1",
+#              unlink "/mail/%n"
+# }
+
 
 #
 # fiqhack example - showing watch mode options
@@ -373,36 +426,36 @@ menu["watchmenu_help"] {
 #
 #
 
-DEFINE {
-  game_path = "/nh343/nethack"
-  game_name = "NetHack 3.4.3"
-  short_name = "NH343"
+#DEFINE {
+#  game_path = "/nh343/nethack"
+#  game_name = "NetHack 3.4.3"
+#  short_name = "NH343"
 
-  game_args = "/nh343/nethack", "-u", "%n"
+#  game_args = "/nh343/nethack", "-u", "%n"
 
-  spooldir = "/mail/"
-  rc_template = "/dgl-default-rcfile.nh343"
+#  spooldir = "/mail/"
+#  rc_template = "(:etc:)/dgl-default-rcfile.nh343"
 
-  rc_fmt = "%ruserdata/%n/%n.nh343rc"
+#  rc_fmt = "%ruserdata/%n/%n.nh343rc"
 
-  inprogressdir = "%rinprogress-nh343/"
+#  inprogressdir = "%rinprogress-nh343/"
 
 # The place where ttyrecs are stored for this game.
 # If this is not defined, ttyrecs are not saved for this game.
 # Leaving this undefined also means the games cannot be spectated.
-  ttyrecdir = "%ruserdata/%n/ttyrec/"
-
-
+#  ttyrecdir = "%ruserdata/%n/ttyrec/"
+#
+#
   # back up savefile
-  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
+#  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
   # set NETHACKOPTIONS to point to the rcfile
-             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
+#             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
   # set up nethack mail stuff, assuming it's compiled with it...
-             setenv "MAIL" "/mail/%n",
-             setenv "SIMPLEMAIL" "1",
+#             setenv "MAIL" "/mail/%n",
+#             setenv "SIMPLEMAIL" "1",
   # don't let the mail file grow
-             unlink "/mail/%n"
-}
+#             unlink "/mail/%n"
+#}
 
 #
 # third game
diff --git a/examples/dgamelaunch.conf.orig b/examples/dgamelaunch.conf.orig
new file mode 100644 (file)
index 0000000..187d526
--- /dev/null
@@ -0,0 +1,450 @@
+# This is a sample dgamelaunch configuration file. Only bash-style comments
+# are allowed, such as this. Each configuration option will be explained
+# along with its default value.
+
+
+
+# Global config variables:
+
+
+# Max amount of registered users to allow. Has no effect if dgl was
+# compiled with SQLite
+maxusers = 64000
+
+# Allow registration of new nicks? (yes or no)
+allow_new_nicks = yes
+
+# Max length for newly registered nicks. Must be less than 20.
+# By default, NetHack only stores the first 10 chars of a name into
+# the record/logfile.
+maxnicklen = 10
+
+# Set the default watching-screen sorting mode. Can be one of
+# "username", "game", "windowsize", "starttime" or "idletime".
+# "username" is the default.
+#sortmode = "username"
+
+# Set the columns displayed in the watching-screen. Each column definition
+# must have four elements as:
+#   [ "<display title>", "<sortname>", <Screen column>, "<printf format>" ]
+#
+# <sortname> may be "unsorted", "username", "game", "windowsize", "starttime",
+# "duration", "idletime", or (if shmem is enabled) "watchers".
+#
+# watch_columns = [ ["", "", 1, "%s)"],
+#                   ["User", "username", 4, "%-15s"],
+#                   ["Game", "game", 21, "%-11s"],
+#                   ["Term", "windowsize", 34, "%s"],
+#                   ["Idle", "idletime", 43, "%-10s"],
+#                   ["Watchers", "watchers", 55, "%5s"],
+#                   ["Started", "starttime", 65, "%s"]
+#                 ]
+
+# Path to a prepared chroot jail.
+chroot_path = "/opt/nethack/nethack.alt.org/"
+
+# From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
+dglroot = "/dgldir/"
+
+# Strings to be replaced in every banner
+# you can have either direct string replacements, like
+# "$FOO" = "BAR", or you can get the server time with
+# "$FOO" = timeformat("%F %T")
+# for the timeformat parameter string format, see man strftime
+bannervars = [ "$MOTDTIME" = "2011.10.08",
+              "$SERVERID" = "$ATTR(14)nethack.alt.org - http://nethack.alt.org/$ATTR()",
+              "$DATETIME" = timeformat("%F %T")
+            ]
+
+# From inside the jail, location of a banner file, which is
+# shown in submenus that cannot be defined separately.
+# Some string substitution is done for every banner file contents:
+# - bannervars from above
+# - $VERSION replaced with "dgamelaunch v" + dgl version number.
+# - $USERNAME replaced with logged-in user's name, or with "[Anonymous]"
+# - $INCLUDE(filename) the named file will be inserted here.
+banner = "/dgl-banner"
+
+# The following two options are fairly insecure. They will force us to
+# load the password/group database into memory while still having root
+# privileges. Replace them with shed_uid/shed_gid entries as soon as
+# possible if you decide to use them. dgamelaunch will inform you of
+# the uids/gids corresponding to your choices when it loads.
+#
+# Note that shed_uid and shed_gid will always take precedence over
+# shed_user and shed_group if they are specified.
+
+# shed_user: username to shed privileges to
+#shed_user = "games"
+# shed_group: group name to shed privileges to
+#shed_group = "games"
+
+# Preferably, you may use the respective gids/uids. This is for Debian:
+shed_uid = 5
+shed_gid = 60
+
+# Locale. Leaving this out, dgamelaunch will not explicitly set locale.
+locale = "en_US.UTF-8"
+
+# Default TERM, used if the user's $TERM is unknown.
+# If undefined, dgamelaunch will just terminate in that case.
+default_term = "xterm"
+
+# Should dgl send select-UTF8-charset escape code? (that is: ESC % G)
+# default is no.
+#utf8esc = yes
+
+# Should dgl allow XON/XOFF? Default is "yes", meaning "don't touch it".
+# "no" disables XON/XOFF
+#flowcontrol = no
+
+# Maximum time in seconds user can idle in the dgamelaunch menus
+# before dgl exits. Default value is 0, which disables the idling timer.
+# Does not apply to external programs or config editors.
+# For setting game idle time, use max_idle_time in the game DEFINE.
+# menu_max_idle_time = 1024
+
+# Passwd refers to the file that stores the user database.
+# The default passwd file is "/dgl-login" for flat-text database, and for
+# sqlite, whatever value was defined for the sqlite database at compile time.
+# This is also used for the shared memory key, if shmem is enabled at compile
+# time.
+#passwd = "/dgl-login"
+
+# Lockfile is used only when dgl was compiled without sqlite.
+#lockfile = "/dgl-lock"
+
+#
+# define some commands that are run when something happens. format is
+# commands [ <time> ] = <command> ...
+#
+# <time> can be one of:
+#   dglstart  = when someone telnets in
+#   login     = when user has logged in
+#   register  = right after a new user is registered
+#   gamestart = just before a game is started
+#   gameend   = after a game ends (see also per-game "postcommand" define)
+#
+# <command> is:
+#   mkdir "foo"        = create a directory "foo"
+#   chdir "foo"        = change current work dir to "foo"
+#   cp "foo" "bar"     = copy file "foo" to "bar", overwriting previous "bar"
+#   ifnxcp "foo" "bar" = copy file "foo" to "bar", if "bar" doesn't exist
+#   unlink "foo"       = delete file "foo"
+#   setenv "foo" "bar" = set environment variable "foo" to "bar"
+#   exec "foo" "bar"   = execute "foo" with "bar" as it's param
+#   rawprint "foo"     = output string "foo"
+#   chpasswd           = do the change password prompting, if logged in
+#   chmail             = do the change email prompting, if logged in
+#   watch_menu         = go to the watching menu
+#   quit               = quit dgl
+#   ask_login          = do the login prompting, if not logged in
+#   ask_register       = do register new user prompting, if not logged in and
+#                        registration of new nicks is allowed.
+#   play_game "foo"    = start game which has the short name "foo"
+#                        (user must be logged in)
+#   play_if_exist "foo" "file" = start game "foo", if file "file" exists.
+#   submenu "foo"      = go to submenu "foo"
+#   return             = return from submenu
+#   sleep "foo"        = sleep for "foo" seconds
+#   ifnxsleep "foo" "file" = sleep for "foo" seconds if file "file" does not exist.
+#
+#  NOTE: edit_options-command was removed. use ifnxcp and exec to simulate it.
+#
+# The commands will be done inside the chroot and with the uid and gid
+# defined above.
+# Parameters to the commands are subject to variable substitution:
+#   %r = dglroot, as defined above
+#   %n = user nick, if user is logged in, or user being watched.
+#   %l = user nick, if logged in, otherwise empty string.
+#   %w = user selected from the watch menu (or logged in user if no user selected)
+#   %N, %L, %W = first character of the above
+#   %u = shed_uid, as defined above, but numeric
+#   %g = game name, if user has selected a game.
+#   %s = short game name, if user has selected a game.
+#   %t = ttyrec path & filename of the last game played.
+#
+# Also some escape codes:
+#   \\ = backslash
+#   \a = bell
+#   \b = backspace
+#   \e = escape character
+#   \f = form feed
+#   \n = newline
+#   \r = carriage return
+#   \t = tab
+#   \v = vertical tab
+#
+# eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo"
+#
+
+# Change the terminal title: (assuming terminals support the escape code)
+#commands[dglstart] = rawprint "\e]2;nethack.alt.org\a"
+
+# create the user's dirs when they register
+commands[register] = mkdir "%ruserdata/%n",
+                     mkdir "%ruserdata/%n/dumplog",
+                     mkdir "%ruserdata/%n/ttyrec"
+
+commands[login] = mkdir "%ruserdata/%n",
+                     mkdir "%ruserdata/%n/dumplog",
+                     mkdir "%ruserdata/%n/ttyrec"
+
+# file mode for when commands copy files.
+# readable and writable by all. you could use eg. "0644" to be more secure.
+filemode = "0666"
+
+
+
+
+# Define the main menus.
+# You _must_ define "mainmenu_anon" and "mainmenu_user".
+# $VERSION and $SERVERID will be replaced, as per the bannerfile above.
+
+# First, the menu shown to anonymous user:
+menu["mainmenu_anon"] {
+        bannerfile = "dgl_menu_main_anon.txt"
+        cursor = (5,18)
+        commands["l"] = ask_login
+        commands["r"] = ask_register
+        commands["w"] = watch_menu
+        commands["q"] = quit
+}
+
+# Then the menu shown when the user has logged in:
+# $USERNAME in here will be replaced with the user name.
+menu["mainmenu_user"] {
+# contents of this file are written to screen.
+# the file must be inside the chroot.
+# Some string subsitutions can be done in the file:
+# $INCLUDE(filename) =  includes the file to this file.
+# String substitutions defined in bannervars-section above.
+# $VERSION           =  dgamelaunch version
+# $USERNAME          =  user name (or [Anonymous] if not logged in)
+# $ATTR(params)      =  change text color and attributes.
+#        params can be either number (to set the text color),
+#       one, or any of "b" (bold), "s" (standout), "u" (underline),
+#       "r" (reverse) or "d" (dim),
+#       or both color number and attribute characters, separated by colon.
+#       Empty param resets color and attributes to default.
+        bannerfile = "dgl_menu_main_user.txt"
+# after which cursor is moved to this location
+# if cursor-definition is missing, the cursor is put
+# to the end of the last line of the banner.
+#        cursor = (5,18)
+# keys we accept. format is
+#  commands["string_of_keys"] = <commandlist>
+# for example, you could use commands["qQ"] = quit
+        commands["c"] = chpasswd
+        commands["e"] = chmail
+        commands["w"] = watch_menu
+        commands["o"] = ifnxcp "/dgl-default-rcfile.nh343" "%ruserdata/%n/%n.nh343rc",
+                       exec "/bin/virus" "%ruserdata/%n/%n.nh343rc"
+        commands["p"] = play_game "NH343"
+        commands["q"] = quit
+}
+
+# this menu is shown when user presses '?' in the watching menu
+menu["watchmenu_help"] {
+       bannerfile = "dgl_menu_watchmenu_help.txt"
+       commands["qQ "] = return
+}
+
+
+
+
+# Next, we'll define one game's data:
+
+#DEFINE {
+#  # From inside the jail, the location of the binary to be launched.
+#  game_path = "/bin/nethackstub"
+#
+#  # Full name of the game
+#  game_name = "NetHack stub"
+#
+#  # Short name, used in the watching menu
+#  short_name = "NHstb"
+#
+#  # Game ID - should be unique. Defaults to game_name, if not defined.
+#  # Used to determine which game is which for "play_game" and "play_if_exists" commands
+#  game_id = "NHstb"
+#
+#  # arguments for when we exec the binary
+#  game_args = "/bin/nethackstub",
+#            "foo",
+#            "user:%n",
+#            "shed_uid:%u",
+#            "bar"
+#
+#  # From inside the jail, where dgamelaunch should put mail.
+#  spooldir = "/var/mail/"
+#
+#  # From inside the jail, the default .nethackrc that is copied for new users.
+#  # rc_template = "/dgl-default-rcfile"
+#
+#  # If player idles longer than max_idle_time seconds, the game will
+#  # receive a sighup. Default value is 0, which disables the idling timer.
+#  max_idle_time = 2000
+#
+#  # Player-specific path to an extra information file written by the game
+#  # The game should write the extra information on one line in this format:
+#  #    <numeric-weight>|extra-information
+#  # For example, the game might write: "100|Astral", "1|D:1", etc. to indicate
+#  # where the player is in the game world. The numeric weight is used when
+#  # a spectator sorts games by the extra information field: higher weights
+#  # will be sorted to appear before lower weights.
+#  # 
+#  extra_info_file = "%rgamedir/%n.extrainfo"
+#
+#  # Make sure the inprogress dir actually exists. default is "inprogress/"
+#  # Each game you define here must have it's own.
+#  inprogressdir = "%rinprogress-nethackstub/"
+#
+#  # We can also define per-game commands, that are executed
+#  # when the game starts:
+#  # commands = chdir "/dgldir", mkdir "foo_%u_%g"
+#
+#  # We can also define per-game commands executed after the game ends,
+#  # but before commands[gameend]
+#  postcommands = chdir "/"
+#
+#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
+#  # If set to "ask", the game will be run with --print-charset beforehand,
+#  # expected to return one of these values.
+#  encoding = "unicode"
+#}
+
+#
+# fiqhack example - showing watch mode options
+#
+#
+
+#DEFINE {
+#  game_path = "/fiqhackdir/fiqhack"
+#  game_name = "FIQHack 4.3.0"
+#  short_name = "fiqhack"
+#
+#  game_args = "/fiqhackdir/fiqhack",
+#              "-H", "/fiqhackdir/data",
+#              "-U", "%ruserdata/%N/%n/fiqhack"
+#
+#  spooldir = "/mail/"
+#  #rc_template = "/dgl-default-rcfile.gh"
+#
+#  #rc_fmt = "%ruserdata/%N/%n/%n.ghrc"
+#
+#  inprogressdir = "%rinprogress-fh/"
+#  extra_info_file = "%rextrainfo-fh/%n.extrainfo"
+#
+#  # The place where ttyrecs are stored for this game.
+#  # If this is not defined, ttyrecs are not saved for this game.
+#  # ttyrecs are not necessary for spectating if watch_path is configured.
+#  ttyrecdir = "%ruserdata/%N/%n/ttyrec/"
+#
+#
+#  commands = setenv "NH4SERVERUSER" "%n",
+#             setenv "NHMAILBOX" "/mail/%n",
+#             setenv "SIMPLEMAIL" "1",
+#             unlink "/mail/%n"
+#
+#  # The executable to use for watching instead of the built-in ttyrec player
+#  watch_path = "/fiqhackdir/fiqhack"
+#
+#  # The args to call it with. As with game_args, argv[0] needs to be included
+#  watch_args = "/fiqhackdir/fiqhack",
+#               "-H", "/fiqhackdir/data",
+#               # we use %n here so anonymous viewers can inherit the config
+#               # of the player. The watch program needs to ensure the watcher
+#               # can't modify anything in here that would affect the player.
+#               "-U", "%ruserdata/%N/%n/fiqhack",
+#               # %w is the player to watch
+#               "-W", "%ruserdata/%W/%w/fiqhack"
+#
+#  # these are run before watching commences.
+#  # Use %l so the watching program knows if the watcher is logged in.
+#  # The watching program should disable mail for anonymous watchers.
+#  watchcommands = setenv "NH4SERVERUSER" "%w",
+#                  setenv "NH4WATCHER" "%l",
+#                  setenv "NHMAILBOX" "/mail/%w"
+#}
+
+#
+# the second game
+#
+#
+
+DEFINE {
+  game_path = "/nh343/nethack"
+  game_name = "NetHack 3.4.3"
+  short_name = "NH343"
+
+  game_args = "/nh343/nethack", "-u", "%n"
+
+  spooldir = "/mail/"
+  rc_template = "/dgl-default-rcfile.nh343"
+
+  rc_fmt = "%ruserdata/%n/%n.nh343rc"
+
+  inprogressdir = "%rinprogress-nh343/"
+
+# The place where ttyrecs are stored for this game.
+# If this is not defined, ttyrecs are not saved for this game.
+# Leaving this undefined also means the games cannot be spectated.
+  ttyrecdir = "%ruserdata/%n/ttyrec/"
+
+
+  # back up savefile
+  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
+  # set NETHACKOPTIONS to point to the rcfile
+             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
+  # set up nethack mail stuff, assuming it's compiled with it...
+             setenv "MAIL" "/mail/%n",
+             setenv "SIMPLEMAIL" "1",
+  # don't let the mail file grow
+             unlink "/mail/%n"
+}
+
+#
+# third game
+#
+#
+
+#DEFINE {
+#  game_path = "/bin/crawlss017"
+#  game_name = "Crawl Stone Soup 0.1.7"
+#  short_name = "Cr017"
+#
+#  game_args = "/bin/crawlss017",
+#            "-name",   "%n",
+#            "-dir",    "/crawlss017/",
+#            "-rc",     "%rrcfiles/%n.crawlrc",
+#            "-morgue", "/crawlss017/morgues/",
+#            "-macro",  "/crawlss017/macros/%n.macro"
+#
+#  rc_template = "/dgl-default-rcfile.crawl"
+#  rc_fmt = "%rrcfiles/%n.crawlrc"
+#  inprogressdir = "%rinprogress-crawlss017/"
+#  encoding = ask
+#}
+
+#
+# fourth game
+#
+#
+
+#DEFINE {
+#  game_path = "/bin/crawlss020"
+#  game_name = "Crawl Stone Soup 0.2.0"
+#  short_name = "Cr020"
+#
+#  game_args = "/bin/crawlss020",
+#            "-name",   "%n",
+#            "-dir",    "/crawlss020/",
+#            "-rc",     "/crawlss020/plr/%n/%n.crawlrc",
+#            "-morgue", "/crawlss020/plr/%n/",
+#            "-macro",  "/crawlss020/plr/%n/"
+#
+#  rc_template = "/dgl-default-rcfile.crawl"
+#  rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"
+#  inprogressdir = "%rinprogress-crawlss020/"
+#}
index ac73438c02527ab7e650d2042fdd9b97ea84fde6..db20831d7bcbfc74a4c6713cb96bf8bbcd924949 100644 (file)
@@ -11,8 +11,9 @@
  c) Change password
  e) Change email address
  w) Watch games in progress
- o) Edit options
- p) Play NetHack 3.4.3
+ o) Edit options (Virus)
+ p) Play NetHack 5.0.0 (curses)
+ P) Play NetHack 5.0.0 (tty)
  q) Quit
 
  =>
diff --git a/examples/dgl_menu_main_user.txt.orig b/examples/dgl_menu_main_user.txt.orig
new file mode 100644 (file)
index 0000000..ac73438
--- /dev/null
@@ -0,0 +1,18 @@
+ ## $SERVERID
+ ##
+ ## $VERSION - network console game launcher
+ ## Copyright (c) 2000-2010 The Dgamelaunch Team
+ ## See http://nethackwiki.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
+ o) Edit options
+ p) Play NetHack 3.4.3
+ q) Quit
+
+ =>
diff --git a/findlibs b/findlibs
new file mode 100644 (file)
index 0000000..a552ee4
--- /dev/null
+++ b/findlibs
@@ -0,0 +1,10 @@
+#/bin/bash
+
+# All of these were written for dgl-create-chroot
+# findlibs from original dgl-create-chroot
+for i in "$@"; do
+  if [ -z "`ldd "$i" | grep 'not a dynamic executable'`" ]; then
+    echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
+    echo $(ldd "$i" | grep 'ld-linux' | awk '{print $1}')
+  fi
+done
diff --git a/install-dgl-nh500 b/install-dgl-nh500
new file mode 100755 (executable)
index 0000000..b757a39
--- /dev/null
@@ -0,0 +1,517 @@
+#!/bin/bash
+
+# install-dgl-nh500
+#
+# Script for setting up Debian DGL/NetHack 5.0.0 environment
+# (hopefully to also set up DCSS 0.34.1 too)
+#
+# You should run this as root.
+#
+# Should be run in the directory it was shipped in.
+#
+# Usage:
+# ./install-dgl-nh500 [options]
+#
+# OPTION [default]                    DESCRIPTION
+# --prefix <dir> [/opt/dgamelaunch]   DGL's chroot. All other locations are
+#                                     relative to this directory! And
+#                                     everything DGL or NetHack need to run
+#                                     is in this directory.
+
+# --var <dir> [/var]                  Location for mutable data. Organized a
+#                                     little strangely in that each game known
+#                                     to dgamelaunch has its own subdirectory,
+#                                     and dgamelaunch's data is just in here.
+
+# --etc <dir> [/etc]                  Location for immutable and config data.
+#                                     Ditto, each game has its own subdirectry.
+#                                     note that NetHack doesn't have one; all
+#                                     of its immutable data lives in hackdir.
+
+# --menudir <dir> [<etc>/menu]         Location for menu files. Really they can
+#                                     be anywhere, but this instructs the
+#                                     script where to put the default ones.
+
+# --hackdir <dir> [/opt/nh500]        NetHack is built wth this as its prefix.
+
+# --playground <dir> [/var/nh500]     NetHack is built with this as its
+#                                     'var playground.'
+
+# --dbfile <sqlite3 db> [<var>/dgamelaunch.db]   The location for the database.
+
+# --nano [FLAG]                       If you set the nano flag, nano will be
+#                                     installed in the chroot, for use as an
+#                                     editor. The default configuration
+#                                     assumes it is "built" with nano.
+
+# --without-nh500 [FLAG]              If you set without-nh500, the script will
+#                                     not install NetHack. Know what you're
+#                                     doing!
+
+# -q -s --quiet --silent [FLAG]       Causes autogen and make to run quietly.
+
+# --clean                [FLAG]       Skips everything except the clean step.
+#                                     Useful if the process gets interrupted...
+
+
+# Here are some settings which would cause nethack and dgl to be installed
+# in a way that reflects the setup instructions provided by Paxed...
+# for posterity and testing.
+#
+# CHROOT="/opt/nethack/nethack.alt.org"
+# DGLVAR="/dgldir"
+# DGLETC="/."
+# MENUDIR="$DGLETC"
+# HACKDIR="/nh500"
+# PLAYGROUND="/nh500/var"
+#
+# ./install-dgl-nh500 --prefix /opt/nethack/nethack.alt.org --var /dgldir --etc /. --menudir /. --hackdir /nh500 --playground /nh500/var
+
+while [[ $# -gt 0 ]]; do
+  case $1 in
+    -h|--help|--usage|-?|--?)
+      printf "`sed -n '3,69p;69q' $0 | tr -d "#"`\n\n"
+      exit 0
+      ;;
+    -q|-s|--quiet|--silent)
+      QUIETMAKE=1
+      shift
+      ;;
+    --prefix)
+      CHROOT="/${2#/}"
+      CHROOT="${CHROOT%/}"
+      shift
+      shift
+      ;;
+    --var)
+      DGLVAR="/${2#/}"
+      DGLVAR="${DGLVAR%/}"
+      shift
+      shift
+      ;;
+    --etc)
+      DGLETC="/${2#/}"
+      DGLETC="${DGLETC%/}"
+      shift
+      shift
+      ;;
+    --menudir)
+      MENUDIR="/${2#/}"
+      MENUDIR="${MENUDIR%/}"
+      shift
+      shift
+      ;;
+    --hackdir)
+      HACKDIR="/${2#/}"
+      HACKDIR="${HACKDIR%/}"
+      shift
+      shift
+      ;;
+    --playground)
+      PLAYGROUND="/${2#/}"
+      PLAYGROUND="${PLAYGROUND%/}"
+      shift
+      shift
+      ;;
+    --dbfile)
+      SQLITE_DBFILE="/${2#/}"
+      SQLITE_DBFILE="${SQLITE_DBFILE%/}"
+      shift
+      shift
+      ;;
+    --nano)
+      DGLNANO="/${2#/}"
+      DGLNANO="${DGLNANO%/}"
+      shift
+      shift
+      ;;
+    # Know what you're doing, or look up a guide on installing NetHack!
+    --without-nh500)
+      NONH=1
+      shift
+      ;;
+    --fetch-dgl)
+      FETCHDGL=1
+      ;;
+    --)
+      set --
+      break
+      ;;
+    -*|--*|*)
+      echo "Unknown option $1"
+      echo "Try $0 --help"
+      exit 1
+      ;;
+  esac
+done
+
+## SETTINGS
+
+# Source repositories and checksums.
+# If you change these, know what you're doing!
+NETHACK500=https://www.nethack.org/download/5.0.0/nethack-500-src.tgz
+NETHACKSHA256=2959b7886aac76185b90aea0c9f80d14343f604de0ae96b3dd2a760f7ab3bde9
+DGL=https://github.com/crawl/dgamelaunch/archive/455308b96fa7522c8c9873653401b4e0cf8f71e4.zip
+
+# Configuration options for DGL.
+# User and group for NetHack and DGL.
+USRGRP="games:games"
+
+# DGL chroot. NetHack is actually installed with prefix '/.', and
+# then moved later; it ultimately lives entirely within the chroot
+# and can't run without it.
+#
+# If you change this here, you will have to change it in <chroot>/etc/dgamelaunch.conf too.
+if [ -z $CHROOT ]; then
+  CHROOT="/opt/dgamelaunch"
+fi
+
+# In theory these would help keep dgamelaunch organized within its own environment.
+#
+# Each directory is within the chroot!
+#
+if [ -z $DGLVAR ]; then
+  DGLVAR="/var"
+fi
+if [ -z $DGLETC ]; then
+  DGLETC="/etc"
+fi
+if [ -z $MENUDIR ]; then
+  MENUDIR="$DGLETC/menu"
+fi
+
+# The path of the sqlite db for users.
+# If this is left undefined (commented out), DGL will be built
+# without sqlite3. Also, it'll probably not work.
+if [ -z $SQLITE_DBFILE ]; then
+  SQLITE_DBFILE="$DGLVAR/dgamelaunch.db"
+fi
+
+# These are baked into the patch files, so if you change them here,
+# change them there also.
+if [ -z $HACKDIR ]; then
+  HACKDIR="/opt/nh500"
+fi
+if [ -z $PLAYGROUND ]; then
+  PLAYGROUND="/var/nh500"
+fi
+if [ -n $NONH ]; then
+  # Disable if you already have NetHack-5.0.0 source downloaded and uncompressed.
+  FETCHNH=1
+  # Disable if you don't want to patch linux.500 and config.h to make life easy.
+  PATCHNH=1
+  # Disable if you already built NetHack-5.0.0 with your preferred settings!
+  BUILDNH=1
+  # Disable if you don't want NetHack to be installed in DGL's root.
+  INSTALLNH=1
+fi
+
+# These are set in the NetHack Makefile, and possibly config.h
+# Note: the Makefile only appears after you run:
+# sys/unix/setup.sh sys/unix/hints/linux.500
+# from inside the NetHack source directory.
+COMPRESSBIN="/bin/gzip"
+GREPBIN="/bin/grep"
+
+# DON'T CHANGE THESE
+WORKDIR="dirname `realpath $0`"
+WORKDIR=`$WORKDIR`
+NETHACKBIN="$HACKDIR/nethack"
+
+
+
+################
+# Some functions
+errorexit() {
+  echo "$@" >&2
+  exit 1
+}
+
+stripsl() {
+  echo "${@#/}"
+}
+
+stripsr() {
+  echo "${@%/}"
+}
+
+standdir() {
+  TMP=`stripsl $@`
+  TMP=`stripsr $TMP`
+  TMP=`echo "$TMP" | tr -d "[:space:]"`
+  echo "$TMP"
+}
+
+# findlibs from original dgl-create-chroot
+findlibs()
+{
+  for i in "$@"; do
+    if [ -z "`ldd "$i" | grep 'not a dynamic executable'`" ]; then
+      echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
+      echo $(ldd "$i" | grep 'ld-linux' | awk '{print $1}')
+    fi
+  done
+}
+
+# cpbin refactored out of original dgl-create-chroot
+cpbin()
+{
+  if [ -e "`which $1`" ]; then
+    NEWDIR=`dirname $1`
+    NEWDIR=`standdir $NEWDIR`
+    echo "Copying $1 to `pwd`/$NEWDIR"
+    mkdir -p "$NEWDIR"
+    cp "`which $1`" "$NEWDIR/"
+    LIBS="$LIBS `findlibs $1`"
+  fi
+}
+
+CHROOT=`standdir $CHROOT`
+DGLVAR=`standdir $DGLVAR`
+DGLETC=`standdir $DGLETC`
+MENUDIR=`standdir $MENUDIR`
+SQLITE_DBFILE=`standdir $SQLITE_DBFILE`
+HACKDIR=`standdir $HACKDIR`
+PLAYGROUND=`standdir $PLAYGROUND`
+COMPRESSBIN=`standdir $COMPRESSBIN`
+GREPBIN=`standdir $GREPBIN`
+NETHACKBIN=`standdir $NETHACKBIN`
+WORKDIR=`standdir $WORKDIR`
+
+
+DEBUG=0
+if [ -z "$DEBUG" -o "$DEBUG" = "0" ]; then # DEBUG
+
+# We'll fetch, patch, build, and install NetHack,
+# then fetch, patch, and build dgamelaunch, then go through the
+# dgl-create-chroot script.
+
+set -e
+
+if [ -n "$QUIETMAKE" ]; then
+  MAKEFLAGS="-s"
+  AUTOGENFLAGS="-q"
+fi
+
+PATCH_ME="dgl-nh500.patch examples/dgamelaunch.conf"
+for i in $PATCH_ME; do
+  cp $i $i.bak
+done
+sed -i -e "s,(:chroot:),"/$CHROOT",g" $PATCH_ME
+sed -i -e "s,(:var:),"/$DGLVAR",g" $PATCH_ME
+sed -i -e "s,(:etc:),"/$DGLETC",g" $PATCH_ME
+sed -i -e "s,(:menudir:),"/$MENUDIR",g" $PATCH_ME
+sed -i -e "s,(:hackdir:),"/$HACKDIR",g" $PATCH_ME
+sed -i -e "s,(:playground:),"/$PLAYGROUND",g" $PATCH_ME
+
+###############
+# Fetch, patch, build, install NetHack
+if [ -n "$FETCHNH" ]; then
+  wget ${NETHACK500} -O ./nethack-500-src.tgz
+  expectsum=${NETHACKSHA256}
+  actualsum=`shasum -a256 ./nethack-500-src.tgz | awk '{ print $1 }'`
+  if [ $actualsum != $expectsum ]; then
+      rm ./nethack-500-src.tgz
+      rm dgamelaunch.zip
+      errorexit 2 "NetHack SHA256 sum is WRONG!!! Edit the script with the right source, or the right checksum."
+  fi
+  tar -xf nethack-500-src.tgz
+fi
+if [ -n "$PATCHNH" -o -n "$BUILDNH" -o -n "$INSTALLNH" ]; then
+  cd NetHack-5.0.0
+fi
+if [ -n "$PATCHNH" ]; then
+  patch -p1 --verbose < "/$WORKDIR/dgl-nh500.patch"
+  sys/unix/setup.sh sys/unix/hints/linux.500
+fi
+if [ -n "$BUILDNH" ]; then
+  make $MAKEFLAGS fetch-lua
+  echo "NOTE: btw, don't worry about these git messages. git doesn't matter."
+  make $MAKEFLAGS all
+fi
+if [ -n "$INSTALLNH" ]; then
+  make $MAKEFLAGS install
+fi
+cd "/$WORKDIR"
+
+###################################
+# Patch, build, install dgamelaunch -- pretty much never used, since this is packaged with dgamelaunch. Unmaintained.
+if [ -n "$FETCHDGL" ]; then
+  wget -O dgamelaunch.zip ${DGL}
+  unzip -q dgamelaunch.zip
+  dglmess="dgamelaunch-`echo "${DGL}" | awk -F/ '{ print $7 }' | awk -F. '{ print $1 }'`"
+  mv "$dglmess" dgamelaunch
+  cd dgamelaunch
+  patch -p1 --verbose < "/$WORKDIR/dgl.patch"
+fi
+
+autoupdate
+if [ -n "$SQLITE_DBFILE" ]; then
+  AUTOGENFLAGS="$AUTOGENFLAGS --enable-sqlite --with-sqlite-db=/$SQLITE_DBFILE"
+fi
+AUTOGENFLAGS="$AUTOGENFLAGS --enable-debugfile --enable-shmem --with-config-file=/$CHROOT/$DGLETC/dgamelaunch.conf --prefix=/$CHROOT"
+MAKEFLAGS="$MAKEFLAGS CFLAGS+=-Wno-implicit-function-declaration"
+echo "Autogen flags: $AUTOGENFLAGS"
+./autogen.sh $AUTOGENFLAGS
+make $MAKEFLAGS
+
+# note to self: do not cd right here
+
+##### dgl-create-chroot ###########################################
+# Run dgl-create-chroot. Rather than patch the script, just building
+# it into this one...
+#
+# Original dgl-create-chroot by joshk@triplehelix.org
+#       modifications by jilles@stack.nl
+# Subsequent modifications by paxed@alt.org
+# Obtained from crawl team at https://github.com/crawl/dgamelaunch
+#      (along with the rest of dgamelaunch)
+# This version by Skyebe, distributed at random
+
+umask 022
+
+if [ -e "/$CHROOT" ]; then
+   errorexit "Chroot /$CHROOT already exists."
+fi
+
+CURDIR="`pwd`"
+CURDIR="`standdir $CURDIR`"
+
+# Create chroot filesystem hierarchy
+mkdir -p "/$CHROOT" || errorexit "Cannot create chroot."
+
+cd "/$CHROOT"
+
+mkdir -p "$MENUDIR" "$DGLVAR" etc var opt lib mail usr bin dev
+mkdir -p "$DGLVAR/inprogress-nh500curses"
+mkdir -p "$DGLVAR/inprogress-nh500tty"
+mkdir -p "$DGLVAR/userdata"
+
+chown -R "$USRGRP" "$DGLVAR" mail
+
+# Create randomness device
+cd dev
+mknod urandom c 1 9
+cd "/$CHROOT"
+echo "We just used mknod! :confetti:"
+
+# Copy DGL files to /etc
+cp "/$CURDIR/examples/dgamelaunch.conf" "$DGLETC"
+[ -f /etc/localtime ] && cp /etc/localtime .
+cp "/$CURDIR/examples/dgl_menu_main_anon.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl_menu_main_user.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl_menu_watchmenu_help.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl-banner" "$MENUDIR"
+cp "/$CURDIR/dgl-default-rcfile" "$DGLETC/dgl-default-rcfile.nh500"
+chmod go+r "$MENUDIR/dgl_menu_main_anon.txt" "$MENUDIR/dgl_menu_main_user.txt" "$MENUDIR/dgl-banner" "$DGLETC/dgl-default-rcfile.nh500"
+
+# Copy extraneous binaries to /bin
+cpbin /$COMPRESSBIN
+cpbin /$GREPBIN
+if [ -n "$DGLNANO" ]; then
+  cpbin /bin/nano
+fi
+cp "/$CURDIR/virus" bin
+
+# Copy NetHack and DGL
+# Remember: we are currently in $CHROOT
+if [ -n "$INSTALLNH" ]; then
+  NHBINFILE="`basename /$NETHACKBIN`.`date +%Y%m%d`"
+  LIBS="$LIBS `findlibs /$NETHACKBIN`"
+  LHACKDIR="`echo "$HACKDIR" | awk -F/ 'BEGIN {OFS=FS} {NF-=1; print}'`"
+  LPLAYGROUND="`echo "$PLAYGROUND" | awk -F/ 'BEGIN {OFS=FS} {NF-=1; print}'`"
+  mkdir -p "$LHACKDIR"
+  mkdir -p "$LPLAYGROUND"
+  cp -r "/$HACKDIR" "$LHACKDIR/"
+  cp "/$NETHACKBIN" "$HACKDIR/$NHBINFILE"
+  ln -s "/$HACKDIR/$NHBINFILE" bin/nh500
+  cp -r "/$PLAYGROUND" "$LPLAYGROUND/"
+  chown -R "$USRGRP" "$HACKDIR"
+  chown -R "$USRGRP" "$PLAYGROUND"
+fi
+
+DGLFILE="dgamelaunch.`date +%Y%m%d`"
+LIBS="$LIBS `findlibs /$CURDIR/dgamelaunch`"
+cp "/$CURDIR/dgamelaunch" "bin/$DGLFILE"
+ln -s "$DGLFILE" bin/dgamelaunch
+# THIS IS IMPORTANT to make watch_games/shmem function
+ln -s /bin/dgamelaunch .
+
+# Creating sqlite db
+if [ -n "$SQLITE_DBFILE" ]; then
+  sqlite3 "/$CHROOT/$SQLITE_DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
+  chown "$USRGRP" "/$CHROOT/$SQLITE_DBFILE"
+fi
+
+# Copying libraries
+LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq`
+for lib in $LIBS; do
+  mkdir -p "/$CHROOT`dirname $lib`"
+  cp $lib "/$CHROOT$lib"
+done
+
+# Curses junk
+if [ -z "$TERMDATA" ]; then
+    SEARCHTERMDATA="/etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo /lib/terminfo"
+    for dir in $SEARCHTERMDATA; do
+       if [ -e "$dir/x/xterm" ]; then
+           TERMDATA="$TERMDATA $dir"
+       fi
+    done
+    if [ -z "$TERMDATA" ]; then
+       errorexit 1 "Couldn't find terminfo definitions. Please specify in 'TERMDATA' variable."
+    fi
+fi
+if [ -n "$TERMDATA" ]; then
+    echo "Copying termdata files from $TERMDATA"
+    for termdat in $TERMDATA; do
+       mkdir -p "/$CHROOT`dirname $termdat`"
+       if [ -d $termdat/. ]; then
+               cp -LR $termdat/. /$CHROOT$termdat
+       else
+               cp $termdat /$CHROOT`dirname $termdat`
+       fi
+    done
+fi
+
+
+fi # DEBUG
+
+# cleanup
+cd "/$WORKDIR"
+RM_ME="NetHack-5.0.0 dgamelaunch.zip nethack-500-src.tgz dgl-nh500.patch \
+  examples/dgamelaunch.conf configure configure.ac .depend Makefile config.h \
+  config.h.in config.log config.status *.o ee virus lex.yy.c y.tab.c y.tab.h"
+if [ -n $INSTALLDGL ]; then
+  RM_ME="$RM_ME dgamelaunch"
+fi
+echo "Removing $RM_ME"
+rm -rf $RM_ME
+mv ./dgl-nh500.patch.bak ./dgl-nh500.patch
+mv ./examples/dgamelaunch.conf.bak ./examples/dgamelaunch.conf
+mv ./configure.ac~ ./configure.ac
+
+HACKDIR=`realpath "/$HACKDIR"`
+PLAYGROUND=`realpath "/$PLAYGROUND"`
+if [ "$HACKDIR" = "/" ]; then
+  cd "$HACKDIR"
+  rm license nethack* nhdat recover symbols sysconf
+else
+  cd `dirname "$HACKDIR"`
+  rm -rf `basename "$HACKDIR"`
+fi
+
+if [ "$PLAYGROUND" = "/" ]; then
+  cd "$PLAYGROUND"
+  rm -rf livelog logfile perm record save/ xlogfile
+else
+  cd `dirname "$PLAYGROUND"`
+  rm -rf `basename "$PLAYGROUND"`
+fi
+
+rm /nethack
+
+echo "Finished."
+
+
+
diff --git a/sanepath b/sanepath
new file mode 100644 (file)
index 0000000..836ba6c
--- /dev/null
+++ b/sanepath
@@ -0,0 +1,5 @@
+#!/bin/bash
+# Squashes slashes, and removes trailing ones
+
+tmp="`echo $1 | tr -s /`"
+echo ${tmp%/}