update_dl.sh 2.9 KB

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