From: sbkelley Date: Sat, 23 May 2026 23:57:54 +0000 (-0400) Subject: Merge branch 'dev' X-Git-Tag: v1.6.1-roc-dev~6^2~22 X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=e2d114fcec0c601670f34425ccd3f04e872149d3;p=dgamelaunch Merge branch 'dev' (cherry picked from commit dc9c243e4ce81a1c78f54a33b3831f7662c1ce0c) --- diff --git a/README b/README deleted file mode 100644 index 0ffeba8..0000000 --- a/README +++ /dev/null @@ -1,320 +0,0 @@ -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: - -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: - -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: - -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. - -sudo chmod a+s /opt/dgamelaunch/bin/dgamelaunch. - -Replace 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: - -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: - -nethack:x:::nethack,1,1,1,1:/home/nethack:/bin/bash - -You need to modify the new user's line like so: - -nethack:x:::nethack,1,1,1,1:/home/nethack:/opt/dgamelaunch/bin/dgamelaunch. - -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... - -More resources for troubleshooting vis NetHack: -https://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch - -See also the old readme below. - -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 NOWIZARD=1 -3) navigate to the directory with these scripts (dgamelaunch source dir) -4) ./cpbin -b /bin /bin/crawl /opt/dgamelaunch -5) sudo cp /etc/dcss0341 /opt/dgamelaunch/etc/ -6) sudo cp /var/dcss0341 /opt/dgamelaunch/var/ -7) (clean up in /bin/crawl, /etc/dcss0341, /var/dcss0341 if you want to; don't need those files anymore) -8) Modify dgamelaunch.conf to uncomment relevant lines -9) sudo mkdir /opt/dgamelaunch/var/inprogress-dcss0341 -10) modify the main menu (or apply dcss-menu.patch to it) - -That's it! - - -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 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 - 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 index 0000000..2ecc7ef --- /dev/null +++ b/README.bak @@ -0,0 +1,246 @@ +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 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 + 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 index 0000000..c17a528 --- /dev/null +++ b/README.md @@ -0,0 +1,158 @@ +The main feature of this fork of dgamelaunch is install-dgl-nh500, which automates installation of NetHack inside +a dgamelaunch chroot. + +# install-dgl-nh500 documentation +```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 [/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 [/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 [/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 [/etc/menu] Location for menu files. Really they can +# be anywhere, but this instructs the +# script where to put the default ones. + +# --hackdir [/opt/nh500] NetHack is built wth this as its prefix. + +# --playground [/var/nh500] NetHack is built with this as its +# 'var playground.' + +# --dbfile [/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. + +# -q -s --quiet --silent [FLAG] Causes autogen and make to run quietly. + + +# 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 +``` + +# 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. +``` + +Replace 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:::nethack,1,1,1,1:/home/nethack:/bin/bash +``` + +You need to modify the new user's line like so: + +```bash +nethack:x:::nethack,1,1,1,1:/home/nethack:/opt/dgamelaunch/bin/dgamelaunch. +``` + +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... + +More resources for troubleshooting vis NetHack: +https://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch + + +# 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 NOWIZARD=1` +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! \ No newline at end of file diff --git a/dgl-nh500.patch b/dgl-nh500.patch index b3decf3..140f8a9 100644 --- a/dgl-nh500.patch +++ b/dgl-nh500.patch @@ -15,7 +15,7 @@ diff -urB NetHack-5.0.0.bak/include/config.h NetHack-5.0.0/include/config.h */ #ifndef HACKDIR -#define HACKDIR "/usr/games/lib/nethackdir" -+#define HACKDIR "/opt/nh500" ++#define HACKDIR "(:hackdir:)" #endif /* @@ -27,7 +27,7 @@ diff -urB NetHack-5.0.0.bak/include/unixconf.h NetHack-5.0.0/include/unixconf.h * system, define VAR_PLAYGROUND to be where the variable parts are kept. */ -/* #define VAR_PLAYGROUND "/var/lib/games/nethack" */ -+#define VAR_PLAYGROUND "/var/nh500" ++#define VAR_PLAYGROUND "(:playground:)" /* * Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more" @@ -74,7 +74,7 @@ diff -urB NetHack-5.0.0.bak/sys/unix/hints/linux.500 NetHack-5.0.0/sys/unix/hint -HACKDIR=$(PREFIX)/games/lib/nethackdir -SHELLDIR = $(PREFIX)/games +PREFIX=/. -+HACKDIR=$(PREFIX)/opt/nh500 ++HACKDIR=$(PREFIX)(:hackdir:) +SHELLDIR = $(PREFIX) VARDIRPERM = 0755 VARFILEPERM = 0600 @@ -83,7 +83,7 @@ diff -urB NetHack-5.0.0.bak/sys/unix/hints/linux.500 NetHack-5.0.0/sys/unix/hint INSTDIR=$(HACKDIR) -VARDIR = $(HACKDIR) -+VARDIR = $(PREFIX)/var/nh500 ++VARDIR = $(PREFIX)(:playground:) ifdef MAKEFILE_TOP TESTGDBPATH=/usr/bin/gdb diff --git a/install-dgl-nh500 b/install-dgl-nh500 index ec5b34b..7ea46d0 100644 --- a/install-dgl-nh500 +++ b/install-dgl-nh500 @@ -1,11 +1,149 @@ #!/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 [/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 [/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 [/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 [/menu] Location for menu files. Really they can +# be anywhere, but this instructs the +# script where to put the default ones. + +# --hackdir [/opt/nh500] NetHack is built wth this as its prefix. + +# --playground [/var/nh500] NetHack is built with this as its +# 'var playground.' + +# --dbfile [/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. + + +# 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,65p;65q' $0 | tr -d "#"`" + 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="${CDGLETC%/}" + 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 "Valid options are: --install-nh500, --nano, --quiet|--silent, --prefix , --var , --etc , --menudir , --hackdir , --playground " + exit 1 + ;; + *) + break # (treat this as $1) + ;; + esac +done ## SETTINGS @@ -15,32 +153,6 @@ NETHACK500=https://www.nethack.org/download/5.0.0/nethack-500-src.tgz NETHACKSHA256=2959b7886aac76185b90aea0c9f80d14343f604de0ae96b3dd2a760f7ab3bde9 DGL=https://github.com/crawl/dgamelaunch/archive/455308b96fa7522c8c9873653401b4e0cf8f71e4.zip -# If this thing ain't working, and you can't figure out why, try disabling -# the -s flag to make by commenting out this line. It won't fix anything, -# but there might be some tell-tale warnings or errors. -QUIETMAKE=1 - -# If you downloaded NetHack yourself, and have applied dgl-nh500.patch etc, -# then comment these lines out to skip fetching/patching. -# Skipping patch step also skips running /sys/unix/setup.sh; -# so know what you're doing, or look up a guide on installing NetHack! - -# 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 - -# If you got this script already bundled with DGL, this should already be -# disabled. -#FETCHDGL=1 - -# Install nano in chroot/bin -DGLNANO=1 - # Configuration options for DGL. # User and group for NetHack and DGL. USRGRP="games:games" @@ -50,25 +162,49 @@ USRGRP="games:games" # and can't run without it. # # If you change this here, you will have to change it in /etc/dgamelaunch.conf too. -CHROOT="/opt/dgamelaunch" +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! # -DGLVAR="/var" -DGLETC="/etc" -MENUDIR="$DGLETC/menu" +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. - SQLITE_DBFILE="$DGLVAR/dgamelaunch.db" +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. -HACKDIR="/opt/nh500" -PLAYGROUND="/var/nh500" +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: @@ -81,17 +217,6 @@ GREPBIN="/bin/grep" WORKDIR="`pwd`" NETHACKBIN="$HACKDIR/nethack" -# 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 mostly. If you uncomment these, you will have to also modify -# some of the patch files, and dgamelaunch.conf. -# -#CHROOT="/opt/nethack/nethack.alt.org" -#DGLVAR="/dgldir" -#DGLETC="/." -#MENUDIR="$DGLETC" -#HACKDIR="/nh500" -#PLAYGROUND="/nh500/var" ################ @@ -157,10 +282,23 @@ WORKDIR=`standdir $WORKDIR` # 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 @@ -192,7 +330,7 @@ fi cd "/$WORKDIR" ################################### -# Patch, build, install dgamelaunch +# 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 @@ -272,15 +410,16 @@ 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}'`" - cp -r "/$HACKDIR" "$LHACKDIR" + cp -r "/$HACKDIR" "./$LHACKDIR" cp "$NETHACKBIN" "$HACKDIR/$NHBINFILE" ln -s "/$HACKDIR/$NHBINFILE" bin/nh500 - cp -r "/$PLAYGROUND" "$LPLAYGROUND" + cp -r "/$PLAYGROUND" "./$LPLAYGROUND" chown -R "$USRGRP" "$HACKDIR" chown -R "$USRGRP" "$PLAYGROUND" fi @@ -330,7 +469,7 @@ fi # cleanup cd "/$WORKDIR" -RM_ME="/opt/nh500 /var/nh500 NetHack-5.0.0 dgamelaunch.zip nethack-500-src.tgz" +RM_ME="$HACKDIR $PLAYGROUND NetHack-5.0.0 dgamelaunch.zip nethack-500-src.tgz" if [ -n $INSTALLDGL ]; then RM_ME="$RM_ME dgamelaunch" fi