diff --git a/Makefile b/Makefile index 0b8600b..a6666bb 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ stat: dependencies: go get github.com/gorilla/mux -build_docker: +build_docker: fetch_sotw mkdir -p stage.tmp/ cp deps/Dockerfile stage.tmp/ cp config.gcfg stage.tmp/config.gcfg @@ -49,6 +49,11 @@ build_docker: cd stage.tmp/ && \ $(OS_PERMS) docker build -t $(IMAGE_NAME) . +fetch_sotw: + mkdir -p stage.tmp/ + wget https://cryo.unixvoid.com/bin/misc/sotw/shadow-of-the-wyrm-release-1.1.2.tar.gz + mv shadow-of-the-wyrm-release-1.1.2.tar.gz stage.tmp/sotw.tar.gz + run_docker: $(OS_PERMS) docker run \ -d \ diff --git a/config.gcfg b/config.gcfg index 7ff46cc..031e5b5 100644 --- a/config.gcfg +++ b/config.gcfg @@ -6,6 +6,8 @@ nhdatlocation = "/NetHack/dat/nhdat" recoverbinary = "/NetHack/util/recover" sysconflocation = "/NetHack/sys/unix/sysconf" + sotwversion = "1.1.2" + sotwroot = "/sotw" bootstrapdelay = 1 [redis] diff --git a/deps/Dockerfile b/deps/Dockerfile index 597351e..e7b9754 100644 --- a/deps/Dockerfile +++ b/deps/Dockerfile @@ -1,4 +1,4 @@ -FROM debian +FROM debian:stretch # install needed packages RUN apt-get update && \ @@ -8,6 +8,7 @@ RUN apt-get update && \ autoconf \ bison \ bsdmainutils \ + bzip2 \ flex \ gcc \ gdb \ @@ -15,14 +16,24 @@ RUN apt-get update && \ groff \ libncursesw5-dev \ libsqlite3-dev \ + libboost1.62-dev \ + libboost-all-dev \ + libncurses5-dev \ + libncursesw5-dev \ + lua5.1 \ + liblua5.1-0-dev \ + libsdl2-dev \ + libxerces-c-dev \ make \ ncurses-dev \ + premake4 \ sqlite3 \ tar \ telnetd \ xinetd \ locales \ - git \ + wget \ + zlibc \ vim RUN apt-get clean @@ -96,5 +107,7 @@ COPY run.sh / COPY chowner.sh /bin/ COPY nethackrc /.nethackrc COPY run_nethack.sh / +ADD sotw.tar.gz / +RUN mv /shadow-of-the-wyrm* /sotw/ CMD ["/run.sh"] diff --git a/deps/chowner.sh b/deps/chowner.sh index 01db8ae..859025a 100755 --- a/deps/chowner.sh +++ b/deps/chowner.sh @@ -2,7 +2,12 @@ while : do + # chown nethack directory chown -R nethack:nethack /hack 2> /dev/null chmod -R 744 /hack 2> /dev/null + + # chown + chown -R nethack:nethack /sotw 2> /dev/null + chmod -R 744 /sotw 2> /dev/null sleep 2 done diff --git a/nethack-launcher/nethack-launcher.go b/nethack-launcher/nethack-launcher.go index a3c8aa1..891817f 100644 --- a/nethack-launcher/nethack-launcher.go +++ b/nethack-launcher/nethack-launcher.go @@ -20,6 +20,8 @@ type Config struct { NhdatLocation string RecoverBinary string SysconfLocation string + SotwVersion string + SotwRoot string BootstrapDelay time.Duration } diff --git a/nethack-launcher/print_user_screen.go b/nethack-launcher/print_user_screen.go index e4be8d8..33f97f1 100644 --- a/nethack-launcher/print_user_screen.go +++ b/nethack-launcher/print_user_screen.go @@ -23,6 +23,7 @@ func printUserScreen(redisClient *redis.Client, username string) string { println(" e) Edit config") println(" r) Recover from crash") fmt.Printf(" p) Play NetHack %s\n", config.NethackLauncher.NethackVersion) + fmt.Printf(" o) Play Shadow of the Wyrm %s\n", config.NethackLauncher.SotwVersion) println(" q) Quit") println("") fmt.Printf(">> ") @@ -73,6 +74,15 @@ func printUserScreen(redisClient *redis.Client, username string) string { wg.Wait() close(watcher) printUserScreen(redisClient, username) + case "o": + wg.Add(1) + currentTime := time.Now().UTC() + fulltime := currentTime.Format("2006-01-02.03:04:05") + go runSotwGame(username, fulltime) + watcher := startWatcher(username, fulltime, redisClient) + wg.Wait() + close(watcher) + printUserScreen(redisClient, username) case "r": clearScreen() recoverSave(redisClient, username) diff --git a/nethack-launcher/run_game.go b/nethack-launcher/run_game.go index 779c339..ddf38ca 100644 --- a/nethack-launcher/run_game.go +++ b/nethack-launcher/run_game.go @@ -40,6 +40,28 @@ func runGame(username, timestamp string) { wg.Done() } +func runSotwGame(username, timestamp string) { + exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() + clearScreen() + + // put together users home dir + //homeDir := fmt.Sprintf("%s/user/%s/", config.NethackLauncher.HackDir, username) + ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp) + + nh := exec.Command("ttyrec", "-f", ttyrecPath, "--", "./ShadowOfTheWyrm") + //nh := exec.Command("./ShadowOfTheWyrm") + nh.Dir = (config.NethackLauncher.SotwRoot) + nh.Stdout = os.Stdout + nh.Stdin = os.Stdin + nh.Stderr = os.Stderr + err := nh.Run() + if err != nil { + fmt.Print(err) + } + exec.Command("exit").Run() + wg.Done() +} + func runtimeRecover(username string) { fmt.Printf(" %s\n", config.NethackLauncher.ServerDisplay) println("")