Browse Source

Move creation files into the proper function

master
Matthew Faltys 5 years ago
parent
commit
013843e4e8
  1. 9
      nethack-launcher/create_user_files.go
  2. 11
      nethack-launcher/print_register_screen.go

9
nethack-launcher/create_user_files.go

@ -7,6 +7,15 @@ import (
) )
func createUserFiles(username string) { func createUserFiles(username string) {
// create user directories
userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username)
exec.Command("mkdir", "-p", userPath).Run()
// copy in rc file
hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir)
hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username)
exec.Command("cp", hackRCLoc, hackRCDest).Run()
// create necessary directories if they dont exist // create necessary directories if they dont exist
userpath := fmt.Sprintf("%s/user/%s", config.NethackLauncher.HackDir, username) userpath := fmt.Sprintf("%s/user/%s", config.NethackLauncher.HackDir, username)

11
nethack-launcher/print_register_screen.go

@ -72,16 +72,7 @@ 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()
// create user directories // stage user directory and files
userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username)
exec.Command("mkdir", "-p", userPath).Run()
// copy in rc file
hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir)
hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username)
exec.Command("cp", hackRCLoc, hackRCDest).Run()
// TODO: move the above creation code into the createUserFiles() function
createUserFiles(username) createUserFiles(username)
// back to main screen // back to main screen

Loading…
Cancel
Save