check_deps.sh 22 KB

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