From da25c52880511cc87c86580ad5184b6279f0d5f7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 10 Jul 2023 21:42:26 +0100 Subject: [PATCH] refactor: improve appmanifest check and force update logic The code changes refactor the `fn_appmanifest_check` function in the `core_steamcmd.sh` file. The improvements include: - Checking if `BytesDownloaded` and `BytesToDownload` match, and forcing an update if they don't. - Checking if `BytesStaged` and `BytesToStage` match, and forcing an update if they don't. - For GoldSrc engine, checking if `SharedDepots` exists in the appmanifest file, and forcing an update if it doesn't. - Fetching missing appmanifest files from GitHub for specific game shortnames. These changes enhance the reliability of the appmanifest check process and ensure that updates are forced when necessary. --- lgsm/modules/core_steamcmd.sh | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/lgsm/modules/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index 78c30f60ae..8088beced0 100644 --- a/lgsm/modules/core_steamcmd.sh +++ b/lgsm/modules/core_steamcmd.sh @@ -327,4 +327,76 @@ fn_appmanifest_check() { core_exit.sh fi fi + + bytesdownloaded=$(grep BytesDownloaded "${appmanifestfile}" | tr -cd '[:digit:]') + bytestodownload=$(grep BytesToDownload "${appmanifestfile}" | tr -cd '[:digit:]') + # if bytesdownloaded and bytestodownload do no match force update + if [ "${bytesdownloaded}" != "${bytestodownload}" ]; then + fn_print_error_nl "BytesDownloaded and BytesToDownload do not match" + fn_script_log_error "BytesDownloaded and BytesToDownload do not match" + fn_print_info_nl "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" + fn_dl_steamcmd + fi + + bytesstaged=$(grep BytesStaged "${appmanifestfile}" | tr -cd '[:digit:]') + bytestostage=$(grep BytesToStage "${appmanifestfile}" | tr -cd '[:digit:]') + # if bytesstaged and bytestostage do no match force update + if [ "${bytesstaged}" != "${bytestostage}" ]; then + fn_print_error_nl "BytesStaged and BytesToStage do not match" + fn_script_log_error "BytesStaged and BytesToStage do not match" + fn_print_info_nl "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" + fn_dl_steamcmd + fi + + # if engine is GoldSrc check SharedDepots exists in appmanifest_90.acf + if [ "${engine}" == "goldsrc" ]; then + shareddepotsexists=$(grep -c SharedDepots "${serverfiles}/steamapps/appmanifest_90.acf") + if [ ! -f "${serverfiles}/steamapps/appmanifest_90.acf" ] || [ "${shareddepotsexists}" == "0" ]; then + fn_print_error_nl "SharedDepots missing from appmanifest_${appid}.acf" + fn_script_log_error "SharedDepots missing from appmanifest_${appid}.acf" + fn_print_info_nl "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" + if [ "${shortname}" == "css" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "cscz" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_80.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "dmc" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_40.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "dod" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_30.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "hldm" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "opfor" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_50.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "ricochet" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_60.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + elif [ "${shortname}" == "tfc" ]; then + fn_fetch_file_github "data" "appmanifest_90.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_10.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_20.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file_github "data" "appmanifest_70.acf" "${serverfiles}/steamapps" "nochmodx" "norun" "noforce" "nohash" + fi + fi + fi }