check_deps.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. elif [ -n "$(command -v yum)" ]; then
  13. yum -q list installed ${deptocheck} 2>/dev/null
  14. depstatus=$?
  15. fi
  16. if [ "${depstatus}" == "0" ]; then
  17. missingdep=0
  18. else
  19. # if missing dependency is flagged
  20. missingdep=1
  21. fi
  22. # Add missing dependencies are added to array_deps_missing array
  23. if [ "${missingdep}" == "1" ]; then
  24. array_deps_missing+=("${deptocheck}")
  25. fi
  26. }
  27. fn_deps_email(){
  28. # Adds postfix to required dependencies if email notification is enabled
  29. if [ "${emailnotification}" == "on" ]; then
  30. if [ -n "$(command -v dpkg-query)" ]; then
  31. array_deps_required+=( mailutils postfix )
  32. elif [ -n "$(command -v yum)" ]; then
  33. array_deps_required+=( mailx postfix )
  34. fi
  35. fi
  36. }
  37. fn_found_missing_deps(){
  38. if [ "${#array_deps_missing[@]}" != "0" ]; then
  39. fn_printdots "Checking dependencies"
  40. sleep 2
  41. fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m"
  42. sleep 1
  43. echo -e ""
  44. sudo -n true > /dev/null 2>&1
  45. if [ $? -eq 0 ]; then
  46. fn_printinfonl "Attempting to install missing dependencies automatically"
  47. echo -en ".\r"
  48. sleep 1
  49. echo -en "..\r"
  50. sleep 1
  51. echo -en "...\r"
  52. sleep 1
  53. echo -en " \r"
  54. if [ -n "$(command -v dpkg-query)" ]; then
  55. echo "sudo apt-get install ${array_deps_missing[@]}"
  56. elif [ -n "$(command -v yum)" ]; then
  57. echo "yum install ${array_deps_missing[@]}"
  58. fi
  59. else
  60. echo ""
  61. fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies"
  62. echo ""
  63. if [ -n "$(command -v dpkg-query)" ]; then
  64. echo "sudo apt-get install ${array_deps_missing[@]}"
  65. elif [ -n "$(command -v yum)" ]; then
  66. echo "yum install ${array_deps_missing[@]}"
  67. fi
  68. echo ""
  69. fi
  70. fi
  71. }
  72. fn_check_loop(){
  73. # Loop though required depenencies
  74. for deptocheck in "${array_deps_required[@]}"
  75. do
  76. fn_deps_detector
  77. done
  78. # user to be informaed of any missing dependecies
  79. fn_found_missing_deps
  80. }
  81. # Check will only run if using apt-get or yum
  82. if [ -n "$(command -v dpkg-query)" ]; then
  83. # Generate array of missing deps
  84. array_deps_missing=()
  85. fn_printdots "Checking dependencies"
  86. # LGSM requirement for curl
  87. array_deps_required=( curl ca-certificates )
  88. # All servers except ts3 require tmux
  89. if [ "${executable}" != "./ts3server_startscript.sh" ]; then
  90. array_deps_required+=( tmux )
  91. fi
  92. # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
  93. if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
  94. array_deps_required+=( lib32gcc1 libstdc++6:i386 )
  95. fi
  96. # Game Specific requirements
  97. # Spark
  98. if [ "${engine}" == "spark" ]; then
  99. array_deps_required+=( speex:i386 libtbb2 )
  100. # 7 Days to Die
  101. elif [ "${executable}" == "./7DaysToDie.sh" ]; then
  102. array_deps_required+=( telnet expect )
  103. # No More Room in Hell
  104. elif [ "${gamename}" == "No More Room in Hell" ]
  105. array_deps_required+=( lib32tinfo5 )
  106. # Brainbread 2 and Don't Starve Together
  107. elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
  108. array_deps_required+=( libcurl4-gnutls-dev:i386 )
  109. elif [ "${engine}" == "projectzomboid" ]; then
  110. array_deps_required+=( openjdk-7-jre )
  111. # Unreal engine
  112. elif [ "${executable}" == "./ucc-bin" ]; then
  113. #UT2K4
  114. if [ -f "${executabledir}/ut2004-bin" ]; then
  115. array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip )
  116. #UT99
  117. else
  118. array_deps_required+=( libsdl1.2debian bzip2 )
  119. fi
  120. fi
  121. fn_deps_email
  122. fn_check_loop
  123. elif [ -n "$(command -v yum)" ]; then
  124. # Generate array of missing deps
  125. array_deps_missing=()
  126. fn_printdots "Checking dependencies"
  127. # LGSM requirement for curl
  128. array_deps_required=( curl )
  129. # All servers except ts3 require tmux
  130. if [ "${executable}" != "./ts3server_startscript.sh" ]; then
  131. array_deps_required+=( tmux )
  132. fi
  133. # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
  134. if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
  135. array_deps_required+=( glibc.i686 libstdc++.i686 )
  136. fi
  137. # Game Specific requirements
  138. # Spark
  139. if [ "${engine}" == "spark" ]; then
  140. array_deps_required+=( speex.i686 tbb.i686 )
  141. # 7 Days to Die
  142. elif [ "${executable}" == "./7DaysToDie.sh" ]; then
  143. array_deps_required+=( telnet expect )
  144. # No More Room in Hell
  145. elif [ "${gamename}" == "No More Room in Hell" ]
  146. array_deps_required+=( ncurses-libs.i686 )
  147. # Brainbread 2 and Don't Starve Together
  148. elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
  149. array_deps_required+=( libcurl.i686 )
  150. elif [ "${engine}" == "projectzomboid" ]; then
  151. array_deps_required+=( java-1.7.0-openjdk )
  152. # Unreal engine
  153. elif [ "${executable}" == "./ucc-bin" ]; then
  154. #UT2K4
  155. if [ -f "${executabledir}/ut2004-bin" ]; then
  156. array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 unzip )
  157. #UT99
  158. else
  159. array_deps_required+=( SDL.i686 bzip2 )
  160. fi
  161. fi
  162. fn_deps_email
  163. fn_check_loop
  164. fi