install_dst_token.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # LinuxGSM install_dst_token.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Configures Don't Starve Together cluster with given token.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. echo -e ""
  9. echo -e "${lightyellow}Enter ${gamename} Cluster Token${default}"
  10. echo -e "================================="
  11. fn_sleep_time
  12. echo -e "A cluster token is required to run this server!"
  13. echo -e "Follow the instructions in this link to obtain this key:"
  14. echo -e "https://linuxgsm.com/dst-auth-token"
  15. echo -e ""
  16. if [ -z "${autoinstall}" ]; then
  17. overwritetoken="true"
  18. if [ -s "${clustercfgdir}/cluster_token.txt" ]; then
  19. echo -e "The cluster token is already set. Do you want to overwrite it?"
  20. fn_script_log_info "Don't Starve Together cluster token is already set"
  21. if fn_prompt_yn "Continue?" N; then
  22. overwritetoken="true"
  23. else
  24. overwritetoken="false"
  25. fi
  26. fi
  27. if [ "${overwritetoken}" == "true" ]; then
  28. echo -e "Once you have the cluster token, enter it below"
  29. echo -n "Cluster Token: "
  30. read -r token
  31. mkdir -pv "${clustercfgdir}"
  32. echo -e "${token}" > "${clustercfgdir}/cluster_token.txt"
  33. if [ -f "${clustercfgdir}/cluster_token.txt" ]; then
  34. echo -e "Don't Starve Together cluster token created"
  35. fn_script_log_info "Don't Starve Together cluster token created"
  36. fi
  37. unset overwritetoken
  38. fi
  39. else
  40. echo -e "You can add your cluster token using the following command"
  41. echo -e "./${selfname} cluster-token"
  42. fi
  43. echo -e ""