command_update.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. # LinuxGSM command_update.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Handles updating of servers.
  7. commandname="UPDATE"
  8. commandaction="Updating"
  9. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. fn_firstcommand_set
  11. fn_update_apply() {
  12. check_status.sh
  13. updatestatus="${status}"
  14. if [ "${updatestatus}" != "0" ]; then
  15. fn_print_restart_warning
  16. exitbypass=1
  17. command_stop.sh
  18. fn_firstcommand_reset
  19. fi
  20. (
  21. unset exitbypass
  22. "$@"
  23. exit 0
  24. )
  25. updateexitcode=$?
  26. if [ "${updateexitcode}" -eq 0 ]; then
  27. date +%s > "${lockdir:?}/last-updated.lock"
  28. fi
  29. if [ "${updatestatus}" != "0" ]; then
  30. # shellcheck disable=SC2034 # Used by command_start.sh.
  31. exitbypass=1
  32. command_start.sh
  33. fn_firstcommand_reset
  34. fi
  35. unset exitbypass
  36. if [ "${updateexitcode}" -ne 0 ]; then
  37. rm -f "${lockdir:?}/update.lock"
  38. # shellcheck disable=SC2034 # Used by alert.sh.
  39. alert="update-failed"
  40. alert.sh
  41. # shellcheck disable=SC2034 # Used by core_exit.sh.
  42. exitcode="${updateexitcode}"
  43. core_exit.sh
  44. fi
  45. }
  46. fn_print_dots ""
  47. check.sh
  48. core_logs.sh
  49. check_update_lock.sh
  50. # A postponed update is requested again if players are still online.
  51. rm -f "${lockdir:?}/${selfname}-update-request.lock"
  52. check_last_update.sh
  53. if [ "${shortname}" == "ts3" ]; then
  54. update_ts3.sh
  55. elif [ "${shortname}" == "mc" ]; then
  56. update_mc.sh
  57. elif [ "${shortname}" == "mcb" ]; then
  58. update_mcb.sh
  59. elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortname}" == "wmc" ]; then
  60. update_pmc.sh
  61. elif [ "${shortname}" == "fctr" ]; then
  62. update_fctr.sh
  63. elif [ "${shortname}" == "hyt" ]; then
  64. update_hyt.sh
  65. elif [ "${shortname}" == "mta" ]; then
  66. update_mta.sh
  67. elif [ "${shortname}" == "jk2" ]; then
  68. update_jk2.sh
  69. elif [ "${shortname}" == "jk3" ]; then
  70. update_jk3.sh
  71. elif [ "${shortname}" == "vints" ]; then
  72. update_vints.sh
  73. elif [ "${shortname}" == "bb" ]; then
  74. update_bb.sh
  75. elif [ "${shortname}" == "ut99" ]; then
  76. update_ut99.sh
  77. elif [ "${shortname}" == "xnt" ]; then
  78. update_xnt.sh
  79. elif [ "${shortname}" == "etl" ]; then
  80. update_etl.sh
  81. else
  82. update_steamcmd.sh
  83. fi
  84. if { [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "hw" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "sol" ] || [ "${shortname}" == "st" ]; } && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then
  85. workshop_core.sh
  86. fn_workshop_update
  87. fi
  88. # remove update lockfile.
  89. rm -f "${lockdir:?}/update.lock"
  90. core_exit.sh