command_validate.sh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 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. # All other servers.
  40. elif [ -n "${branch}" ]; then
  41. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}"
  42. else
  43. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}"
  44. fi
  45. exitcode=$?
  46. fn_print_dots "Validating server: SteamCMD"
  47. if [ "${exitcode}" != "0" ]; then
  48. fn_print_fail_nl "Validating server: SteamCMD"
  49. fn_script_log_fatal "Validating server: SteamCMD: FAIL"
  50. else
  51. fn_print_ok_nl "Validating server: SteamCMD"
  52. fn_script_log_pass "Validating server: SteamCMD: OK"
  53. fi
  54. core_exit.sh
  55. }
  56. fn_stop_warning(){
  57. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  58. fn_script_log_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  59. totalseconds=3
  60. for seconds in {3..1}; do
  61. fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation: ${totalseconds}"
  62. totalseconds=$((totalseconds - 1))
  63. sleep 1
  64. if [ "${seconds}" == "0" ]; then
  65. break
  66. fi
  67. done
  68. fn_print_warn_nl "Validating server: SteamCMD: ${selfname} will be stopped during validation"
  69. }
  70. fn_print_dots "Validating server"
  71. fn_print_dots "Validating server: SteamCMD"
  72. check.sh
  73. check_status.sh
  74. if [ "${status}" != "0" ]; then
  75. fn_stop_warning
  76. exitbypass=1
  77. command_stop.sh
  78. fn_validate
  79. exitbypass=1
  80. command_start.sh
  81. else
  82. fn_validate
  83. fi