command_mods_update.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # LGSM command_mods_update.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: https://gameservermanagers.com
  6. # Description: Updates installed mods along with mods_list.sh.
  7. local commandname="MODS"
  8. local commandaction="Mods Update"
  9. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  10. check.sh
  11. mods_list.sh
  12. fn_mods_update_init(){
  13. fn_script_log "Entering mods & addons update"
  14. echo "================================="
  15. echo "${gamename} mods & addons update"
  16. echo ""
  17. # Installed mod dir is "${modslockfilefullpath}"
  18. # How many mods will be updated
  19. installedmodscount="$(cat "${modslockfilefullpath}" | wc -l)"
  20. echo "${installedmodscount} addons will be updated:"
  21. # Loop showing mods to update
  22. installedmodsline=1
  23. while [ $installedmodsline -le $installedmodscount ]; do
  24. echo -e " * \e[36m$(sed "${installedmodsline}q;d" "${modslockfilefullpath}")\e[0m"
  25. let installedmodsline=installedmodsline+1
  26. done
  27. sleep 2
  28. }
  29. fn_mods_update_loop(){
  30. while [ $installedmodsline -le $installedmodscount ]; do
  31. currentmod="$(sed "${installedmodsline}q;d" "${modslockfilefullpath}")"
  32. fn_mod_get_info_from_command
  33. if [ -n "${currentmod}" ]; then
  34. fn_print_dots_nl "Updating ${modprettyname}"
  35. sleep 0.5
  36. fn_script_log "Updating ${modprettyname}."
  37. # Get mod info
  38. fn_mod_get_info_from_command
  39. # Check if mod is already installed
  40. fn_mod_already_installed
  41. # Check and create required directories
  42. fn_mods_dir
  43. # Clear lgsm/tmp/mods dir if exists then recreate it
  44. fn_clear_tmp_mods
  45. fn_mods_tmpdir
  46. # Download mod
  47. fn_mod_dl
  48. # Extract the mod
  49. fn_mod_extract
  50. # Build a file list
  51. fn_mod_fileslist
  52. # Copying to destination
  53. fn_mod_copy_destination
  54. # Ending with installation routines
  55. fn_mod_add_list
  56. fn_clear_tmp_mods
  57. fn_print_ok_nl "${modprettyname} installed."
  58. fn_script_log "${modprettyname} installed."
  59. else
  60. fn_print_fail "No mod was selected."
  61. core_exit.sh
  62. fi
  63. done
  64. }
  65. fn_mods_update_init