check_deps.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/bash
  2. # LGSM check_deps.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="310116"
  6. # Description: Checks that the require dependencies are installed for LGSM
  7. fn_deps_detector(){
  8. # Checks is dependency is missing
  9. if [ -n "$(command -v dpkg-query)" ]; then
  10. dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
  11. depstatus=$?
  12. if [ "${depstatus}" == "0" ]; then
  13. missingdep=0
  14. else
  15. # if missing dependency is flagged
  16. missingdep=1
  17. fi
  18. fi
  19. # Add missing dependencies are added to array_deps_missing array
  20. if [ "${missingdep}" == "1" ]; then
  21. array_deps_missing+=("${deptocheck}")
  22. fi
  23. }
  24. fn_deps_email(){
  25. # Adds postfix to required dependencies if email notification is enabled
  26. if [ "${emailnotification}" == "on" ]; then
  27. array_deps_required+=( mailutils postfix )
  28. fi
  29. }
  30. fn_found_missing_deps(){
  31. if [ "${#array_deps_missing[@]}" != "0" ]; then
  32. fn_printdots "Checking dependencies"
  33. sleep 2
  34. fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m"
  35. sleep 1
  36. echo -e ""
  37. sudo -n true > /dev/null 2>&1
  38. if [ $? -eq 0 ]; then
  39. fn_printinfonl "Attempting to install missing dependencies automatically"
  40. echo -en ".\r"
  41. sleep 1
  42. echo -en "..\r"
  43. sleep 1
  44. echo -en "...\r"
  45. sleep 1
  46. echo -en " \r"
  47. sudo apt-get install ${array_deps_missing[@]}
  48. exit 1
  49. else
  50. echo ""
  51. fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies"
  52. echo ""
  53. echo "sudo apt-get install ${array_deps_missing[@]}"
  54. echo ""
  55. exit 1
  56. fi
  57. fi
  58. }
  59. # Check will only run if using apt-get or yum
  60. if [ -n "$(command -v dpkg-query)" ]; then
  61. # Generate array of missing deps
  62. array_deps_missing=()
  63. fn_printdots "Checking dependencies"
  64. # LGSM requirement for curl
  65. local array_deps_required=( curl )
  66. # All servers except ts3 require tmux
  67. if [ "${executable}" != "./ts3server_startscript.sh" ]; then
  68. local array_deps_required+=( tmux )
  69. fi
  70. # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
  71. if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
  72. local array_deps_required+=( lib32gcc1 libstdc++6:i386 )
  73. fi
  74. # Game Specific requirements
  75. # Spark
  76. if [ "${engine}" == "spark" ]; then
  77. local array_deps_required+=( speex:i386 libtbb2 )
  78. # 7 Days to Die
  79. elif [ "${executable}" == "./7DaysToDie.sh" ]; then
  80. local array_deps_required+=( telnet expect )
  81. # Brainbread 2 and Don't Starve Together
  82. elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
  83. local array_deps_required+=( libcurl4-gnutls-dev:i386 )
  84. if [ "${engine}" == "projectzomboid" ]; then
  85. local array_deps_required+=( openjdk-7-jre )
  86. # Unreal engine
  87. elif [ "${executable}" == "./ucc-bin" ]; then
  88. #UT2K4
  89. if [ -f "${executabledir}/ut2004-bin" ]; then
  90. local array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip )
  91. #UT99
  92. else
  93. local array_deps_required+=( libsdl1.2debian bzip2 )
  94. fi
  95. else
  96. fn_printfail "Unknown executable"
  97. exit
  98. fi
  99. fn_deps_email
  100. # Loop though required depenencies
  101. for deptocheck in "${array_deps_required[@]}"
  102. do
  103. fn_deps_detector
  104. done
  105. # user to be informaed of any missing dependecies
  106. fn_found_missing_deps
  107. fi