From 4c181d48b4372174c4026f2fddb27780a991fd9a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 29 Sep 2024 22:16:29 +0100 Subject: [PATCH] att bootstrap fetch module --- lgsm/modules/core_modules.sh | 5 +++++ linuxgsm.sh | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index d040cf942..75a98ddd8 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -42,6 +42,11 @@ core_legacy.sh() { core_exit.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + echo "fn_fetch_module failed, using fn_bootstrap_fetch_module instead." + fn_bootstrap_fetch_module + fi } core_getopt.sh() { diff --git a/linuxgsm.sh b/linuxgsm.sh index 9847c31ef..8bfd6e466 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -82,6 +82,30 @@ fn_bootstrap_fetch_trap() { core_exit.sh } +# Fetches modules from the Git repo during first download. +fn_bootstrap_fetch_module() { + github_file_url_dir="lgsm/modules" + github_file_url_name="${modulefile}" + # If master branch will currently running LinuxGSM version to prevent "version mixing". This is ignored if a fork. + if [ "${githubbranch}" == "master" ] && [ "${githubuser}" == "GameServerManagers" ] && [ "${commandname}" != "UPDATE-LGSM" ]; then + remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${version}/${github_file_url_dir}/${github_file_url_name}" + remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${version}/${github_file_url_dir}/${github_file_url_name}" + else + remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" + remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" + fi + remote_fileurl_name="GitHub" + remote_fileurl_backup_name="Bitbucket" + local_filedir="${modulesdir}" + local_filename="${github_file_url_name}" + chmodx="chmodx" + run="run" + forcedl="noforce" + hash="nohash" + # Passes vars to the file download module. + fn_fetch_file "${remote_fileurl}" "${remote_fileurl_backup}" "${remote_fileurl_name}" "${remote_fileurl_backup_name}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${hash}" +} + fn_bootstrap_fetch_file() { remote_fileurl="${1}" remote_fileurl_backup="${2}"