command_update.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # A postponed update is requested again if players are still online.
  50. rm -f "${lockdir:?}/${selfname}-update-request.lock"
  51. check_last_update.sh
  52. if [ "${shortname}" == "ts3" ]; then
  53. update_ts3.sh
  54. elif [ "${shortname}" == "mc" ]; then
  55. update_mc.sh
  56. elif [ "${shortname}" == "mcb" ]; then
  57. update_mcb.sh
  58. elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortname}" == "wmc" ]; then
  59. update_pmc.sh
  60. elif [ "${shortname}" == "fctr" ]; then
  61. update_fctr.sh
  62. elif [ "${shortname}" == "hyt" ]; then
  63. update_hyt.sh
  64. elif [ "${shortname}" == "mta" ]; then
  65. update_mta.sh
  66. elif [ "${shortname}" == "jk2" ]; then
  67. update_jk2.sh
  68. elif [ "${shortname}" == "jk3" ]; then
  69. update_jk3.sh
  70. elif [ "${shortname}" == "luanti" ]; then
  71. update_luanti.sh
  72. elif [ "${shortname}" == "vints" ]; then
  73. update_vints.sh
  74. elif [ "${shortname}" == "bb" ]; then
  75. update_bb.sh
  76. elif [ "${shortname}" == "ut99" ]; then
  77. update_ut99.sh
  78. elif [ "${shortname}" == "xnt" ]; then
  79. update_xnt.sh
  80. elif [ "${shortname}" == "etl" ]; then
  81. update_etl.sh
  82. else
  83. update_steamcmd.sh
  84. fi
  85. 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
  86. workshop_core.sh
  87. fn_workshop_update
  88. fi
  89. # remove update lockfile.
  90. rm -f "${lockdir:?}/update.lock"
  91. core_exit.sh