command_mods_install.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # LGSM command_mods_install.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: https://gameservermanagers.com
  6. # Description: List and installs available mods along with mods_list.sh and mods_core.sh.
  7. local commandname="MODS"
  8. local commandaction="addons/mods"
  9. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  10. fn_mods_install_init(){
  11. fn_print_header
  12. # Display installed mods
  13. fn_installed_mods_light_list
  14. echo "Available addons/mods"
  15. echo "================================="
  16. # Display available mods from mods_list.sh
  17. fn_mods_show_available
  18. echo ""
  19. # Keep prompting as long as the user input doesn't correspond to an available mod
  20. while [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; do
  21. echo -en "Enter an ${cyan}addon/mod${default} to ${green}install${default} (or exit to abort): "
  22. read -r usermodselect
  23. # Exit if user says exit or abort
  24. if [ "${usermodselect}" == "exit" ]||[ "${usermodselect}" == "abort" ]; then
  25. core_exit.sh
  26. # Supplementary output upon invalid user input
  27. elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
  28. fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
  29. fi
  30. done
  31. echo ""
  32. echo "Installing ${modprettyname}"
  33. echo "================================="
  34. fn_script_log_info "${modprettyname} selected for install"
  35. # Gives a pretty name to the user and get all mod info
  36. currentmod="${usermodselect}"
  37. }
  38. # Run all required operation
  39. fn_mod_installation(){
  40. # Get mod info
  41. fn_mod_get_info_from_command
  42. # Check if mod is already installed
  43. fn_mod_already_installed
  44. # Check and create required files
  45. fn_mods_files
  46. # Clear lgsm/tmp/mods dir if exists then recreate it
  47. fn_clear_tmp_mods
  48. fn_mods_tmpdir
  49. # Download & extract mod
  50. fn_install_mod_dl_extract
  51. # Convert to lowercase if needed
  52. fn_mod_lowercase
  53. # Build a file list
  54. fn_mod_fileslist
  55. # Copying to destination
  56. fn_mod_copy_destination
  57. # Ending with installation routines
  58. fn_mod_add_list
  59. # Post install fixes
  60. fn_postinstall_tasks
  61. # Cleaning
  62. fn_clear_tmp_mods
  63. echo "${modprettyname} installed"
  64. fn_script_log_pass "${modprettyname} installed."
  65. }
  66. check.sh
  67. mods_core.sh
  68. fn_mods_install_init
  69. fn_mod_installation
  70. core_exit.sh