install_dst_token.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # LGSM install_dst_token.sh function
  3. # Author: Daniel Gibbs & Marvin Lehmann (marvinl97)
  4. # Website: https://gameservermanagers.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 ""
  10. echo "Enter ${gamename} Cluster Token"
  11. echo "================================="
  12. sleep 1
  13. echo "A cluster token is required to run this server!"
  14. echo "Follow the instructions in this link to obtain this key:"
  15. echo "https://gameservermanagers.com/dst-auth-token"
  16. echo ""
  17. if [ -z "${autoinstall}" ]; then
  18. overwritetoken="true"
  19. if [ -s "${clustercfgdir}/cluster_token.txt" ]; then
  20. echo "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. while true; do
  23. read -e -i "n" -p "Continue? [Y/n]" yn
  24. case $yn in
  25. [Yy]* ) overwritetoken="true"; break;;
  26. [Nn]* ) overwritetoken="false"; break;;
  27. * ) echo "Please answer yes or no.";;
  28. esac
  29. done
  30. fi
  31. if [ "${overwritetoken}" == "true" ]; then
  32. echo "Once you have the cluster token, enter it below"
  33. echo -n "Cluster Token: "
  34. read token
  35. mkdir -pv "${clustercfgdir}"
  36. echo "${token}" > "${clustercfgdir}/cluster_token.txt"
  37. if [ -f "${clustercfgdir}/cluster_token.txt" ]; then
  38. echo "Don't Starve Together cluster token created"
  39. fn_script_log_info "Don't Starve Together cluster token created"
  40. fi
  41. unset overwritetoken
  42. fi
  43. else
  44. echo "You can add your cluster token using the following command"
  45. echo "./${selfname} cluster-token"
  46. fi
  47. echo ""