check_steamcmd.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # LGSM check_steamcmd.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="061115"
  6. # Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD
  7. if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]; then
  8. : # These servers do not require SteamCMD. Check is skipped.
  9. elif [ "${modulename}" == "Starting" ]||[ "${modulename}" == "Update" ]||[ "${modulename}" == "Validate" ]; then
  10. # Checks if SteamCMD exists when starting or updating a server.
  11. # Re-installs if missing.
  12. steamcmddir="${rootdir}/steamcmd"
  13. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
  14. fn_printwarnnl "SteamCMD is missing"
  15. fn_scriptlog "SteamCMD is missing"
  16. sleep 1
  17. if [ ! -d "${steamcmddir}" ]; then
  18. mkdir -v "${steamcmddir}"
  19. fi
  20. curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1)
  21. exitcode=$?
  22. echo -e "downloading steamcmd_linux.tar.gz...\c"
  23. if [ $exitcode -eq 0 ]; then
  24. fn_printokeol
  25. else
  26. fn_printfaileol
  27. echo "${curl}"
  28. echo -e "${githuburl}\n"
  29. exit $exitcode
  30. fi
  31. tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
  32. rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
  33. chmod +x "${steamcmddir}/steamcmd.sh"
  34. fi
  35. if [ "${modulename}" == "Update" ]||[ "${modulename}" == "Validate" ]; then
  36. # Checks that steamcmd is working correctly and will prompt Steam Guard if required.
  37. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
  38. if [ $? -ne 0 ]; then
  39. fn_printfailurenl "Error running SteamCMD"
  40. fi
  41. fi
  42. fi