command_validate.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. local modulename="VALIDATE"
  7. local commandaction="Validate"
  8. local function_selfname=$(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 [ "${appid}" == "90" ]; then
  32. ${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}"
  33. else
  34. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}"
  35. fi
  36. exitcode=$?
  37. fn_print_dots "Validating server: SteamCMD"
  38. if [ "${exitcode}" != "0" ]; then
  39. fn_print_fail_nl "Validating server: SteamCMD"
  40. fn_script_log_fatal "Validating server: SteamCMD: FAIL"
  41. else
  42. fn_print_ok_nl "Validating server: SteamCMD"
  43. fn_script_log_pass "Validating server: SteamCMD: OK"
  44. fi
  45. core_exit.sh
  46. }
  47. fn_stop_warning(){
  48. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  49. fn_script_log_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  50. totalseconds=3
  51. for seconds in {3..1}; do
  52. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation: ${totalseconds}"
  53. totalseconds=$((totalseconds - 1))
  54. sleep 1
  55. if [ "${seconds}" == "0" ]; then
  56. break
  57. fi
  58. done
  59. fn_print_warn_nl "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  60. }
  61. fn_print_dots "Validating server"
  62. fn_print_dots "Validating server: SteamCMD"
  63. check.sh
  64. check_status.sh
  65. if [ "${status}" != "0" ]; then
  66. fn_stop_warning
  67. exitbypass=1
  68. command_stop.sh
  69. fn_validate
  70. exitbypass=1
  71. command_start.sh
  72. else
  73. fn_validate
  74. fi