command_mods_install.sh 2.2 KB

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