command_update.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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}" == "vints" ]; then
  71. update_vints.sh
  72. elif [ "${shortname}" == "bb" ]; then
  73. update_bb.sh
  74. elif [ "${shortname}" == "ut99" ]; then
  75. update_ut99.sh
  76. elif [ "${shortname}" == "xnt" ]; then
  77. update_xnt.sh
  78. elif [ "${shortname}" == "etl" ]; then
  79. update_etl.sh
  80. else
  81. update_steamcmd.sh
  82. fi
  83. 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
  84. workshop_core.sh
  85. fn_workshop_update
  86. fi
  87. # remove update lockfile.
  88. rm -f "${lockdir:?}/update.lock"
  89. core_exit.sh