Browse Source

Add first time setup nethackrc logic

master
Matthew Faltys 5 years ago
parent
commit
5a897706a3
  1. 2
      deps/Dockerfile
  2. 18
      nethack-launcher.go

2
deps/Dockerfile vendored

@ -45,7 +45,7 @@ COPY nethack-launcher /
COPY redis.conf /
COPY run.sh /
COPY chowner.sh /bin/
COPY nethackrc /hack/.nethackrc
COPY nethackrc /.nethackrc
COPY run_nethack.sh /
CMD ["/run.sh"]

18
nethack-launcher.go

@ -570,6 +570,24 @@ func createInitialFiles() {
if _, err := os.Stat(fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir)); os.IsNotExist(err) {
exec.Command("cp", config.NethackLauncher.NhdatLocation, config.NethackLauncher.HackDir).Run()
}
// make sure initial rcfile exists
hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir)
if _, err := os.Stat(hackRCLoc); os.IsNotExist(err) {
fmt.Printf("initial config file not found at: %s\n", hackRCLoc)
fmt.Printf("%s\n", err)
// check root and move in if applicable
if _, err := os.Stat("/.nethackrc"); os.IsNotExist(err) {
fmt.Printf("initial config file not found at root\n")
fmt.Printf("%s\n", err)
os.Exit(1)
} else {
// move nethackrc file to proper location
exec.Command("cp", "/.nethackrc", config.NethackLauncher.HackDir).Run()
}
}
}
func janitor(redisClient *redis.Client) {

Loading…
Cancel
Save