From 9326d48684f3c679ed0ee2ecd03e3a7cfca3e0d1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Sep 2023 23:45:59 +0100 Subject: [PATCH] fix(mta): change updater to use builds (#4310) https://github.com/multitheftauto/mtasa-blue/issues/3176 --- lgsm/modules/update_mc.sh | 1 + lgsm/modules/update_mcb.sh | 2 ++ lgsm/modules/update_mta.sh | 16 ++++++++++------ lgsm/modules/update_pmc.sh | 1 + lgsm/modules/update_vints.sh | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lgsm/modules/update_mc.sh b/lgsm/modules/update_mc.sh index 85e903577..d65ee7563 100644 --- a/lgsm/modules/update_mc.sh +++ b/lgsm/modules/update_mc.sh @@ -11,6 +11,7 @@ fn_update_dl() { # Download and extract files to serverfiles. fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "chmodx" "norun" "noforce" "nohash" cp -f "${tmpdir}/${remotebuildfilename}" "${serverfiles}/${executable#./}" + fn_clear_tmp } fn_update_localbuild() { diff --git a/lgsm/modules/update_mcb.sh b/lgsm/modules/update_mcb.sh index b125a3c49..ceb284b39 100644 --- a/lgsm/modules/update_mcb.sh +++ b/lgsm/modules/update_mcb.sh @@ -23,10 +23,12 @@ fn_update_dl() { echo -e "${extractcmd}" >> "${lgsmlog}" fi echo -e "${extractcmd}" + fn_clear_tmp core_exit.sh else fn_print_ok_eol_nl fn_script_log_pass "Extracting ${local_filename}" + fn_clear_tmp fi } diff --git a/lgsm/modules/update_mta.sh b/lgsm/modules/update_mta.sh index eab77c748..fd728b22d 100644 --- a/lgsm/modules/update_mta.sh +++ b/lgsm/modules/update_mta.sh @@ -11,13 +11,17 @@ fn_update_dl() { # Download and extract files to tmpdir. fn_fetch_file "http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz" "" "" "" "${tmpdir}" "multitheftauto_linux_x64.tar.gz" "nochmodx" "norun" "force" "nohash" fn_dl_extract "${tmpdir}" "multitheftauto_linux_x64.tar.gz" "${serverfiles}" "multitheftauto_linux_x64" + fn_clear_tmp } fn_update_localbuild() { # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" - # Uses log file to get local build. - localbuild=$(grep "= Multi Theft Auto: San Andreas v" "${serverfiles}/mods/deathmatch/logs/server.log" | awk '{ print $7 }' | sed -r 's/^.{1}//' | tail -1) + # Uses executable to get local build. + if [ -d "${executabledir}" ]; then + cd "${executabledir}" || exit + localbuild=$(${executable} -v 2> /dev/null) + fi if [ -z "${localbuild}" ]; then fn_print_error "Checking local build: ${remotelocation}: missing local build info" fn_script_log_error "Missing local build info" @@ -31,11 +35,11 @@ fn_update_localbuild() { fn_update_remotebuild() { # Get remote build info. - apiurl="https://api.github.com/repos/multitheftauto/mtasa-blue/releases/latest" + apiurl="https://linux.multitheftauto.com/revision/latest.txt" remotebuildresponse=$(curl -s "${apiurl}") - remotebuildfilename=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .name') - remotebuildurl=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .browser_download_url') - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r '.tag_name') + remotebuildfilename="multitheftauto_linux_x64.tar.gz" + remotebuildurl="http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz" + remotebuildversion=$(echo "${remotebuildresponse}") if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuildversion variable has been set. diff --git a/lgsm/modules/update_pmc.sh b/lgsm/modules/update_pmc.sh index 5154bfeb9..56d36a09b 100644 --- a/lgsm/modules/update_pmc.sh +++ b/lgsm/modules/update_pmc.sh @@ -12,6 +12,7 @@ fn_update_dl() { fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "chmodx" "norun" "force" "${remotebuildhash}" cp -f "${tmpdir}/${remotebuildfilename}" "${serverfiles}/${executable#./}" echo "${remotebuildversion}" > "${serverfiles}/build.txt" + fn_clear_tmp } fn_update_localbuild() { diff --git a/lgsm/modules/update_vints.sh b/lgsm/modules/update_vints.sh index 75755248c..d545a9c83 100644 --- a/lgsm/modules/update_vints.sh +++ b/lgsm/modules/update_vints.sh @@ -20,7 +20,7 @@ fn_update_localbuild() { # Uses executable to get local build. if [ -d "${executabledir}" ]; then cd "${executabledir}" || exit - localbuild="$(${preexecutable} ${executable} --version | sed '/^[[:space:]]*$/d')" + localbuild="$(${preexecutable} ${executable} --version 2> /dev/null | sed '/^[[:space:]]*$/d')" fi if [ -z "${localbuild}" ]; then fn_print_error "Checking local build: ${remotelocation}: missing local build info"