Browse Source

Add parameters for save file caching

pull/1/head
Matthew Faltys 5 years ago
parent
commit
ee891cd615
  1. 2
      config.gcfg
  2. 7
      deps/clean.sh
  3. 2
      nethack-launcher/cleanup.go
  4. 2
      nethack-launcher/nethack-launcher.go

2
config.gcfg

@ -6,8 +6,10 @@
nhdatlocation = "/NetHack/dat/nhdat"
recoverbinary = "/NetHack/util/recover"
sysconflocation = "/NetHack/sys/unix/sysconf"
ttyreccache = "10"
sotwversion = "1.1.7"
sotwroot = "/sotw"
sotwdumpcache = "5"
bootstrapdelay = 1
[redis]

7
deps/clean.sh vendored

@ -1,12 +1,14 @@
#!/bin/bash
HACKDIR=$1
USERDIR=$2
TTYRECCACHE=$3
SOTWDUMPCACHE=$4
###
# clean old ttyrecs
###
cd /$HACKDIR/user/$USERDIR/ttyrec/
ls -1tr | head -n -10 | xargs -d '\n' rm -f --
ls -1tr | head -n -$TTYRECCACHE | xargs -d '\n' rm -f --
###
@ -16,8 +18,9 @@ cd /$HACKDIR/user/$USERDIR/sotw/
# there are always 4 symlinked files
# leave 5 of the latest dumps
DUMPFILES=$(expr $SOTWDUMPCACHE + 4)
FILES=$(ls -1tr *.txt | head -n -9)
FILES=$(ls -1tr *.txt | head -n -$DUMPFILES)
for f in $FILES; do
#test -h $f || echo "removing old file $f"

2
nethack-launcher/cleanup.go

@ -11,7 +11,7 @@ func runCleanup(username string) {
// non-symlinked .txt files in /<hackdir>/user/<username>/sotw/
// run cleanup file
out, err := exec.Command("/bin/clean.sh", config.NethackLauncher.HackDir, username).Output()
out, err := exec.Command("/bin/clean.sh", config.NethackLauncher.HackDir, username, config.NethackLauncher.TTYRecCache, config.NethackLauncher.SotwDumpCache).Output()
if err != nil {
fmt.Println(err)
}

2
nethack-launcher/nethack-launcher.go

@ -20,8 +20,10 @@ type Config struct {
NhdatLocation string
RecoverBinary string
SysconfLocation string
TTYRecCache string
SotwVersion string
SotwRoot string
SotwDumpCache string
BootstrapDelay time.Duration
}

Loading…
Cancel
Save