install_dst_token.sh 1.5 KB

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