check_deps.sh 21 KB

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