update_dl.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. # LGSM update_dl.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Runs a server update.
  6. local modulename="Update"
  7. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  8. fn_steamcmd_dl(){
  9. cd "${rootdir}"
  10. cd "steamcmd"
  11. # Detects if unbuffer command is available.
  12. if [ $(command -v stdbuf) ]; then
  13. unbuffer="stdbuf -i0 -o0 -e0"
  14. fi
  15. if [ "${engine}" == "goldsource" ]; then
  16. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}"
  17. else
  18. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}"
  19. fi
  20. fix.sh
  21. }
  22. fn_teamspeak3_dl(){
  23. cd "${rootdir}"
  24. echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
  25. fn_script_log "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
  26. wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
  27. sleep 1
  28. echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
  29. fn_script_log "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
  30. tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
  31. local status=$?
  32. if [ ${status} -eq 0 ]; then
  33. echo "OK"
  34. else
  35. echo "FAIL - Exit status ${status}"
  36. fn_script_log "Failed to extract - Exit status ${status}"
  37. sleep 1
  38. cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
  39. cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
  40. rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
  41. fn_script_log "Failure! Unable to update"
  42. exit ${status}
  43. fi
  44. echo -e "copying to ${filesdir}...\c"
  45. fn_script_log "Copying to ${filesdir}"
  46. cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
  47. local status=$?
  48. if [ ${status} -eq 0 ]; then
  49. echo "OK"
  50. else
  51. echo "FAIL - Exit status ${status}"
  52. fn_script_log "Failed to copy - Exit status ${status}"
  53. sleep 1
  54. cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
  55. cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
  56. rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
  57. fn_script_log "Failure! Unable to update"
  58. exit ${status}
  59. fi
  60. rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
  61. rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
  62. }
  63. check.sh
  64. info_config.sh
  65. fn_print_dots "Updating ${servername}"
  66. sleep 1
  67. fn_print_ok_nl "Updating ${servername}"
  68. fn_script_log "Updating ${servername}"
  69. sleep 1
  70. if [ "${gamename}" == "Teamspeak 3" ]; then
  71. fn_teamspeak3_dl
  72. else
  73. fn_steamcmd_dl
  74. fi