6 changed files with 57 additions and 3 deletions
			
			
		@ -0,0 +1,28 @@
					 | 
				
			||||
#!/bin/bash | 
				
			||||
HACKDIR=$1 | 
				
			||||
USERDIR=$2 | 
				
			||||
 | 
				
			||||
### | 
				
			||||
# clean old ttyrecs | 
				
			||||
### | 
				
			||||
cd /$HACKDIR/user/$USERDIR/ttyrec/ | 
				
			||||
ls -1tr | head -n -10 | xargs -d '\n' rm -f -- | 
				
			||||
 | 
				
			||||
 | 
				
			||||
### | 
				
			||||
# clean sotw files | 
				
			||||
### | 
				
			||||
cd /$HACKDIR/user/$USERDIR/sotw/ | 
				
			||||
 | 
				
			||||
# there are always 4 symlinked files | 
				
			||||
# leave 5 of the latest dumps | 
				
			||||
 | 
				
			||||
FILES=$(ls -1tr *.txt | head -n -9) | 
				
			||||
 | 
				
			||||
for f in $FILES; do | 
				
			||||
  #test -h $f || echo "removing old file $f" | 
				
			||||
  if [ ! -h $f ]; then | 
				
			||||
    echo "removing old file $f" | 
				
			||||
    rm -rf $f | 
				
			||||
  fi | 
				
			||||
done | 
				
			||||
@ -0,0 +1,19 @@
					 | 
				
			||||
package main | 
				
			||||
 | 
				
			||||
import ( | 
				
			||||
	"fmt" | 
				
			||||
	"os/exec" | 
				
			||||
) | 
				
			||||
 | 
				
			||||
func runCleanup(username string) { | 
				
			||||
	// clean up ttyrecs in /<hackdir>/user/<username>/ttyrec/
 | 
				
			||||
	// clean up sotw dumps, aka:
 | 
				
			||||
	// non-symlinked .txt files in /<hackdir>/user/<username>/sotw/
 | 
				
			||||
 | 
				
			||||
	// run cleanup file
 | 
				
			||||
	out, err := exec.Command("/bin/clean.sh", config.NethackLauncher.HackDir, username).Output() | 
				
			||||
	if err != nil { | 
				
			||||
		fmt.Println(err) | 
				
			||||
	} | 
				
			||||
	fmt.Printf("%s\n", out) | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue