Browse Source

Add ovh-ttyrec fuctionality to fix ttyrec bug

master
Matthew Faltys 5 years ago
parent
commit
79bfc3523e
  1. 16
      deps/Dockerfile
  2. 17
      nethack-launcher.go

16
deps/Dockerfile vendored

@ -3,11 +3,12 @@ FROM debian
# install needed packages # install needed packages
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \ DEBIAN_FRONTEND=noninteractive apt-get install -y \
ttyrec \
termrec \
nethack-console \ nethack-console \
redis-server \ redis-server \
openssh-server \ openssh-server \
g++ \
make \
git \
vim vim
# make required dirs # make required dirs
@ -27,6 +28,17 @@ RUN useradd hack -d / -s /nethack-launcher
RUN echo 'hack:U6aMy0wojraho' | chpasswd -e RUN echo 'hack:U6aMy0wojraho' | chpasswd -e
RUN chown -R hack /hack/ RUN chown -R hack /hack/
# build ttyrec
RUN git clone https://github.com/ovh/ovh-ttyrec && \
cd ovh-ttyrec && \
./configure && make && make install
# remove ttyrec artifacts
RUN rm -rf ovh-ttyrec/
RUN DEBIAN_FRONTEND=noninteractive apt-get remove -y\
make \
git
# copy in files # copy in files
COPY config.gcfg / COPY config.gcfg /
COPY nethack-launcher / COPY nethack-launcher /

17
nethack-launcher.go

@ -441,8 +441,8 @@ func printProgressScreen(redisClient *redis.Client, username string) {
// restart display // restart display
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run()
clearScreen() clearScreen()
//nh := exec.Command("ttyplay", "-p", ttyrecPath) nh := exec.Command("ttyplay", "-p", ttyrecPath)
nh := exec.Command("termplay", "-f", "live", ttyrecPath) //nh := exec.Command("termplay", "-f", "live", ttyrecPath)
nh.Stdout = os.Stdout nh.Stdout = os.Stdout
nh.Stdin = os.Stdin nh.Stdin = os.Stdin
nh.Stderr = os.Stderr nh.Stderr = os.Stderr
@ -458,14 +458,14 @@ func printProgressScreen(redisClient *redis.Client, username string) {
} }
func runGame(username, timestamp string) { func runGame(username, timestamp string) {
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run()
clearScreen()
// put together users home dir // put together users home dir
homeDir := fmt.Sprintf("%s/user/%s/", config.NethackLauncher.HackDir, username) homeDir := fmt.Sprintf("%s/user/%s/", config.NethackLauncher.HackDir, username)
ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp) ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp)
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run()
clearScreen() nh := exec.Command("ttyrec", "-f", ttyrecPath, "--", "nethack")
//nh := exec.Command("ttyrec", ttyrecPath, "-e", "nethack")
nh := exec.Command("termrec", ttyrecPath, "-e", "nethack")
//nh := exec.Command("termrec", ttyrecPath, "-e", "nethack")
nh.Env = os.Environ() nh.Env = os.Environ()
nh.Env = append(nh.Env, fmt.Sprintf("HOME=%s", homeDir)) nh.Env = append(nh.Env, fmt.Sprintf("HOME=%s", homeDir))
nh.Env = append(nh.Env, fmt.Sprintf("USER=%s", username)) nh.Env = append(nh.Env, fmt.Sprintf("USER=%s", username))
@ -477,9 +477,6 @@ func runGame(username, timestamp string) {
if err != nil { if err != nil {
fmt.Print(err) fmt.Print(err)
} }
fmt.Printf("%v\n", nh.Stdout)
fmt.Printf("%v\n", nh.Stdin)
fmt.Printf("%v\n", nh.Stderr)
exec.Command("exit").Run() exec.Command("exit").Run()
wg.Done() wg.Done()
} }

Loading…
Cancel
Save