install_dst_token.sh 1.6 KB

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