check_deps.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 apt 2> /dev/null)" ] && [ -d /etc/nullmailer ]; then
  120. # 'mailutils' provides the 'mail' binary, 'nullmailer' is the MTA
  121. array_deps_required+=(mailutils nullmailer)
  122. elif [ "$(command -v yum 2> /dev/null)" ] || [ "$(command -v dnf 2> /dev/null)" ]; then
  123. array_deps_required+=(s-nail postfix)
  124. elif [ "$(command -v apt 2> /dev/null)" ]; then
  125. array_deps_required+=(mailutils postfix)
  126. fi
  127. else
  128. if [ "$(command -v yum 2> /dev/null)" ] || [ "$(command -v dnf 2> /dev/null)" ]; then
  129. array_deps_required+=(s-nail postfix)
  130. elif [ "$(command -v apt 2> /dev/null)" ]; then
  131. array_deps_required+=(mailutils postfix)
  132. fi
  133. fi
  134. fi
  135. }
  136. fn_install_missing_deps() {
  137. # If any dependencies are not installed.
  138. if [ "${#array_deps_missing[*]}" != "0" ]; then
  139. if [ "${commandname}" == "INSTALL" ]; then
  140. fn_print_warning_nl "Missing dependencies: ${red}${array_deps_missing[*]}${default}"
  141. fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
  142. else
  143. fn_print_dots "Missing dependencies"
  144. fn_print_warn "Missing dependencies: ${red}${array_deps_missing[*]}${default}"
  145. fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
  146. fi
  147. # Attempt automatic dependency installation
  148. if [ "${autoinstall}" == "1" ]; then
  149. sudo -n true > /dev/null 2>&1
  150. else
  151. sudo -v > /dev/null 2>&1
  152. fi
  153. autodepinstall="$?"
  154. if [ "${monoinstalled}" == "false" ]; then
  155. fn_install_mono_repo
  156. fi
  157. if [ "${dotnetinstalled}" == "false" ]; then
  158. fn_install_dotnet_repo
  159. fi
  160. if [ "${commandname}" == "INSTALL" ]; then
  161. if [ "${autodepinstall}" == "0" ]; then
  162. fn_print_information_nl "$(whoami) has sudo access."
  163. fn_script_log_info "$(whoami) has sudo access."
  164. else
  165. fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies or run ./${selfname} install as root."
  166. fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies or run ./${selfname} install as root."
  167. fi
  168. fi
  169. # Add sudo dpkg --add-architecture i386 if using i386 packages.
  170. if [ "$(command -v apt 2> /dev/null)" ]; then
  171. if printf '%s\n' "${array_deps_required[@]}" | grep -q -P 'i386'; then
  172. i386installcommand="sudo dpkg --add-architecture i386; "
  173. fi
  174. fi
  175. # If automatic dependency install is available
  176. if [ "${autodepinstall}" == "0" ]; then
  177. fn_print_information_nl "Automatically installing missing dependencies."
  178. fn_script_log_info "Automatically installing missing dependencies."
  179. echo -en ".\r"
  180. fn_sleep_time_1
  181. echo -en "..\r"
  182. fn_sleep_time_1
  183. echo -en "...\r"
  184. fn_sleep_time_1
  185. echo -en " \r"
  186. if [ "$(command -v apt 2> /dev/null)" ]; then
  187. 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[*]}"
  188. eval "${cmd}"
  189. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  190. cmd="sudo dnf -y install ${array_deps_missing[*]}"
  191. eval "${cmd}"
  192. elif [ "$(command -v yum 2> /dev/null)" ]; then
  193. cmd="sudo yum -y install ${array_deps_missing[*]}"
  194. eval "${cmd}"
  195. fi
  196. autodepinstall="$?"
  197. # If auto install passes, remove steamcmd install failure and set exit code to 0.
  198. if [ "${autodepinstall}" == "0" ]; then
  199. unset steamcmdfail
  200. exitcode=0
  201. fi
  202. fi
  203. # If automatic dependency install is unavailable.
  204. if [ "${autodepinstall}" != "0" ]; then
  205. if [ "$(command -v apt 2> /dev/null)" ]; then
  206. echo -e " Run: '${green}${i386installcommand}sudo apt update; sudo apt install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  207. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  208. echo -e " Run: '${green}sudo dnf install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  209. elif [ "$(command -v yum 2> /dev/null)" ]; then
  210. echo -e " Run: '${green}sudo yum install ${array_deps_missing[*]}${default}' as root to install missing dependencies."
  211. fi
  212. fi
  213. if [ "${steamcmdfail}" ]; then
  214. if [ "${commandname}" == "INSTALL" ]; then
  215. fn_print_failure_nl "Missing dependencies required to run SteamCMD."
  216. fn_script_log_fail "Missing dependencies required to run SteamCMD."
  217. core_exit.sh
  218. else
  219. fn_print_error_nl "Missing dependencies required to run SteamCMD."
  220. fn_script_log_error "Missing dependencies required to run SteamCMD."
  221. fi
  222. fi
  223. else
  224. if [ "${commandname}" == "INSTALL" ]; then
  225. fn_print_skip2_nl "Required dependencies already installed."
  226. fn_script_log_info "Required dependencies already installed."
  227. fi
  228. fi
  229. }
  230. fn_check_loop() {
  231. # Loop though required dependencies checking if they are installed.
  232. for deptocheck in "${array_deps_required[@]}"; do
  233. fn_deps_detector
  234. done
  235. # user will be informed of any missing dependencies.
  236. fn_install_missing_deps
  237. }
  238. # Checks if dependency is installed or not.
  239. fn_deps_detector() {
  240. ## Check.
  241. # SteamCMD: Will be removed from required array if no appid is present or non-free repo is not available.
  242. # This will cause SteamCMD to be installed using tar.
  243. if [ "${deptocheck}" == "libsdl2-2.0-0:i386" ] && [ -z "${appid}" ]; then
  244. array_deps_required=("${array_deps_required[@]/libsdl2-2.0-0:i386/}")
  245. steamcmdstatus=1
  246. return
  247. elif [ "${deptocheck}" == "steamcmd" ] && [ -z "${appid}" ]; then
  248. array_deps_required=("${array_deps_required[@]/steamcmd/}")
  249. steamcmdstatus=1
  250. return
  251. elif [ "${deptocheck}" == "steamcmd" ] && [ "${distroid}" == "debian" ] && ! grep -qE '[^deb]+non-free([^-]|$)' /etc/apt/sources.list; then
  252. array_deps_required=("${array_deps_required[@]/steamcmd/}")
  253. steamcmdstatus=1
  254. return
  255. # Java: Added for users using Oracle JRE to bypass check.
  256. elif [[ ${deptocheck} == "openjdk"* ]] || [[ ${deptocheck} == "java"* ]]; then
  257. # Is java already installed?
  258. if [ -n "${javaversion}" ]; then
  259. # Added for users using Oracle JRE to bypass check.
  260. depstatus=0
  261. deptocheck="${javaversion}"
  262. else
  263. depstatus=1
  264. fi
  265. # Mono: A Mono repo needs to be installed.
  266. elif [ "${deptocheck}" == "mono-complete" ]; then
  267. if [ -n "${monoversion}" ] && [ "${monoversion}" -ge "5" ]; then
  268. # Mono >= 5.0.0 already installed.
  269. depstatus=0
  270. monoinstalled=true
  271. else
  272. # Mono not installed or installed Mono < 5.0.0.
  273. depstatus=1
  274. monoinstalled=false
  275. fi
  276. # .NET runtime: check installed runtime version for any dotnet-runtime-X.Y package.
  277. elif [[ "${deptocheck}" =~ ^dotnet-runtime-([0-9]+\.[0-9]+)$ ]]; then
  278. dotnetrequired="${BASH_REMATCH[1]}"
  279. if [ "$(command -v dotnet 2> /dev/null)" ] && dotnet --list-runtimes | grep -q "Microsoft.NETCore.App ${dotnetrequired}"; then
  280. depstatus=0
  281. dotnetinstalled=true
  282. else
  283. depstatus=1
  284. dotnetinstalled=false
  285. fi
  286. elif [ "$(command -v apt 2> /dev/null)" ]; then
  287. dpkg-query -W -f='${Status}' "${deptocheck}" 2> /dev/null | grep -q -P '^install ok installed'
  288. depstatus=$?
  289. elif [ "$(command -v dnf 2> /dev/null)" ]; then
  290. dnf list installed "${deptocheck}" > /dev/null 2>&1
  291. depstatus=$?
  292. elif [ "$(command -v rpm 2> /dev/null)" ]; then
  293. rpm -q "${deptocheck}" > /dev/null 2>&1
  294. depstatus=$?
  295. fi
  296. # Outcome of Check.
  297. if [ "${steamcmdstatus}" == "1" ]; then
  298. # If SteamCMD is not available in repo dont check for it.
  299. unset steamcmdstatus
  300. elif [ "${depstatus}" == "0" ]; then
  301. # If dependency is found.
  302. missingdep=0
  303. if [ "${commandname}" == "INSTALL" ]; then
  304. echo -e "${green}${deptocheck}${default}"
  305. fn_sleep_time
  306. fi
  307. elif [ "${depstatus}" != "0" ]; then
  308. # If dependency is not found.
  309. missingdep=1
  310. if [ "${commandname}" == "INSTALL" ]; then
  311. echo -e "${red}${deptocheck}${default}"
  312. fn_sleep_time
  313. fi
  314. # If SteamCMD requirements are not met install will fail.
  315. if [ -n "${appid}" ]; then
  316. for steamcmddeptocheck in "${array_deps_required_steamcmd[@]}"; do
  317. if [ "${deptocheck}" != "steamcmd" ] && [ "${deptocheck}" == "${steamcmddeptocheck}" ]; then
  318. steamcmdfail=1
  319. fi
  320. done
  321. fi
  322. fi
  323. unset depstatus
  324. # Missing dependencies are added to array_deps_missing.
  325. if [ "${missingdep}" == "1" ]; then
  326. array_deps_missing+=("${deptocheck}")
  327. fi
  328. }
  329. if [ "${commandname}" == "INSTALL" ]; then
  330. if [ "$(whoami)" == "root" ]; then
  331. echo -e ""
  332. echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies as root${default}"
  333. fn_messages_separator
  334. fn_print_information_nl "Checking any missing dependencies for ${gamename} server only."
  335. fn_print_information_nl "This will NOT install a ${gamename} server."
  336. else
  337. echo -e ""
  338. echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies${default}"
  339. fn_messages_separator
  340. fi
  341. fi
  342. info_distro.sh
  343. # Will warn user if their distro is no longer supported by the vendor.
  344. if [ -n "${distrosupport}" ]; then
  345. if [ "${distrosupport}" == "unsupported" ]; then
  346. fn_print_warning_nl "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
  347. fn_script_log_warn "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
  348. fi
  349. fi
  350. # These titles are only supported up to Ubuntu 22.04 (Jammy) and Debian 12 (Bookworm).
  351. if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "22.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "12"; }; then
  352. if [ "${shortname}" == "bf1942" ] || [ "${shortname}" == "bfv" ]; then
  353. fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 22.04 or Debian <= 12)."
  354. fn_script_log_fail "${gamename} is not supported on ${distroname}."
  355. core_exit.sh
  356. fi
  357. fi
  358. # These titles are only supported up to Ubuntu 20.04 and Debian 11.
  359. if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "20.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "11"; }; then
  360. if [ "${shortname}" == "onset" ] || [ "${shortname}" == "btl" ]; then
  361. fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 20.04 or Debian <= 11)."
  362. fn_script_log_fail "${gamename} is not supported on ${distroname}."
  363. core_exit.sh
  364. fi
  365. fi
  366. # Vintage Story tracks newer .NET runtimes; older distro releases may not ship required packages.
  367. if [ "${shortname}" == "vints" ]; then
  368. 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
  369. fn_print_warning_nl "${gamename} may require newer .NET runtimes than ${distroname} provides."
  370. echo -e "If startup fails due to missing .NET runtime, upgrading to Ubuntu 24.04+ or Debian 12+ is recommended."
  371. fn_script_log_warn "${gamename} may require newer .NET runtimes than ${distroname} provides."
  372. fi
  373. fi
  374. if [ ! -f "${tmpdir}/dependency-no-check.tmp" ] && [ ! -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
  375. # Check that the distro dependency csv file exists.
  376. fn_check_file_github "lgsm/data" "${distroid}-${distroversioncsv}.csv"
  377. if [ -n "${checkflag}" ] && [ "${checkflag}" == "0" ]; then
  378. fn_fetch_file_github "lgsm/data" "${distroid}-${distroversioncsv}.csv" "${datadir}" "chmodx" "norun" "noforce" "nohash"
  379. fi
  380. fi
  381. # If the file successfully downloaded run the dependency check.
  382. if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
  383. depall=$(awk -F, '$1=="all" {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  384. depsteamcmd=$(awk -F, '$1=="steamcmd" {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  385. depshortname=$(awk -v shortname="${shortname}" -F, '$1==shortname {$1=""; print $0}' "${datadir}/${distroid}-${distroversioncsv}.csv")
  386. # Generate array of missing deps.
  387. array_deps_missing=()
  388. array_deps_required=("${depall} ${depsteamcmd} ${depshortname}")
  389. array_deps_required_steamcmd=("${depsteamcmd}")
  390. fn_deps_email
  391. # Unique sort dependency array.
  392. IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
  393. fn_check_loop
  394. # Warn the user that dependency checking is unavailable for their distro.
  395. elif [ "${commandname}" == "INSTALL" ] || [ -n "${checkflag}" ] && [ "${checkflag}" != "0" ]; then
  396. fn_print_warning_nl "LinuxGSM dependency checking currently unavailable for ${distroname}."
  397. # Prevent future dependency checking if unavailable for the distro.
  398. echo "${version}" > "${tmpdir}/dependency-no-check.tmp"
  399. elif [ -f "${tmpdir}/dependency-no-check.tmp" ]; then
  400. # Allow LinuxGSM to try a dependency check if LinuxGSM has been recently updated.
  401. nocheckversion=$(cat "${tmpdir}/dependency-no-check.tmp")
  402. if [ "${version}" != "${nocheckversion}" ]; then
  403. rm -f "${tmpdir:?}/dependency-no-check.tmp"
  404. fi
  405. fi