command_validate.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # LinuxGSM command_validate.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Runs a server validation.
  6. commandname="VALIDATE"
  7. commandaction="Validating"
  8. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. fn_validate(){
  10. fn_script_log_warn "Validating server: SteamCMD: Validate might overwrite some customised files"
  11. totalseconds=3
  12. for seconds in {3..1}; do
  13. fn_print_warn "Validating server: SteamCMD: Validate might overwrite some customised files: ${totalseconds}"
  14. totalseconds=$((totalseconds - 1))
  15. sleep 1
  16. if [ "${seconds}" == "0" ]; then
  17. break
  18. fi
  19. done
  20. fn_print_warn_nl "Validating server: SteamCMD: Validate might overwrite some customised files"
  21. fn_print_start_nl "Validating server: SteamCMD"
  22. fn_script_log_info "Validating server: SteamCMD"
  23. if [ -d "${steamcmddir}" ]; then
  24. cd "${steamcmddir}" || exit
  25. fi
  26. # Detects if unbuffer command is available, for 32 bit distributions only.
  27. info_distro.sh
  28. if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
  29. unbuffer="stdbuf -i0 -o0 -e0"
  30. fi
  31. # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands.
  32. if [ "${appid}" == "90" ]; then
  33. # If using a specific branch.
  34. if [ -n "${branch}" ]; then
  35. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}"
  36. else
  37. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}"
  38. fi
  39. elif [ "${shortname}" == "ac" ]; then
  40. ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit
  41. local exitcode=$?
  42. # All other servers.
  43. elif [ -n "${branch}" ]; then
  44. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}"
  45. else
  46. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}"
  47. fi
  48. exitcode=$?
  49. fn_print_dots "Validating server: SteamCMD"
  50. if [ "${exitcode}" != "0" ]; then
  51. fn_print_fail_nl "Validating server: SteamCMD"
  52. fn_script_log_fatal "Validating server: SteamCMD: FAIL"
  53. else
  54. fn_print_ok_nl "Validating server: SteamCMD"
  55. fn_script_log_pass "Validating server: SteamCMD: OK"
  56. fi
  57. core_exit.sh
  58. }
  59. fn_stop_warning(){
  60. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  61. fn_script_log_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  62. totalseconds=3
  63. for seconds in {3..1}; do
  64. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation: ${totalseconds}"
  65. totalseconds=$((totalseconds - 1))
  66. sleep 1
  67. if [ "${seconds}" == "0" ]; then
  68. break
  69. fi
  70. done
  71. fn_print_warn_nl "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  72. }
  73. fn_print_dots "Validating server"
  74. fn_print_dots "Validating server: SteamCMD"
  75. check.sh
  76. if [ "${status}" != "0" ]; then
  77. fn_stop_warning
  78. exitbypass=1
  79. command_stop.sh
  80. fn_validate
  81. exitbypass=1
  82. command_start.sh
  83. else
  84. fn_validate
  85. fi
  86. core_exit.sh