check_deps.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. #!/bin/bash
  2. # LinuxGSM check_deps.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Checks and installs missing dependencies.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. fn_install_dotnet_repo() {
  9. local dotnetpackage
  10. dotnetpackage="dotnet-runtime-7.0"
  11. for dep in "${array_deps_missing[@]}"; do
  12. if [[ "${dep}" == dotnet-runtime-* ]]; then
  13. dotnetpackage="${dep}"
  14. break
  15. fi
  16. done
  17. if [ "${distroid}" == "ubuntu" ]; then
  18. # If the required .NET package is unavailable in Ubuntu repos, add the Microsoft repo.
  19. if ! apt-cache show "${dotnetpackage}" > /dev/null 2>&1; then
  20. fn_fetch_file "https://packages.microsoft.com/config/ubuntu/${distroversion}/packages-microsoft-prod.deb" "" "" "" "/tmp" "packages-microsoft-prod.deb" "" "" "" ""
  21. sudo dpkg -i /tmp/packages-microsoft-prod.deb
  22. fi
  23. elif [ "${distroid}" == "debian" ]; then
  24. # If the required .NET package is unavailable in Debian repos, add the Microsoft repo.
  25. if ! apt-cache show "${dotnetpackage}" > /dev/null 2>&1; then
  26. fn_fetch_file "https://packages.microsoft.com/config/debian/${distroversion}/packages-microsoft-prod.deb" "" "" "" "/tmp" "packages-microsoft-prod.deb" "" "" "" ""
  27. sudo dpkg -i /tmp/packages-microsoft-prod.deb
  28. fi
  29. fi
  30. }
  31. fn_install_mono_repo() {
  32. if [ "${autodepinstall}" == "0" ]; then
  33. fn_print_information_nl "Automatically adding Mono repository."
  34. fn_script_log_info "Automatically adding Mono repository."
  35. echo -en ".\r"
  36. fn_sleep_time_1
  37. echo -en "..\r"
  38. fn_sleep_time_1
  39. echo -en "...\r"
  40. fn_sleep_time_1
  41. echo -en " \r"
  42. if [ "${distroid}" == "ubuntu" ]; then
  43. if [ "${distroversion}" == "22.04" ]; then
  44. cmd="sudo apt-get install gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-jammy main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  45. elif [ "${distroversion}" == "20.04" ]; then
  46. cmd="sudo apt-get install gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-focal main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  47. elif [ "${distroversion}" == "18.04" ]; then
  48. cmd="sudo apt-get install gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  49. elif [ "${distroversion}" == "16.04" ]; then
  50. cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https ca-certificates;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  51. else
  52. monoautoinstall="1"
  53. fi
  54. elif [ "${distroid}" == "debian" ]; then
  55. if [ "${distroversion}" == "12" ]; then
  56. cmd="sudo apt-get install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-bookworm main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  57. elif [ "${distroversion}" == "11" ]; then
  58. cmd="sudo apt-get install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-bullseye main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  59. elif [ "${distroversion}" == "10" ]; then
  60. cmd="sudo apt-get install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  61. elif [ "${distroversion}" == "9" ]; then
  62. cmd="sudo apt-get install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
  63. else
  64. monoautoinstall="1"
  65. fi
  66. elif [ "${distroid}" == "centos" ] || [ "${distroid}" == "almalinux" ] || [ "${distroid}" == "rocky" ]; then
  67. if [ "${distroversion}" == "8" ]; then
  68. cmd="sudo rpmkeys --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'"
  69. elif [ "${distroversion}" == "7" ]; then
  70. cmd="sudo rpmkeys --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'"
  71. else
  72. monoautoinstall="1"
  73. fi
  74. elif [ "${distroid}" == "fedora" ]; then
  75. if [ "${distroversion}" -ge "29" ]; then
  76. cmd="sudo rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo';dnf update"
  77. else
  78. cmd="sudo rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo';dnf update"
  79. fi
  80. else
  81. monoautoinstall="1"
  82. fi
  83. # Run the mono repo install.
  84. eval "${cmd}"
  85. monorepoexitcode=$?
  86. # Did Mono repo install correctly?
  87. if [ "${monoautoinstall}" != "1" ]; then
  88. if [ "${monorepoexitcode}" -ne 0 ]; then
  89. fn_print_failure_nl "Unable to install Mono repository."
  90. fn_script_log_fail "Unable to install Mono repository."
  91. else
  92. fn_print_success_nl "Installing Mono repository completed."
  93. fn_script_log_pass "Installing Mono repository completed."
  94. fi
  95. fi
  96. # Mono can not be auto installed with this distro.
  97. if [ "${monoautoinstall}" == "1" ]; then
  98. fn_print_warning_nl "Mono auto install not available for ${distroname}."
  99. echo -e "Follow instructions on Mono website to install."
  100. echo -e "https://www.mono-project.com/download/stable/#download-lin"
  101. fn_script_log_warn "Unable to install Mono repository. Mono auto install not available for ${distroname}."
  102. fi
  103. else
  104. fn_print_information_nl "Installing Mono repository."
  105. fn_print_warning_nl "$(whoami) does not have sudo access."
  106. echo -e "Follow instructions on Mono website to install."
  107. echo -e "https://www.mono-project.com/download/stable/#download-lin"
  108. fn_script_log_warn "Unable to install Mono repository. $(whoami) does not have sudo access."
  109. fi
  110. }
  111. fn_deps_email() {
  112. # Adds postfix to required dependencies if email alert is enabled.
  113. if [ "${emailalert}" == "on" ]; then
  114. if [ -f /usr/bin/mailx ]; then
  115. if [ -d /etc/exim4 ]; then
  116. array_deps_required+=(exim4)
  117. elif [ -d /etc/sendmail ]; then
  118. array_deps_required+=(sendmail)
  119. elif [ "$(command -v yum 2> /dev/null)" ] || [ "$(command -v dnf 2> /dev/null)" ]; then
  120. array_deps_required+=(s-nail postfix)
  121. elif [ "$(command -v apt 2> /dev/null)" ]; then
  122. array_deps_required+=(mailutils postfix)
  123. fi
  124. else
  125. if [ "$(command -v yum 2> /dev/null)" ] || [ "$(command -v dnf 2> /dev/null)" ]; then
  126. array_deps_required+=(s-nail postfix)
  127. elif [ "$(command -v apt 2> /dev/null)" ]; then
  128. array_deps_required+=(mailutils postfix)
  129. fi
  130. fi
  131. fi
  132. }
  133. fn_install_missing_deps() {
  134. # If any dependencies are not installed.
  135. if [ "${#array_deps_missing[*]}" != "0" ]; then
  136. if [ "${commandname}" == "INSTALL" ]; then
  137. fn_print_warning_nl "Missing dependencies: ${red}${array_deps_missing[*]}${default}"
  138. fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
  139. else
  140. fn_print_dots "Missing dependencies"
  141. fn_print_warn "Missing dependencies: ${red}${array_deps_missing[*]}${default}"
  142. fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
  143. fi
  144. # Attempt automatic dependency installation
  145. if [ "${autoinstall}" == "1" ]; then
  146. sudo -n true > /dev/null 2>&1
  147. else
  148. sudo -v > /dev/null 2>&1
  149. fi
  150. autodepinstall="$?"
  151. if [ "${monoinstalled}" == "false" ]; then
  152. fn_install_mono_repo
  153. fi
  154. if [ "${dotnetinstalled}" == "false" ]; then
  155. fn_install_dotnet_repo
  156. fi
  157. if [ "${commandname}" == "INSTALL" ]; then
  158. if [ "${autodepinstall}" == "0" ]; then
  159. fn_print_information_nl "$(whoami) has sudo access."
  160. fn_script_log_info "$(whoami) has sudo access."
  161. else
  162. fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies or run ./${selfname} install as root."
  163. fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies or run ./${selfname} install as root."
  164. fi
  165. fi
  166. # Add sudo dpkg --add-architecture i386 if using i386 packages.
  167. if [ "$(command -v apt 2> /dev/null)" ]; then
  168. if printf '%s\n' "${array_deps_required[@]}" | grep -q -P 'i386'; then
  169. i386installcommand="sudo dpkg --add-architecture i386; "
  170. fi
  171. fi
  172. # If automatic dependency install is available
  173. if [ "${autodepinstall}" == "0" ]; then
  174. fn_print_information_nl "Automatically installing missing dependencies."
  175. fn_script_log_info "Automatically installing missing dependencies."
  176. echo -en ".\r"
  177. fn_sleep_time_1
  178. echo -en "..\r"
  179. fn_sleep_time_1
  180. echo -en "...\r"
  181. fn_sleep_time_1
  182. echo -en " \r"
  183. if [ "$(command -v apt 2> /dev/null)" ]; then
  184. cmd="echo steamcmd steam/question select \"I AGREE\" | sudo debconf-set-selections; echo steamcmd steam/license note '' | sudo debconf-set-selections; ${i386installcommand}sudo apt-get update; sudo apt-get -y install ${array_deps_missing[*]}"
  185. eval "${cmd}"
  186. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  187. cmd="sudo dnf -y install ${array_deps_missing[*]}"
  188. eval "${cmd}"
  189. elif [ "$(command -v yum 2> /dev/null)" ]; then
  190. cmd="sudo yum -y install ${array_deps_missing[*]}"
  191. eval "${cmd}"
  192. fi
  193. autodepinstall="$?"
  194. # If auto install passes, remove steamcmd install failure and set exit code to 0.
  195. if [ "${autodepinstall}" == "0" ]; then
  196. unset steamcmdfail
  197. exitcode=0
  198. fi
  199. fi
  200. # If automatic dependency install is unavailable.
  201. if [ "${autodepinstall}" != "0" ]; then
  202. if [ "$(command -v apt 2> /dev/null)" ]; then
  203. echo -e " Run: '${green}${i386installcommand}sudo apt update; sudo apt install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  204. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  205. echo -e " Run: '${green}sudo dnf install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  206. elif [ "$(command -v yum 2> /dev/null)" ]; then
  207. echo -e " Run: '${green}sudo yum install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  208. fi
  209. fi
  210. if [ "${steamcmdfail}" ]; then
  211. if [ "${commandname}" == "INSTALL" ]; then
  212. fn_print_failure_nl "Missing dependencies required to run SteamCMD."
  213. fn_script_log_fail "Missing dependencies required to run SteamCMD."
  214. core_exit.sh
  215. else
  216. fn_print_error_nl "Missing dependencies required to run SteamCMD."
  217. fn_script_log_error "Missing dependencies required to run SteamCMD."
  218. fi
  219. fi
  220. else
  221. if [ "${commandname}" == "INSTALL" ]; then
  222. fn_print_skip2_nl "Required dependencies already installed."
  223. fn_script_log_info "Required dependencies already installed."
  224. fi
  225. fi
  226. }
  227. fn_check_loop() {
  228. # Loop though required dependencies checking if they are installed.
  229. for deptocheck in "${array_deps_required[@]}"; do
  230. fn_deps_detector
  231. done
  232. # user will be informed of any missing dependencies.
  233. fn_install_missing_deps
  234. }
  235. # Checks if dependency is installed or not.
  236. fn_deps_detector() {
  237. ## Check.
  238. # SteamCMD: Will be removed from required array if no appid is present or non-free repo is not available.
  239. # This will cause SteamCMD to be installed using tar.
  240. if [ "${deptocheck}" == "libsdl2-2.0-0:i386" ] && [ -z "${appid}" ]; then
  241. array_deps_required=("${array_deps_required[@]/libsdl2-2.0-0:i386/}")
  242. steamcmdstatus=1
  243. return
  244. elif [ "${deptocheck}" == "steamcmd" ] && [ -z "${appid}" ]; then
  245. array_deps_required=("${array_deps_required[@]/steamcmd/}")
  246. steamcmdstatus=1
  247. return
  248. elif [ "${deptocheck}" == "steamcmd" ] && [ "${distroid}" == "debian" ] && ! grep -qE '[^deb]+non-free([^-]|$)' /etc/apt/sources.list; then
  249. array_deps_required=("${array_deps_required[@]/steamcmd/}")
  250. steamcmdstatus=1
  251. return
  252. # Java: Added for users using Oracle JRE to bypass check.
  253. elif [[ ${deptocheck} == "openjdk"* ]] || [[ ${deptocheck} == "java"* ]]; then
  254. # Is java already installed?
  255. if [ -n "${javaversion}" ]; then
  256. # Added for users using Oracle JRE to bypass check.
  257. depstatus=0
  258. deptocheck="${javaversion}"
  259. else
  260. depstatus=1
  261. fi
  262. # Mono: A Mono repo needs to be installed.
  263. elif [ "${deptocheck}" == "mono-complete" ]; then
  264. if [ -n "${monoversion}" ] && [ "${monoversion}" -ge "5" ]; then
  265. # Mono >= 5.0.0 already installed.
  266. depstatus=0
  267. monoinstalled=true
  268. else
  269. # Mono not installed or installed Mono < 5.0.0.
  270. depstatus=1
  271. monoinstalled=false
  272. fi
  273. # .NET runtime: check installed runtime version for any dotnet-runtime-X.Y package.
  274. elif [[ "${deptocheck}" =~ ^dotnet-runtime-([0-9]+\.[0-9]+)$ ]]; then
  275. dotnetrequired="${BASH_REMATCH[1]}"
  276. if [ "$(command -v dotnet 2> /dev/null)" ] && dotnet --list-runtimes | grep -q "Microsoft.NETCore.App ${dotnetrequired}"; then
  277. depstatus=0
  278. dotnetinstalled=true
  279. else
  280. depstatus=1
  281. dotnetinstalled=false
  282. fi
  283. elif [ "$(command -v apt 2> /dev/null)" ]; then
  284. dpkg-query -W -f='${Status}' "${deptocheck}" 2> /dev/null | grep -q -P '^install ok installed'
  285. depstatus=$?
  286. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  287. dnf list installed "${deptocheck}" > /dev/null 2>&1
  288. depstatus=$?
  289. elif [ "$(command -v rpm 2> /dev/null)" ]; then
  290. rpm -q "${deptocheck}" > /dev/null 2>&1
  291. depstatus=$?
  292. fi
  293. # Outcome of Check.
  294. if [ "${steamcmdstatus}" == "1" ]; then
  295. # If SteamCMD is not available in repo dont check for it.
  296. unset steamcmdstatus
  297. elif [ "${depstatus}" == "0" ]; then
  298. # If dependency is found.
  299. missingdep=0
  300. if [ "${commandname}" == "INSTALL" ]; then
  301. echo -e "${green}${deptocheck}${default}"
  302. fn_sleep_time
  303. fi
  304. elif [ "${depstatus}" != "0" ]; then
  305. # If dependency is not found.
  306. missingdep=1
  307. if [ "${commandname}" == "INSTALL" ]; then
  308. echo -e "${red}${deptocheck}${default}"
  309. fn_sleep_time
  310. fi
  311. # If SteamCMD requirements are not met install will fail.
  312. if [ -n "${appid}" ]; then
  313. for steamcmddeptocheck in "${array_deps_required_steamcmd[@]}"; do
  314. if [ "${deptocheck}" != "steamcmd" ] && [ "${deptocheck}" == "${steamcmddeptocheck}" ]; then
  315. steamcmdfail=1
  316. fi
  317. done
  318. fi
  319. fi
  320. unset depstatus
  321. # Missing dependencies are added to array_deps_missing.
  322. if [ "${missingdep}" == "1" ]; then
  323. array_deps_missing+=("${deptocheck}")
  324. fi
  325. }
  326. if [ "${commandname}" == "INSTALL" ]; then
  327. if [ "$(whoami)" == "root" ]; then
  328. echo -e ""
  329. echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies as root${default}"
  330. fn_messages_separator
  331. fn_print_information_nl "Checking any missing dependencies for ${gamename} server only."
  332. fn_print_information_nl "This will NOT install a ${gamename} server."
  333. else
  334. echo -e ""
  335. echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies${default}"
  336. fn_messages_separator
  337. fi
  338. fi
  339. info_distro.sh
  340. # Will warn user if their distro is no longer supported by the vendor.
  341. if [ -n "${distrosupport}" ]; then
  342. if [ "${distrosupport}" == "unsupported" ]; then
  343. fn_print_warning_nl "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
  344. fn_script_log_warn "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
  345. fi
  346. fi
  347. # These titles are only supported up to Ubuntu 22.04 (Jammy) and Debian 12 (Bookworm).
  348. if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "22.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "12"; }; then
  349. if [ "${shortname}" == "bf1942" ] || [ "${shortname}" == "bfv" ]; then
  350. fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 22.04 or Debian <= 12)."
  351. fn_script_log_fail "${gamename} is not supported on ${distroname}."
  352. core_exit.sh
  353. fi
  354. fi
  355. # These titles are only supported up to Ubuntu 20.04 and Debian 11.
  356. if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "20.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "11"; }; then
  357. if [ "${shortname}" == "onset" ] || [ "${shortname}" == "btl" ]; then
  358. fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 20.04 or Debian <= 11)."
  359. fn_script_log_fail "${gamename} is not supported on ${distroname}."
  360. core_exit.sh
  361. fi
  362. fi
  363. # Vintage Story tracks newer .NET runtimes; older distro releases may not ship required packages.
  364. if [ "${shortname}" == "vints" ]; then
  365. if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "lt" "24.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "lt" "12"; } || [ "${distroid}" == "centos" ] || [ "${distroid}" == "rhel" ] || [ "${distroid}" == "rocky" ] || [ "${distroid}" == "almalinux" ]; then
  366. fn_print_warning_nl "${gamename} may require newer .NET runtimes than ${distroname} provides."
  367. echo -e "If startup fails due to missing .NET runtime, upgrading to Ubuntu 24.04+ or Debian 12+ is recommended."
  368. fn_script_log_warn "${gamename} may require newer .NET runtimes than ${distroname} provides."
  369. fi
  370. fi
  371. if [ ! -f "${tmpdir}/dependency-no-check.tmp" ] && [ ! -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
  372. # Check that the distro dependency csv file exists.
  373. fn_check_file_github "lgsm/data" "${distroid}-${distroversioncsv}.csv"
  374. if [ -n "${checkflag}" ] && [ "${checkflag}" == "0" ]; then
  375. fn_fetch_file_github "lgsm/data" "${distroid}-${distroversioncsv}.csv" "${datadir}" "chmodx" "norun" "noforce" "nohash"
  376. fi
  377. fi
  378. # If the file successfully downloaded run the dependency check.
  379. if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
  380. depall=$(awk -F, '$1=="all" {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  381. depsteamcmd=$(awk -F, '$1=="steamcmd" {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  382. depshortname=$(awk -v shortname="${shortname}" -F, '$1==shortname {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  383. # Generate array of missing deps.
  384. array_deps_missing=()
  385. array_deps_required=("${depall} ${depsteamcmd} ${depshortname}")
  386. array_deps_required_steamcmd=("${depsteamcmd}")
  387. fn_deps_email
  388. # Unique sort dependency array.
  389. IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
  390. fn_check_loop
  391. # Warn the user that dependency checking is unavailable for their distro.
  392. elif [ "${commandname}" == "INSTALL" ] || [ -n "${checkflag}" ] && [ "${checkflag}" != "0" ]; then
  393. fn_print_warning_nl "LinuxGSM dependency checking currently unavailable for ${distroname}."
  394. # Prevent future dependency checking if unavailable for the distro.
  395. echo "${version}" > "${tmpdir}/dependency-no-check.tmp"
  396. elif [ -f "${tmpdir}/dependency-no-check.tmp" ]; then
  397. # Allow LinuxGSM to try a dependency check if LinuxGSM has been recently updated.
  398. nocheckversion=$(cat "${tmpdir}/dependency-no-check.tmp")
  399. if [ "${version}" != "${nocheckversion}" ]; then
  400. rm -f "${tmpdir:?}/dependency-no-check.tmp"
  401. fi
  402. fi