# 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.

# 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 = 20

# Set the default watching-screen sorting mode. Can be one of
# "username", "game", "windowsize", "starttime" or "idletime".
# "username" is the default.
sortmode = "username"

# Maximum idle time in menus
menu_max_idle_time = 3600

# Path to a prepared chroot jail.
chroot_path = "/home/paxed/hacking/coding/dgamelaunch/chroot/"

# From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
dglroot = "/dgldir/"

# Server ID string
server_id = "CDO - Dungeon Crawl Stone Soup - http://crawl.develz.org"

# 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 = "/dgldir/data/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.
shed_uid = 2002
shed_gid = 1010

# The defaults are usually just fine for this. passwd refers to the file
# that stores the user database, and lockfile is only used internally by
# dgamelaunch.
# passwd doesn't matter if dgl was compiled with SQLite, as the name of
# the sqlite database will be defined at compile time.
passwd = "/dgldir/data/dgl-login"
lockfile = "/dgldir/data/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
#
# <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
#   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.
#   edit_options "foo" = edit options for game which has the short name "foo"
#                        (user must be logged in)
#   play_game "foo"    = start game which has the short name "foo"
#                        (user must be logged in)
#   submenu "foo"      = go to submenu "foo"
#   return             = return from submenu
#
# 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
#   %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.
#
# eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo"
#

commands[register] = mkdir "%rttyrec/%n"
commands[login] = mkdir "%rttyrec/%n",
    ifnxcp "%rdata/dgl-default.crawl-svn.macro" "%rrcfiles/crawl-svn/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-svn.rc" "%rrcfiles/crawl-svn/%n.rc",
    ifnxcp "%rdata/dgl-default.crawl-rel.macro" "%rrcfiles/crawl-rel/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-rel.rc" "%rrcfiles/crawl-rel/%n.rc",
    ifnxcp "%rdata/dgl-default.crawl-old.macro" "%rrcfiles/crawl-old/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-old.rc" "%rrcfiles/crawl-old/%n.rc",
    ifnxcp "%rdata/dgl-default.crawl-spr.macro" "%rrcfiles/crawl-spr/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-spr.rc" "%rrcfiles/crawl-spr/%n.rc",
    ifnxcp "%rdata/dgl-default.crawl-anc.macro" "%rrcfiles/crawl-anc/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-anc.rc" "%rrcfiles/crawl-anc/%n.rc"

menu["mainmenu_anon"] {
  bannerfile = "/dgldir/data/menus/main_anon.txt"
  # cursor = (5,18)
  commands["lL"] = ask_login
  commands["rR"] = ask_register
  commands["wW"] = watch_menu
  commands["qQ"] = quit
}

menu["mainmenu_user"] {
  bannerfile = "/dgldir/data/menus/main_user.txt"
  commands["cC"] = chpasswd
  commands["eE"] = chmail
  commands["wW"] = watch_menu
  commands["1"] = submenu "crawl-svn"
  commands["2"] = submenu "crawl-rel"
  commands["3"] = submenu "crawl-old"
  commands["4"] = submenu "crawl-anc"
  commands["5"] = submenu "crawl-spr"
  commands["pP"] = play_game "dcss-svn"
  commands["qQ"] = quit
}

menu["watchmenu_help"] {
	bannerfile = "/dgldir/data/menus/watchmenu_help.txt"
	commands["qQ "] = return
}

menu["crawl-svn"] {
  bannerfile = "/dgldir/data/menus/crawl_svn.txt"
  commands["o"] = exec "ee" "%rrcfiles/crawl-svn/%n.rc"
  commands["O"] = exec "virus" "%rrcfiles/crawl-svn/%n.rc"
  commands["m"] = exec "ee" "%rrcfiles/crawl-svn/%n.macro"
  commands["M"] = exec "virus" "%rrcfiles/crawl-svn/%n.macro"
  commands["v"] = exec "ee" "/crawl-svn/docs/crawl_changelog.txt"
  commands["V"] = exec "virus" "/crawl-svn/docs/crawl_changelog.txt"
  commands["pP"] = play_game "dcss-svn"
  commands["A"] = submenu "crawl-svn-adv"
  commands["wW"] = watch_menu
  commands["qQ"] = return
}

menu["crawl-rel"] {
  bannerfile = "/dgldir/data/menus/crawl_rel.txt"
  commands["o"] = exec "ee" "%rrcfiles/crawl-rel/%n.rc"
  commands["O"] = exec "virus" "%rrcfiles/crawl-rel/%n.rc"
  commands["m"] = exec "ee" "%rrcfiles/crawl-rel/%n.macro"
  commands["M"] = exec "virus" "%rrcfiles/crawl-rel/%n.macro"
  commands["v"] = exec "ee" "/crawl-rel/docs/crawl_changelog.txt"
  commands["V"] = exec "virus" "/crawl-rel/docs/crawl_changelog.txt"
  commands["pP"] = play_game "dcss-rel"
  commands["A"] = submenu "crawl-rel-adv"
  commands["wW"] = watch_menu
  commands["qQ"] = return
}

menu["crawl-old"] {
  bannerfile = "/dgldir/data/menus/crawl_old.txt"
  commands["o"] = exec "ee" "%rrcfiles/crawl-old/%n.rc"
  commands["O"] = exec "virus" "%rrcfiles/crawl-old/%n.rc"
  commands["m"] = exec "ee" "%rrcfiles/crawl-old/%n.macro"
  commands["M"] = exec "virus" "%rrcfiles/crawl-old/%n.macro"
  commands["v"] = exec "ee" "/crawl-old/docs/crawl_changelog.txt"
  commands["V"] = exec "virus" "/crawl-old/docs/crawl_changelog.txt"
  commands["pP"] = play_game "dcss-old"
  commands["A"] = submenu "crawl-old-adv"
  commands["wW"] = watch_menu
  commands["qQ"] = return
}

menu["crawl-spr"] {
  bannerfile = "/dgldir/data/menus/crawl_spr.txt"
  commands["o"] = exec "ee" "%rrcfiles/crawl-spr/%n.rc"
  commands["O"] = exec "virus" "%rrcfiles/crawl-spr/%n.rc"
  commands["m"] = exec "ee" "%rrcfiles/crawl-spr/%n.macro"
  commands["M"] = exec "virus" "%rrcfiles/crawl-spr/%n.macro"
  commands["v"] = exec "ee" "/crawl-spr/docs/crawl_changelog.txt"
  commands["V"] = exec "virus" "/crawl-spr/docs/crawl_changelog.txt"
  commands["pP"] = play_game "dcss-spr"
  commands["A"] = submenu "crawl-spr-adv"
  commands["wW"] = watch_menu
  commands["qQ"] = return
}

menu["crawl-anc"] {
  bannerfile = "/dgldir/data/menus/crawl_anc.txt"
  commands["o"] = exec "ee" "%rrcfiles/crawl-anc/%n.rc"
  commands["O"] = exec "virus" "%rrcfiles/crawl-anc/%n.rc"
  commands["m"] = exec "ee" "%rrcfiles/crawl-anc/%n.macro"
  commands["M"] = exec "virus" "%rrcfiles/crawl-anc/%n.macro"
  commands["pP"] = play_game "dc-anc"
  commands["A"] = submenu "crawl-anc-adv"
  commands["wW"] = watch_menu
  commands["qQ"] = return
}

menu["crawl-svn-adv"] {
  bannerfile = "/dgldir/data/menus/crawl_svn_adv.txt"
  commands["B"] =
    exec "savegame-backup-svn.sh" "%n",
    return
  commands["O"] =
    cp "%rdata/dgl-default.crawl-svn.rc" "%rrcfiles/crawl-svn/%n.rc",
    return
  commands["M"] =
    cp "%rdata/dgl-default.crawl-svn.macro" "%rrcfiles/crawl-svn/%n.macro",
    return
  commands["qQ"] = return
}

menu["crawl-rel-adv"] {
  bannerfile = "/dgldir/data/menus/crawl_rel_adv.txt"
  commands["B"] =
    exec "savegame-backup-rel.sh" "%n",
    return
  commands["O"] =
    cp "%rdata/dgl-default.crawl-rel.rc" "%rrcfiles/crawl-rel/%n.rc",
    return
  commands["M"] =
    cp "%rdata/dgl-default.crawl-rel.macro" "%rrcfiles/crawl-rel/%n.macro",
    return
  commands["qQ"] = return
}

menu["crawl-old-adv"] {
  bannerfile = "/dgldir/data/menus/crawl_old_adv.txt"
  commands["B"] =
    exec "savegame-backup-old.sh" "%n",
    return
  commands["O"] =
    cp "%rdata/dgl-default.crawl-old.rc" "%rrcfiles/crawl-old/%n.rc",
    return
  commands["M"] =
    cp "%rdata/dgl-default.crawl-old.macro" "%rrcfiles/crawl-old/%n.macro",
    return
  commands["qQ"] = return
}

menu["crawl-spr-adv"] {
  bannerfile = "/dgldir/data/menus/crawl_spr_adv.txt"
  commands["B"] =
    exec "savegame-backup-spr.sh" "%n",
    return
  commands["O"] =
    cp "%rdata/dgl-default.crawl-spr.rc" "%rrcfiles/crawl-spr/%n.rc",
    return
  commands["M"] =
    cp "%rdata/dgl-default.crawl-spr.macro" "%rrcfiles/crawl-spr/%n.macro",
    return
  commands["qQ"] = return
}

menu["crawl-anc-adv"] {
  bannerfile = "/dgldir/data/menus/crawl_anc_adv.txt"
  commands["O"] =
    cp "%rdata/dgl-default.crawl-anc.rc" "%rrcfiles/crawl-anc/%n.rc",
    return
  commands["M"] =
    cp "%rdata/dgl-default.crawl-anc.macro" "%rrcfiles/crawl-anc/%n.macro",
    return
  commands["qQ"] = return
}

DEFINE {
  game_path = "/bin/crawl-svn"
  game_name = "Stone Soup pre-0.6"
  short_name = "dcss-svn"

  game_args = "/bin/crawl-svn",
    "-name", "%n",
    "-rc", "%rrcfiles/crawl-svn/%n.rc",
    "-macro", "%rrcfiles/crawl-svn/%n.macro",
    "-morgue", "/crawl-svn/morgue/%n"

  max_idle_time = 3600

  spooldir = "/var/mail/"

  rc_template = "/dgldir/data/dgl-default.crawl-svn.rc"
  rc_fmt = "%rrcfiles/crawl-svn/%n.rc"

  inprogressdir = "%rinprogress/crawl-svn/"

  ttyrecdir = "%rttyrec/%n/"

  commands =
    ifnxcp "%rdata/dgl-default.crawl-svn.macro" "%rrcfiles/crawl-svn/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-svn.rc" "%rrcfiles/crawl-svn/%n.rc",
    setenv "MAIL" "/var/mail/%n",
    setenv "SIMPLEMAIL" "1",
    unlink "/var/mail/%n"
}

DEFINE {
  game_path = "/bin/crawl-rel"
  game_name = "Stone Soup 0.5.2+"
  short_name = "dcss-rel"

  game_args = "/bin/crawl-rel",
    "-name", "%n",
    "-rc", "%rrcfiles/crawl-rel/%n.rc",
    "-macro", "%rrcfiles/crawl-rel/%n.macro",
    "-morgue", "/crawl-rel/morgue/%n"

  max_idle_time = 3600

  spooldir = "/var/mail/"

  rc_template = "/dgldir/data/dgl-default.crawl-rel.rc"
  rc_fmt = "%rrcfiles/crawl-rel/%n.rc"

  inprogressdir = "%rinprogress/crawl-rel/"

  ttyrecdir = "%rttyrec/%n/"

  commands =
    ifnxcp "%rdata/dgl-default.crawl-rel.macro" "%rrcfiles/crawl-rel/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-rel.rc" "%rrcfiles/crawl-rel/%n.rc",
    setenv "MAIL" "/var/mail/%n",
    setenv "SIMPLEMAIL" "1",
    unlink "/var/mail/%n"
}

DEFINE {
  game_path = "/bin/crawl-old"
  game_name = "Stone Soup 0.4.5+"
  short_name = "dcss-old"

  game_args = "/bin/crawl-old",
    "-name", "%n",
    "-rc", "%rrcfiles/crawl-old/%n.rc",
    "-macro", "%rrcfiles/crawl-old/%n.macro",
    "-morgue", "/crawl-old/morgue/%n"

  max_idle_time = 3600

  spooldir = "/var/mail/"

  rc_template = "/dgldir/data/dgl-default.crawl-old.rc"
  rc_fmt = "%rrcfiles/crawl-old/%n.rc"

  inprogressdir = "%rinprogress/crawl-old/"

  ttyrecdir = "%rttyrec/%n/"

  commands =
    ifnxcp "%rdata/dgl-default.crawl-old.macro" "%rrcfiles/crawl-old/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-old.rc" "%rrcfiles/crawl-old/%n.rc",
    setenv "MAIL" "/var/mail/%n",
    setenv "SIMPLEMAIL" "1",
    unlink "/var/mail/%n"
}

DEFINE {
  game_path = "/bin/crawl-spr-starter"
  game_name = "Dungeon Sprint #1"
  short_name = "dcss-spr"

  game_args = "/bin/crawl-spr-starter",
    "-name", "%n",
    "-rc", "%rrcfiles/crawl-spr/%n.rc",
    "-macro", "%rrcfiles/crawl-spr/%n.macro",
    "-morgue", "/crawl-spr/morgue/%n"

  max_idle_time = 3600

  spooldir = "/var/mail/"

  rc_template = "/dgldir/data/dgl-default.crawl-spr.rc"
  rc_fmt = "%rrcfiles/crawl-spr/%n.rc"

  inprogressdir = "%rinprogress/crawl-spr/"

  ttyrecdir = "%rttyrec/%n/"

  commands =
    ifnxcp "%rdata/dgl-default.crawl-spr.macro" "%rrcfiles/crawl-spr/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-spr.rc" "%rrcfiles/crawl-spr/%n.rc",
    setenv "MAIL" "/var/mail/%n",
    setenv "SIMPLEMAIL" "1",
    unlink "/var/mail/%n"
}

DEFINE {
  game_path = "/bin/crawl-anc"
  game_name = "Dungeon Crawl 4.1.2a"
  short_name = "dc-anc"

  game_args = "/bin/crawl-anc",
    "-name", "%n",
    "-dir", "%rrcfiles/crawl-anc/",
    "-rc", "%n.rc",
    "-macro", "%n.macro",
    "-morgue", "/crawl-anc/morgue/%n"

  max_idle_time = 3600

  spooldir = "/var/mail/"

  rc_template = "/dgldir/data/dgl-default.crawl-anc.rc"
  rc_fmt = "%rrcfiles/crawl-anc/%n.rc"

  inprogressdir = "%rinprogress/crawl-anc/"

  ttyrecdir = "%rttyrec/%n/"

  commands =
    ifnxcp "%rdata/dgl-default.crawl-anc.macro" "%rrcfiles/crawl-anc/%n.macro",
    ifnxcp "%rdata/dgl-default.crawl-anc.rc" "%rrcfiles/crawl-anc/%n.rc",
    mkdir "/crawl-anc/morgue/%n",
    setenv "MAIL" "/var/mail/%n",
    setenv "SIMPLEMAIL" "1",
    unlink "/var/mail/%n"
}

