Browse Source

Add file checking

Remove reclist
master
Matthew Faltys 5 years ago
parent
commit
6740664fc3
  1. 7
      Makefile
  2. 2
      config.gcfg
  3. 1
      deps/Dockerfile
  4. 2
      deps/server_config.gcfg
  5. 10
      nethack-launcher.go

7
Makefile

@ -6,7 +6,7 @@ NETHACK_DIR=$(shell pwd)/savedata
IMAGE_NAME=nethack_launch IMAGE_NAME=nethack_launch
all: stat reclist all: stat
run: run:
go run \ go run \
@ -16,10 +16,6 @@ stat:
mkdir -p bin/ mkdir -p bin/
$(CGOR) $(GOC) $(GOFLAGS) -o bin/nethack-launcher nethack-launcher.go $(CGOR) $(GOC) $(GOFLAGS) -o bin/nethack-launcher nethack-launcher.go
reclist:
mkdir -p bin/
gcc -static deps/reclist.c -o bin/reclist
dependencies: dependencies:
go get github.com/gorilla/mux go get github.com/gorilla/mux
@ -27,7 +23,6 @@ build_docker:
mkdir -p stage.tmp/ mkdir -p stage.tmp/
cp deps/Dockerfile stage.tmp/ cp deps/Dockerfile stage.tmp/
cp deps/server_config.gcfg stage.tmp/config.gcfg cp deps/server_config.gcfg stage.tmp/config.gcfg
cp bin/reclist stage.tmp/
cp bin/nethack-launcher stage.tmp/ cp bin/nethack-launcher stage.tmp/
cp deps/redis.conf stage.tmp/ cp deps/redis.conf stage.tmp/
cp deps/run.sh stage.tmp/ cp deps/run.sh stage.tmp/

2
config.gcfg

@ -1,7 +1,7 @@
[nethacklauncher] [nethacklauncher]
loglevel = "debug" loglevel = "debug"
serverdisplay = "unixvoid.com underground nethack server" serverdisplay = "unixvoid.com underground nethack server"
nethackversion = "3.6.0" nethackversion = "3.6.1"
hackdir = "savedata/hack" hackdir = "savedata/hack"
nhdatlocation = "/usr/lib/games/nethack/nhdat" nhdatlocation = "/usr/lib/games/nethack/nhdat"
bootstrapdelay = 1 bootstrapdelay = 1

1
deps/Dockerfile vendored

@ -18,7 +18,6 @@ RUN mkdir /hack/
# copy in files # copy in files
COPY config.gcfg / COPY config.gcfg /
COPY nethack-launcher / COPY nethack-launcher /
COPY reclist /bin/
COPY redis.conf / COPY redis.conf /
COPY run.sh / COPY run.sh /
COPY nethackrc /hack/.nethackrc COPY nethackrc /hack/.nethackrc

2
deps/server_config.gcfg vendored

@ -1,7 +1,7 @@
[nethacklauncher] [nethacklauncher]
loglevel = "debug" loglevel = "debug"
serverdisplay = "unixvoid.com underground nethack server" serverdisplay = "unixvoid.com underground nethack server"
nethackversion = "3.6.0" nethackversion = "3.6.1"
hackdir = "/hack" hackdir = "/hack"
nhdatlocation = "/usr/lib/games/nethack/nhdat" nhdatlocation = "/usr/lib/games/nethack/nhdat"
bootstrapdelay = 1 bootstrapdelay = 1

10
nethack-launcher.go

@ -109,6 +109,13 @@ func checkFiles() {
fmt.Printf("%s\n", err) fmt.Printf("%s\n", err)
os.Exit(1) os.Exit(1)
} }
// make sure initial rcfile exists
hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir)
if _, err := os.Stat(hackRCLoc); os.IsNotExist(err) {
glogger.Info.Printf("initial config file not found at: %s\n", hackRCLoc)
fmt.Printf("%s\n", err)
os.Exit(1)
}
} }
func clearScreen() { func clearScreen() {
@ -345,9 +352,6 @@ func printRegisterScreen(redisClient *redis.Client) {
secHash := sha3.Sum512([]byte(sec)) secHash := sha3.Sum512([]byte(sec))
redisClient.Set(fmt.Sprintf("user:%s", username), fmt.Sprintf("%x", secHash), 0).Err() redisClient.Set(fmt.Sprintf("user:%s", username), fmt.Sprintf("%x", secHash), 0).Err()
// TODO create config file
// HackDir/user/username/<config>
// create user directories // create user directories
userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username) userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username)
exec.Command("mkdir", "-p", userPath).Run() exec.Command("mkdir", "-p", userPath).Run()

Loading…
Cancel
Save