commit
67140d743a
10 changed files with 790 additions and 0 deletions
@ -0,0 +1,4 @@ |
||||
**/data |
||||
**/dgldir/ |
||||
**/nethack_var/ |
||||
**/sshd_host_keys/ |
@ -0,0 +1,88 @@ |
||||
FROM debian:stable-slim as build |
||||
|
||||
ARG nethack_version=3.6.6 |
||||
|
||||
RUN apt-get update -y |
||||
|
||||
RUN apt-get install -y gcc make flex bison build-essential git libncurses5-dev wget autotools-dev autoconf sqlite3 libsqlite3-dev |
||||
|
||||
# Build dgamelaunch |
||||
WORKDIR / |
||||
|
||||
RUN git clone git://github.com/paxed/dgamelaunch.git |
||||
|
||||
WORKDIR dgamelaunch |
||||
|
||||
RUN ./autogen.sh --enable-sqlite --enable-shmem --with-config-file=/opt/nethack/nethack.jerryaldrichiii.com/etc/dgamelaunch.conf |
||||
|
||||
RUN make |
||||
|
||||
COPY dgl-create-chroot.sh dgl-create-chroot.sh |
||||
RUN sh dgl-create-chroot.sh |
||||
|
||||
WORKDIR /opt/nethack/nethack.jerryaldrichiii.com/ |
||||
|
||||
# Copy libs needed at runtime |
||||
RUN cp /lib/x86_64-linux-gnu/libncurses.so.6 lib/x86_64-linux-gnu/ |
||||
RUN cp /lib/x86_64-linux-gnu/libnss_files.so.2 lib/x86_64-linux-gnu/libnss_files.so.2 |
||||
|
||||
COPY dgamelaunch.conf etc/dgamelaunch.conf |
||||
|
||||
# Build Nethack |
||||
WORKDIR / |
||||
RUN wget https://github.com/NetHack/NetHack/archive/NetHack-${nethack_version}_Released.tar.gz |
||||
|
||||
RUN tar xvzf NetHack*.tar.gz |
||||
|
||||
WORKDIR NetHack-NetHack-${nethack_version}_Released |
||||
|
||||
COPY ./hints.sh hints.sh |
||||
|
||||
RUN sh sys/unix/setup.sh hints.sh |
||||
|
||||
RUN make && make install |
||||
|
||||
# TODO: Add a custom sysconf? https://nethackwiki.com/wiki/Sysconf |
||||
RUN cp -R /root/nethack/chroot/nethack/* /opt/nethack/nethack.jerryaldrichiii.com/nethack |
||||
RUN chown games:games /opt/nethack/nethack.jerryaldrichiii.com/nethack/sysconf |
||||
|
||||
# Could probably use alpine..but I'm too lazy to trackdown libc/musl errors |
||||
FROM debian:stable-slim |
||||
|
||||
LABEL maintainer "jerryaldrichiii@gmail.com" |
||||
|
||||
RUN apt-get update && apt-get install -y openssh-server && apt-get clean |
||||
|
||||
COPY --from=build /opt/nethack/nethack.jerryaldrichiii.com/ /opt/nethack/nethack.jerryaldrichiii.com |
||||
RUN cp -R /opt/nethack/nethack.jerryaldrichiii.com/dgldir /opt/nethack/nethack.jerryaldrichiii.com/dgldir.orig |
||||
RUN cp -R /opt/nethack/nethack.jerryaldrichiii.com/nethack/var /opt/nethack/nethack.jerryaldrichiii.com/nethack_var.orig |
||||
RUN cp /opt/nethack/nethack.jerryaldrichiii.com/usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu/ |
||||
COPY dgl_menu_main_user.txt /opt/nethack/nethack.jerryaldrichiii.com/ |
||||
|
||||
RUN useradd --no-create-home --gid 60 --shell /opt/nethack/nethack.jerryaldrichiii.com/dgamelaunch nethack |
||||
RUN passwd -d nethack |
||||
|
||||
RUN chown -R nethack:games /opt/nethack/nethack.jerryaldrichiii.com/nethack |
||||
|
||||
# If you figure out how to make this run without suid or root...let me know |
||||
RUN chmod 4755 /opt/nethack/nethack.jerryaldrichiii.com/dgamelaunch |
||||
|
||||
COPY entrypoint.sh /entrypoint.sh |
||||
RUN chmod +x /entrypoint.sh |
||||
|
||||
# Configure SSHD |
||||
RUN mkdir -p /srv/sshd/host_keys |
||||
COPY sshd_config /srv/sshd/sshd_config |
||||
RUN chown -R nethack /srv/sshd |
||||
RUN cp /etc/passwd /opt/nethack/nethack.jerryaldrichiii.com/etc |
||||
RUN chown nethack /etc/shadow |
||||
|
||||
EXPOSE 2323 |
||||
|
||||
VOLUME ["/opt/nethack/nethack.jerryaldrichiii.com/dgldir"] |
||||
VOLUME ["/opt/nethack/nethack.jerryaldrichiii.com/nethack/var"] |
||||
VOLUME ["/srv/sshd/host_keys"] |
||||
|
||||
USER nethack |
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"] |
@ -0,0 +1,33 @@ |
||||
# nethack-server via dgamelaunch + Docker |
||||
|
||||
## Setup |
||||
|
||||
Create SSHD host keys (optional): |
||||
|
||||
``` |
||||
mkdir bootstrap |
||||
ssh-keygen -N '' -t rsa -f data/sshd_host_keys/sshd_host_rsa_key |
||||
``` |
||||
|
||||
Run the server: |
||||
|
||||
``` |
||||
docker build . -t replaceme/nethack-server:latest |
||||
|
||||
# These directories will contain your persistent data |
||||
mkdir -p data/{dgldir,nethack_var,sshd_host_keys} |
||||
sudo chown -R 1000:60 data |
||||
|
||||
docker run -it --rm \ |
||||
-p 2222:2222 \ |
||||
-v $(pwd)/data/dgldir:/opt/nethack/nethack.jerryaldrichiii.com/dgldir \ |
||||
-v $(pwd)/data/nethack_var:/opt/nethack/nethack.jerryaldrichiii.com/nethack/var \ |
||||
-v $(pwd)/data/sshd_host_keys:/srv/sshd/host_keys \ |
||||
replaceme/nethack-server:latest |
||||
``` |
||||
|
||||
# Forgive me |
||||
|
||||
This was a weekend project...it could use some work. |
||||
|
||||
See: TODO.md |
@ -0,0 +1,341 @@ |
||||
# 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.jerryaldrichiii.com/" |
||||
|
||||
# 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.jerryaldrichiii.com$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 = 1000 |
||||
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 |
||||
# |
||||
# 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 |
||||
# %N = first character of user name, if user is logged in |
||||
# %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.nh" "%ruserdata/%n/%n.nhrc", |
||||
exec "/bin/virus" "%ruserdata/%n/%n.nhrc" |
||||
commands["p"] = play_game "NH" |
||||
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 { |
||||
game_path = "/nethack/nethack" |
||||
game_name = "NetHack" |
||||
short_name = "NH" |
||||
|
||||
game_args = "/nethack/nethack", "-u", "%n" |
||||
|
||||
spooldir = "/mail/" |
||||
rc_template = "/dgl-default-rcfile.nh" |
||||
|
||||
rc_fmt = "%ruserdata/%n/%n.nhrc" |
||||
|
||||
inprogressdir = "%rinprogress-nh/" |
||||
|
||||
# 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 "/nethack/var/save/%u%n.gz" "/nethack/var/save/%u%n.gz.bak", |
||||
# set NETHACKOPTIONS to point to the rcfile |
||||
setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nhrc", |
||||
# 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" |
||||
} |
||||
|
||||
# |
||||
# the second game |
||||
# |
||||
# |
||||
|
||||
#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" |
||||
#} |
@ -0,0 +1,221 @@ |
||||
#!/bin/sh |
||||
|
||||
# Ideas and some parts from the original dgl-create-chroot (by joshk@triplehelix.org, modifications by jilles@stack.nl) |
||||
# This one by paxed@alt.org then jerryaldrichiii@gmail.com |
||||
# |
||||
# configure dgl with --with-config-file=/path_to_chroot/etc/dgamelaunch.conf, if you want the conf file inside the chroot. |
||||
# |
||||
|
||||
# Same as chroot_path in dgl config file |
||||
CHROOT="/opt/nethack/nethack.jerryaldrichiii.com/" |
||||
# the user & group from dgamelaunch config file. |
||||
USRGRP="games:games" |
||||
# COMPRESS from include/config.h; the compression binary to copy. leave blank to skip. |
||||
COMPRESSBIN="/bin/gzip" |
||||
# nethack binary to copy into chroot (leave blank to skip) |
||||
#NETHACKBIN="/root/nethack/chroot/nethack/nethack" |
||||
# fixed data to copy (leave blank to skip) |
||||
#NH_PLAYGROUND_FIXED="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh/" |
||||
# HACKDIR from include/config.h; aka nethack subdir inside chroot |
||||
NHSUBDIR="/nethack/" |
||||
# VAR_PLAYGROUND from include/unixconf.h |
||||
NH_VAR_PLAYGROUND="/nethack/var/" |
||||
|
||||
# only define this if dgl was configured with --enable-sqlite |
||||
SQLITE_DBFILE="/dgldir/dgamelaunch.db" |
||||
|
||||
# END OF CONFIG |
||||
############################################################################## |
||||
|
||||
errorexit() |
||||
{ |
||||
echo "Error: $@" >&2 |
||||
exit 1 |
||||
} |
||||
|
||||
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 |
||||
} |
||||
|
||||
############################################################################## |
||||
|
||||
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 "Couldn't find terminfo definitions. Please specify in 'TERMDATA' variable." |
||||
fi |
||||
fi |
||||
|
||||
|
||||
|
||||
# remove trailing slash, if any |
||||
CHROOT="`echo ${CHROOT%/}`" |
||||
|
||||
set -e |
||||
umask 022 |
||||
|
||||
if [ -e "$CHROOT" ]; then |
||||
errorexit "Chroot $CHROOT already exists." |
||||
fi |
||||
|
||||
CURDIR="`pwd`" |
||||
|
||||
if [ ! -e "$CURDIR/dgamelaunch" ]; then |
||||
errorexit "Cannot find dgamelaunch in $CURDIR" |
||||
fi |
||||
|
||||
DGLFILE="dgamelaunch.`date +%Y%m%d`" |
||||
|
||||
echo "Setting up chroot in $CHROOT" |
||||
|
||||
LIBS="`findlibs dgamelaunch`" |
||||
|
||||
mkdir -p "$CHROOT" || errorexit "Cannot create chroot" |
||||
cd "$CHROOT" |
||||
mkdir dgldir etc lib mail usr bin |
||||
chown "$USRGRP" dgldir mail |
||||
cp "$CURDIR/dgamelaunch" "$DGLFILE" |
||||
ln -s "$DGLFILE" dgamelaunch |
||||
|
||||
mkdir -p "$CHROOT/dgldir/inprogress-nh" |
||||
mkdir -p "$CHROOT/dgldir/userdata" |
||||
chown "$USRGRP" "$CHROOT/dgldir/inprogress-nh" |
||||
chown "$USRGRP" "$CHROOT/dgldir/userdata" |
||||
|
||||
|
||||
if [ -n "$SQLITE_DBFILE" ]; then |
||||
if [ "x`which sqlite3`" = "x" ]; then |
||||
errorexit "No sqlite3 found." |
||||
else |
||||
echo "Creating SQLite database at $SQLITE_DBFILE" |
||||
SQLITE_DBFILE="`echo ${SQLITE_DBFILE%/}`" |
||||
SQLITE_DBFILE="`echo ${SQLITE_DBFILE#/}`" |
||||
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 |
||||
fi |
||||
|
||||
|
||||
if [ -n "$COMPRESSBIN" -a -e "`which $COMPRESSBIN`" ]; then |
||||
COMPRESSDIR="`dirname $COMPRESSBIN`" |
||||
COMPRESSDIR="`echo ${COMPRESSDIR%/}`" |
||||
COMPRESSDIR="`echo ${COMPRESSDIR#/}`" |
||||
echo "Copying $COMPRESSBIN to $COMPRESSDIR" |
||||
mkdir -p "$COMPRESSDIR" |
||||
cp "`which $COMPRESSBIN`" "$COMPRESSDIR/" |
||||
LIBS="$LIBS `findlibs $COMPRESSBIN`" |
||||
fi |
||||
|
||||
|
||||
mkdir -p dev |
||||
cd dev |
||||
mknod urandom c 1 9 |
||||
cd .. |
||||
|
||||
|
||||
cd etc |
||||
cp "$CURDIR/examples/dgamelaunch.conf" . |
||||
echo "Edit $CHROOT/etc/dgamelaunch.conf to suit your needs." |
||||
[ -f /etc/localtime ] && cp /etc/localtime . |
||||
cd .. |
||||
|
||||
|
||||
cd bin |
||||
cp "$CURDIR/ee" . |
||||
cp "$CURDIR/virus" . |
||||
echo "Copied text editors 'ee' and 'virus' to chroot." |
||||
cd .. |
||||
|
||||
|
||||
cp "$CURDIR/examples/dgl_menu_main_anon.txt" . |
||||
cp "$CURDIR/examples/dgl_menu_main_user.txt" . |
||||
cp "$CURDIR/examples/dgl_menu_watchmenu_help.txt" . |
||||
cp "$CURDIR/examples/dgl-banner" . |
||||
cp "$CURDIR/dgl-default-rcfile" "dgl-default-rcfile.nh" |
||||
chmod go+r dgl_menu_main_anon.txt dgl_menu_main_user.txt dgl-banner dgl-default-rcfile.nh |
||||
|
||||
NHSUBDIR="`echo ${NHSUBDIR%/}`" |
||||
NHSUBDIR="`echo ${NHSUBDIR#/}`" |
||||
|
||||
mkdir "$CHROOT/$NHSUBDIR" |
||||
|
||||
if [ -n "$NETHACKBIN" -a ! -e "$NETHACKBIN" ]; then |
||||
errorexit "Cannot find NetHack binary $NETHACKBIN" |
||||
fi |
||||
|
||||
if [ -n "$NETHACKBIN" -a -e "$NETHACKBIN" ]; then |
||||
echo "Copying $NETHACKBIN" |
||||
cd "$NHSUBDIR" |
||||
NHBINFILE="`basename $NETHACKBIN`.`date +%Y%m%d`" |
||||
cp "$NETHACKBIN" "$NHBINFILE" |
||||
ln -s "$NHBINFILE" nethack |
||||
LIBS="$LIBS `findlibs $NETHACKBIN`" |
||||
cd "$CHROOT" |
||||
fi |
||||
|
||||
|
||||
NH_PLAYGROUND_FIXED="`echo ${NH_PLAYGROUND_FIXED%/}`" |
||||
|
||||
if [ -n "$NH_PLAYGROUND_FIXED" -a -d "$NH_PLAYGROUND_FIXED" ]; then |
||||
echo "Copying NetHack playground stuff." |
||||
NHFILES="*.lev *.dat cmdhelp data dungeon help hh history license opthelp options oracles recover rumors wizhelp" |
||||
for fil in $NHFILES; do |
||||
cp $NH_PLAYGROUND_FIXED/$fil "$CHROOT/$NHSUBDIR/" |
||||
done |
||||
fi |
||||
|
||||
|
||||
NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND%/}`" |
||||
NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND#/}`" |
||||
|
||||
echo "Creating NetHack variable dir stuff." |
||||
if [ -n "$NH_VAR_PLAYGROUND" ]; then |
||||
mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND" |
||||
chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND" |
||||
fi |
||||
mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND/save" |
||||
chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND/save" |
||||
touch "$CHROOT/$NH_VAR_PLAYGROUND/logfile" |
||||
touch "$CHROOT/$NH_VAR_PLAYGROUND/perm" |
||||
touch "$CHROOT/$NH_VAR_PLAYGROUND/record" |
||||
touch "$CHROOT/$NH_VAR_PLAYGROUND/xlogfile" |
||||
|
||||
chown -R "$USRGRP" "$CHROOT/$NHSUBDIR" |
||||
chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND" |
||||
|
||||
|
||||
|
||||
# Curses junk |
||||
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 |
||||
|
||||
|
||||
LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq` |
||||
echo "Copying libraries:" $LIBS |
||||
for lib in $LIBS; do |
||||
mkdir -p "$CHROOT`dirname $lib`" |
||||
cp $lib "$CHROOT$lib" |
||||
done |
||||
|
||||
|
||||
echo "Finished." |
@ -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 |
||||
q) Quit |
||||
|
||||
=> |
@ -0,0 +1,30 @@ |
||||
#!/bin/sh |
||||
|
||||
set -e |
||||
|
||||
CHROOTDIR=/opt/nethack/nethack.jerryaldrichiii.com |
||||
|
||||
# Copy dgldir on initial run |
||||
if [ ! -d $CHROOTDIR/dgldir/userdata ]; then |
||||
echo "No dgldir detected, copying from image" |
||||
# Need archive here to get original attributes |
||||
cp -a $CHROOTDIR/dgldir.orig/* $CHROOTDIR/dgldir/ |
||||
fi |
||||
|
||||
# Copy nethack/var on initial run |
||||
if [ ! -d $CHROOTDIR/nethack/var/save ]; then |
||||
echo "No nethack_var detected, copying from image" |
||||
# Need archive here to get original attributes |
||||
cp -a $CHROOTDIR/nethack_var.orig/* $CHROOTDIR/nethack/var |
||||
fi |
||||
|
||||
mkdir -p /srv/sshd/host_keys |
||||
if [ ! -f /srv/sshd/host_keys/sshd_host_rsa_key ]; then |
||||
echo "No SSHD host key found at /srv/sshd/host_keys/sshd_host_rsa_key" |
||||
printf "Generating SSHD host key pair" |
||||
ssh-keygen -N '' -t rsa -f /srv/sshd/host_keys/sshd_host_rsa_key |
||||
chmod 400 /srv/sshd/host_keys/sshd_host_rsa_key |
||||
echo "SSHD host key pair generated successfully" |
||||
fi |
||||
|
||||
/usr/sbin/sshd -f /srv/sshd/sshd_config -De |
@ -0,0 +1,41 @@ |
||||
#-PRE |
||||
# Linux hints file |
||||
# This hints file provides a chrooted build for Linux, specifically |
||||
# for Ubuntu dapper. |
||||
# Does not copy required libraries or termcap files into the chroot. |
||||
|
||||
COMPILEREVISION?=1 |
||||
|
||||
# this is the chroot dir |
||||
PREFIX=$(wildcard ~)/nethack/chroot |
||||
|
||||
# this is the dir where NetHack is inside the chroot |
||||
HACKDIR=/nethack |
||||
INSTDIR=$(PREFIX)$(HACKDIR) |
||||
SHELLDIR=$(PREFIX)/games |
||||
VARDIR=$(INSTDIR)/var |
||||
|
||||
POSTINSTALL=cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf; |
||||
CFLAGS1=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\" |
||||
CFLAGS=-g -O -I../include -DNOTPARMDECL $(CFLAGS1) -DDLB |
||||
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE |
||||
CFLAGS+=-DTIMED_DELAY |
||||
CFLAGS+=-DHACKDIR=\"$(HACKDIR)\" |
||||
CFLAGS+=-DVAR_PLAYGROUND=\"$(HACKDIR)/var\" |
||||
|
||||
LINK=$(CC) |
||||
# Only needed for GLIBC stack trace: |
||||
LFLAGS=-rdynamic |
||||
|
||||
WINSRC = $(WINTTYSRC) |
||||
WINOBJ = $(WINTTYOBJ) |
||||
WINLIB = $(WINTTYLIB) |
||||
|
||||
WINTTYLIB=-lncurses -ltinfo |
||||
|
||||
CHOWN=true |
||||
CHGRP=true |
||||
|
||||
VARDIRPERM = 0755 |
||||
VARFILEPERM = 0600 |
||||
GAMEPERM = 0755 |
@ -0,0 +1,13 @@ |
||||
Port 2222 |
||||
|
||||
PermitRootLogin no |
||||
PermitEmptyPasswords yes |
||||
AllowAgentForwarding no |
||||
AllowTcpForwarding no |
||||
PermitTTY yes |
||||
X11Forwarding no |
||||
PrintMotd no |
||||
|
||||
PidFile /srv/sshd/sshd.pid |
||||
|
||||
HostKey /srv/sshd/host_keys/sshd_host_rsa_key |
Loading…
Reference in new issue