check_steamcmd.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # LinuxGSM check_steamcmd.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Checks if SteamCMD is installed correctly.
  6. local commandname="CHECK"
  7. fn_install_steamcmd(){
  8. if [ ! -d "${steamcmddir}" ]; then
  9. mkdir -pv "${steamcmddir}"
  10. fi
  11. fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${tmpdir}" "steamcmd_linux.tar.gz"
  12. fn_dl_extract "${tmpdir}" "steamcmd_linux.tar.gz" "${steamcmddir}"
  13. chmod +x "${steamcmddir}/steamcmd.sh"
  14. }
  15. fn_check_steamcmd_user(){
  16. # Checks if steamuser is setup.
  17. if [ "${steamuser}" == "username" ]; then
  18. fn_print_fail_nl "Steam login not set. Update steamuser in ${selfname}"
  19. echo " * Change steamuser=\"username\" to a valid steam login."
  20. if [ -d "${scriptlogdir}" ]; then
  21. fn_script_log_fatal "Steam login not set. Update steamuser in ${selfname}"
  22. fi
  23. core_exit.sh
  24. fi
  25. # Anonymous user is set if steamuser is missing
  26. if [ -z "${steamuser}" ]; then
  27. if [ -d "${scriptlogdir}" ]; then
  28. fn_script_log_info "Using anonymous Steam login"
  29. fi
  30. steamuser="anonymous"
  31. steampass=''
  32. sleep 1
  33. fi
  34. }
  35. fn_check_steamcmd_sh(){
  36. # Checks if SteamCMD exists when starting or updating a server.
  37. # Installs if missing.
  38. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
  39. if [ "${function_selfname}" == "command_install.sh" ]; then
  40. fn_install_steamcmd
  41. else
  42. fn_print_error_nl "SteamCMD is missing"
  43. fn_script_log_error "SteamCMD is missing"
  44. sleep 1
  45. fn_install_steamcmd
  46. fi
  47. elif [ "${function_selfname}" == "command_install.sh" ]; then
  48. fn_print_information "SteamCMD is already installed..."
  49. fn_print_ok_eol_nl
  50. fi
  51. }
  52. fn_check_steamcmd_user
  53. fn_check_steamcmd_sh