From b23061b12b07f635c502db8d42520c8e88671624 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 22 Mar 2023 21:30:31 +0000 Subject: [PATCH] fixes --- lgsm/functions/core_steamcmd.sh | 44 ++++++++++++++++++--------- lgsm/functions/update_factorio.sh | 6 ++-- lgsm/functions/update_minecraft.sh | 6 ++-- lgsm/functions/update_vintagestory.sh | 6 ++-- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/lgsm/functions/core_steamcmd.sh b/lgsm/functions/core_steamcmd.sh index 89746c4c0..97a3b5878 100755 --- a/lgsm/functions/core_steamcmd.sh +++ b/lgsm/functions/core_steamcmd.sh @@ -14,7 +14,7 @@ fn_install_steamcmd() { if [ ! -d "${steamcmddir}" ]; then mkdir -p "${steamcmddir}" fi - fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "" "" "" "${tmpdir}" "steamcmd_linux.tar.gz" "" "norun" "noforce" "nohash" + fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "" "" "" "${tmpdir}" "steamcmd_linux.tar.gz" "nochmodx" "norun" "noforce" "nohash" fn_dl_extract "${tmpdir}" "steamcmd_linux.tar.gz" "${steamcmddir}" chmod +x "${steamcmddir}/steamcmd.sh" } @@ -157,9 +157,9 @@ fn_update_steamcmd_localbuild() { fi # Checks if localbuild variable has been set. - if [ -z "${localbuild}" ] || [ "${localbuild}" == "null" ]; then - fn_print_fail "Checking local build: ${remotelocation}" - fn_script_log_fatal "Checking local build" + if [ -z "${localbuild}" ]; then + fn_print_fail "Checking local build: ${remotelocation}: missing local build info" + fn_script_log_fatal "Missing local build info" core_exit.sh else fn_print_ok "Checking local build: ${remotelocation}" @@ -179,12 +179,12 @@ fn_update_steamcmd_remotebuild() { fi # password for branch not needed to check the buildid - remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]') + remotebuildversion=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuild variable has been set. - if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then + # Checks if remotebuildversion variable has been set. + if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh @@ -194,7 +194,7 @@ fn_update_steamcmd_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then + if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fatal "Unable to get remote build" core_exit.sh @@ -204,12 +204,12 @@ fn_update_steamcmd_remotebuild() { fn_update_steamcmd_compare() { fn_print_dots "Checking for update: ${remotelocation}" - if [ "${localbuild}" != "${remotebuild}" ]; then + if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuild}${default}" + echo -e "* Remote build: ${green}${remotebuildversion}${default}" if [ -n "${branch}" ]; then echo -e "* Branch: ${branch}" fi @@ -217,17 +217,24 @@ fn_update_steamcmd_compare() { echo -e "* Branch password: ${betapassword}" fi echo -e "https://steamdb.info/app/${appid}/" + if [ -f "${rootdir}/.dev-debug" ]; then + echo -e "Remote build info" + echo -e "* apiurl: ${apiurl}" + echo -e "* remotebuildfilename: ${remotebuildfilename}" + echo -e "* remotebuildurl: ${remotebuildurl}" + echo -e "* remotebuildversion: ${remotebuildversion}" + fi echo -en "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuild}" + fn_script_log_info "Remote build: ${remotebuildversion}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -n "${betapassword}" ]; then fn_script_log_info "Branch password: ${betapassword}" fi - fn_script_log_info "${localbuild} > ${remotebuild}" + fn_script_log_info "${localbuild} > ${remotebuildversion}" if [ "${commandname}" == "UPDATE" ]; then unset updateonstart @@ -246,8 +253,8 @@ fn_update_steamcmd_compare() { exitbypass=1 command_start.sh fn_firstcommand_reset - unset exitbypass fi + unset exitbypass date +%s > "${lockdir}/lastupdate.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then @@ -259,7 +266,7 @@ fn_update_steamcmd_compare() { echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuild}${default}" + echo -e "* Remote build: ${green}${remotebuildversion}${default}" if [ -n "${branch}" ]; then echo -e "* Branch: ${branch}" fi @@ -270,13 +277,20 @@ fn_update_steamcmd_compare() { echo -en "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuild}" + fn_script_log_info "Remote build: ${remotebuildversion}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -n "${betapassword}" ]; then fn_script_log_info "Branch password: ${betapassword}" fi + if [ -f "${rootdir}/.dev-debug" ]; then + echo -e "Remote build info" + echo -e "* apiurl: ${apiurl}" + echo -e "* remotebuildfilename: ${remotebuildfilename}" + echo -e "* remotebuildurl: ${remotebuildurl}" + echo -e "* remotebuildversion: ${remotebuildversion}" + fi fi } diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index 981718f3f..7c6a3a63d 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -18,8 +18,10 @@ fn_update_localbuild() { # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" # Uses executable to get local build. - cd "${executabledir}" || exit - localbuild=$(${executable} --version | grep "Version:" | awk '{print $2}') + if [ -d "${exutabledir}" ]; then + cd "${executabledir}" || exit + localbuild=$(${executable} --version | grep "Version:" | awk '{print $2}') + fi if [ -z "${localbuild}" ]; then fn_print_error "Checking local build: ${remotelocation}: missing local build info" fn_script_log_error "Missing local build info" diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index 74194cac3..211753598 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -16,8 +16,10 @@ fn_update_localbuild() { # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" # Uses executable to get local build. - cd "${executabledir}" || exit - localbuild=$(unzip -p "minecraft_server.jar" version.json | jq -r '.id') + if [ -d "${exutabledir}" ]; then + cd "${executabledir}" || exit + localbuild=$(unzip -p "minecraft_server.jar" version.json | jq -r '.id') + fi if [ -z "${localbuild}" ]; then fn_print_error "Checking local build: ${remotelocation}: missing local build info" fn_script_log_error "Missing local build info" diff --git a/lgsm/functions/update_vintagestory.sh b/lgsm/functions/update_vintagestory.sh index 9e49fd0d4..84e3192c9 100755 --- a/lgsm/functions/update_vintagestory.sh +++ b/lgsm/functions/update_vintagestory.sh @@ -18,8 +18,10 @@ fn_update_localbuild() { # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" # Uses executable to get local build. - cd "${executabledir}" || exit - localbuild="$(${preexecutable} ${executable} --version | sed '/^[[:space:]]*$/d')" + if [ -d "${exutabledir}" ]; then + cd "${executabledir}" || exit + localbuild="$(${preexecutable} ${executable} --version | sed '/^[[:space:]]*$/d')" + fi if [ -z "${localbuild}" ]; then fn_print_error "Checking local build: ${remotelocation}: missing local build info" fn_script_log_error "Missing local build info"