diff --git a/Makefile b/Makefile index 97f9b00..3e455e4 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ dependencies: build_docker: mkdir -p stage.tmp/ cp deps/Dockerfile stage.tmp/ - cp deps/server_config.gcfg stage.tmp/config.gcfg + cp config.gcfg stage.tmp/config.gcfg cp bin/nethack-launcher stage.tmp/ cp deps/redis.conf stage.tmp/ cp deps/run.sh stage.tmp/ diff --git a/config.gcfg b/config.gcfg index 133ef5e..ffcab6f 100644 --- a/config.gcfg +++ b/config.gcfg @@ -2,9 +2,10 @@ loglevel = "debug" serverdisplay = "unixvoid.com underground nethack server" nethackversion = "3.6.3 beta1+" - hackdir = "savedata/hack" + hackdir = "/hack" nhdatlocation = "/NetHack/dat/nhdat" recoverbinary = "/NetHack/util/recover" + sysconflocation = "/NetHack/sys/unix/sysconf" bootstrapdelay = 1 [redis] diff --git a/deps/Dockerfile b/deps/Dockerfile index a3becec..683baee 100644 --- a/deps/Dockerfile +++ b/deps/Dockerfile @@ -41,6 +41,11 @@ RUN cd NetHack && \ RUN find /* -name nethack RUN chmod 777 /NetHack/sys/unix/sysconf +# update sysconf +RUN sed -i 's/.*WIZARDS=.*/#WIZARDS=/' /NetHack/sys/unix/sysconf +RUN sed -i 's/.*GENERICUSERS=.*/#GENERICUSERS=/' /NetHack/sys/unix/sysconf +RUN sed -i 's/.*MAXPLAYERS=.*/MAXPLAYERS=0/' /NetHack/sys/unix/sysconf + # make required dirs RUN mkdir -p /redisbackup/ @@ -57,6 +62,8 @@ RUN echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config RUN useradd nethack -d / -s /nethack-launcher RUN echo 'nethack:U6aMy0wojraho' | chpasswd -e RUN chown -R nethack /hack/ +RUN chown -R nethack /NetHack/ +RUN touch /.hushlogin # build ttyrec RUN git clone https://github.com/ovh/ovh-ttyrec && \ diff --git a/deps/server_config.gcfg b/deps/server_config.gcfg deleted file mode 100644 index 146be16..0000000 --- a/deps/server_config.gcfg +++ /dev/null @@ -1,12 +0,0 @@ -[nethacklauncher] - loglevel = "debug" - serverdisplay = "unixvoid.com underground nethack server" - nethackversion = "3.6.3 beta1+" - hackdir = "/hack" - nhdatlocation = "/usr/lib/games/nethack/nhdat" - recoverbinary = "/usr/lib/games/nethack/recover" - bootstrapdelay = 1 - -[redis] - host = "localhost:6379" - password = "" diff --git a/nethack-launcher/create_initial_files.go b/nethack-launcher/create_initial_files.go index 5f60d98..e289db1 100644 --- a/nethack-launcher/create_initial_files.go +++ b/nethack-launcher/create_initial_files.go @@ -14,7 +14,18 @@ func createInitialFiles() { // move in nhdat file if it does not exist if _, err := os.Stat(fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir)); os.IsNotExist(err) { - exec.Command("cp", config.NethackLauncher.NhdatLocation, config.NethackLauncher.HackDir).Run() + fmt.Printf("%s\n", err) + println("moving in initial nhdat file") + out, err := exec.Command("cp", config.NethackLauncher.NhdatLocation, fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir)).Output() + if err != nil { + fmt.Printf("%s\n", err) + } + fmt.Printf("%s\n", out) + } + + // move in sysconf file if it does not exist + if _, err := os.Stat(fmt.Sprintf("%s/sysconf", config.NethackLauncher.HackDir)); os.IsNotExist(err) { + exec.Command("cp", config.NethackLauncher.SysconfLocation, config.NethackLauncher.HackDir).Run() } // make sure record file exists @@ -35,6 +46,7 @@ func createInitialFiles() { os.Exit(1) } else { // move nethackrc file to proper location + println("moving in initial config file") exec.Command("cp", "/.nethackrc", config.NethackLauncher.HackDir).Run() } diff --git a/nethack-launcher/create_user_files.go b/nethack-launcher/create_user_files.go index 81923e2..6f6a22d 100644 --- a/nethack-launcher/create_user_files.go +++ b/nethack-launcher/create_user_files.go @@ -34,6 +34,9 @@ func createUserFiles(username string) { // create record symlink exec.Command("ln", "-s", fmt.Sprintf("%s/record", config.NethackLauncher.HackDir), fmt.Sprintf("%s/record", userpath)).Run() + // create sysconf symlink + exec.Command("ln", "-s", fmt.Sprintf("%s/sysconf", config.NethackLauncher.HackDir), fmt.Sprintf("%s/sysconf", userpath)).Run() + // move in nhdat file if it does not exist exec.Command("cp", fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir), userpath).Run() } diff --git a/nethack-launcher/nethack-launcher.go b/nethack-launcher/nethack-launcher.go index bb68f33..a3c8aa1 100644 --- a/nethack-launcher/nethack-launcher.go +++ b/nethack-launcher/nethack-launcher.go @@ -13,13 +13,14 @@ import ( type Config struct { NethackLauncher struct { - Loglevel string - ServerDisplay string - NethackVersion string - HackDir string - NhdatLocation string - RecoverBinary string - BootstrapDelay time.Duration + Loglevel string + ServerDisplay string + NethackVersion string + HackDir string + NhdatLocation string + RecoverBinary string + SysconfLocation string + BootstrapDelay time.Duration } Redis struct {