diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index 0eef7c6da..138ccdab1 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -68,10 +68,7 @@ fn_update_factorio_remotebuild() { fn_update_factorio_compare() { fn_print_dots "Checking for update: ${remotelocation}" - # Removes dots so if statement can compare version numbers. - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/functions/update_jediknight2.sh b/lgsm/functions/update_jediknight2.sh index ba52d51a6..402c43539 100644 --- a/lgsm/functions/update_jediknight2.sh +++ b/lgsm/functions/update_jediknight2.sh @@ -65,11 +65,8 @@ fn_update_jk2_remotebuild() { } fn_update_jk2_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index 28fdcaf06..bb7aecaeb 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -9,9 +9,9 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_minecraft_dl() { # Generate link to version manifest json. - remotebuildlink=$(curl -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r --arg branch ${branch} --arg mcversion ${remotebuild} '.versions | .[] | select(.type==$branch and .id==$mcversion) | .url') + remotebuildurl=$(curl -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r --arg branch ${branch} --arg mcversion ${remotebuild} '.versions | .[] | select(.type==$branch and .id==$mcversion) | .url') # Generate link to server.jar - remotebuildurl=$(curl -s "${remotebuildlink}" | jq -r '.downloads.server.url') + remotebuildurl=$(curl -s "${remotebuildurl}" | jq -r '.downloads.server.url') fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "minecraft_server.${remotebuild}.jar" "" "norun" "noforce" "nohash" echo -e "copying to ${serverfiles}...\c" @@ -82,7 +82,6 @@ fn_update_minecraft_remotebuild() { } fn_update_minecraft_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" diff --git a/lgsm/functions/update_minecraft_bedrock.sh b/lgsm/functions/update_minecraft_bedrock.sh index e4422dc15..91aa2c3fd 100644 --- a/lgsm/functions/update_minecraft_bedrock.sh +++ b/lgsm/functions/update_minecraft_bedrock.sh @@ -78,11 +78,8 @@ fn_update_minecraft_remotebuild() { } fn_update_minecraft_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/functions/update_mta.sh b/lgsm/functions/update_mta.sh index cfb45e8b6..feb988360 100644 --- a/lgsm/functions/update_mta.sh +++ b/lgsm/functions/update_mta.sh @@ -67,11 +67,8 @@ fn_update_mta_remotebuild() { } fn_update_mta_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then if [ "${forceupdate}" == "1" ]; then # forceupdate bypasses checks, useful for small build changes mtaupdatestatus="forced" @@ -89,35 +86,39 @@ fn_update_mta_compare() { fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - unset updateonstart - check_status.sh - # If server stopped. - if [ "${status}" == "0" ]; then - exitbypass=1 - fn_update_mta_dl - if [ "${localbuild}" == "0" ]; then + if [ "${commandname}" == "UPDATE" ]; then + unset updateonstart + check_status.sh + # If server stopped. + if [ "${status}" == "0" ]; then exitbypass=1 - command_start.sh - fn_firstcommand_reset + fn_update_mta_dl + if [ "${localbuild}" == "0" ]; then + exitbypass=1 + command_start.sh + fn_firstcommand_reset + exitbypass=1 + command_stop.sh + fn_firstcommand_reset + fi + # If server started. + else + fn_print_restart_warning exitbypass=1 command_stop.sh fn_firstcommand_reset + exitbypass=1 + fn_update_mta_dl + exitbypass=1 + command_start.sh + fn_firstcommand_reset fi - # If server started. - else - fn_print_restart_warning - exitbypass=1 - command_stop.sh - fn_firstcommand_reset - exitbypass=1 - fn_update_mta_dl - exitbypass=1 - command_start.sh - fn_firstcommand_reset + unset exitbypass + date +%s > "${lockdir}/lastupdate.lock" + alert="update" + elif [ "${commandname}" == "CHECK-UPDATE" ]; then + alert="check-update" fi - unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" - alert="update" alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 8ae22e369..aa36fe8d5 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -81,11 +81,8 @@ fn_update_ts3_remotebuild() { } fn_update_ts3_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/functions/update_ut99.sh b/lgsm/functions/update_ut99.sh index 242bead7d..c205532d3 100644 --- a/lgsm/functions/update_ut99.sh +++ b/lgsm/functions/update_ut99.sh @@ -8,23 +8,12 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_ut99_dl() { - remotebuildlink=$(curl --connect-timeout 10 -sL "https://api.github.com/repos/OldUnreal/UnrealTournamentPatches/releases/latest" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .browser_download_url') + remotebuildurl=$(curl --connect-timeout 10 -sL "https://api.github.com/repos/OldUnreal/UnrealTournamentPatches/releases/latest" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .browser_download_url') remotebuildfilename=$(curl --connect-timeout 10 -sL "https://api.github.com/repos/OldUnreal/UnrealTournamentPatches/releases/latest" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .name') - fn_fetch_file "${remotebuildlink}" "${tmpdir}" "${remotebuildfilename}" "" "norun" "noforce" "nohash" + fn_fetch_file "${remotebuildurl}" "${tmpdir}" "${remotebuildfilename}" "" "norun" "noforce" "nohash" fn_dl_extract "${tmpdir}" "${remotebuildfilename}" "${serverfiles}" - local exitcode=$? - if [ "${exitcode}" == "0" ]; then - fn_print_ok_eol_nl - fn_script_log_pass "Copying to ${serverfiles}" - fn_clear_tmp - # put version number in version.txt - echo "${remotebuild}" > "${serverfiles}/version.txt" - else - fn_print_fail_eol_nl - fn_script_log_fatal "Copying to ${serverfiles}" - core_exit.sh - fi + echo "${remotebuild}" > "${serverfiles}/build.txt" } fn_update_ut99_localbuild() { @@ -68,11 +57,8 @@ fn_update_ut99_remotebuild() { } fn_update_ut99_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" - localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') - remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') - if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -84,35 +70,39 @@ fn_update_ut99_compare() { fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - unset updateonstart - check_status.sh - # If server stopped. - if [ "${status}" == "0" ]; then - exitbypass=1 - fn_update_ut99_dl - if [ "${localbuild}" == "0" ]; then + if [ "${commandname}" == "UPDATE" ]; then + unset updateonstart + check_status.sh + # If server stopped. + if [ "${status}" == "0" ]; then exitbypass=1 - command_start.sh - fn_firstcommand_reset + fn_update_ut99_dl + if [ "${localbuild}" == "0" ]; then + exitbypass=1 + command_start.sh + fn_firstcommand_reset + exitbypass=1 + command_stop.sh + fn_firstcommand_reset + fi + # If server started. + else + fn_print_restart_warning exitbypass=1 command_stop.sh fn_firstcommand_reset + exitbypass=1 + fn_update_ut99_dl + exitbypass=1 + command_start.sh + fn_firstcommand_reset fi - # If server started. - else - fn_print_restart_warning - exitbypass=1 - command_stop.sh - fn_firstcommand_reset - exitbypass=1 - fn_update_ut99_dl - exitbypass=1 - command_start.sh - fn_firstcommand_reset + unset exitbypass + date +%s > "${lockdir}/lastupdate.lock" + alert="update" + elif [ "${commandname}" == "CHECK-UPDATE" ]; then + alert="check-update" fi - unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" - alert="update" alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" @@ -130,8 +120,6 @@ fn_update_ut99_compare() { # The location where the builds are checked and downloaded. remotelocation="github.com" -localbuildfile="${serverfiles}/version.txt" - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_ut99_remotebuild fn_update_ut99_dl diff --git a/lgsm/functions/update_vintagestory.sh b/lgsm/functions/update_vintagestory.sh index eb5d3fadd..1ed336eae 100755 --- a/lgsm/functions/update_vintagestory.sh +++ b/lgsm/functions/update_vintagestory.sh @@ -11,11 +11,11 @@ fn_update_vs_dl() { # get version info for download remotebuildresponse=$(curl -s "${apiurl}" | jq --arg version "${remotebuild}" '.[$version].server') remotebuildfile=$(echo -e "${remotebuildresponse}" | jq -r '.filename') - remotebuildlink=$(echo -e "${remotebuildresponse}" | jq -r '.urls.cdn') + remotebuildurl=$(echo -e "${remotebuildresponse}" | jq -r '.urls.cdn') remotebuildmd5=$(echo -e "${remotebuildresponse}" | jq -r '.md5') # Download and extract files to serverfiles - fn_fetch_file "${remotebuildlink}" "" "" "" "${tmpdir}" "${remotebuildfile}" "nochmodx" "norun" "force" "${remotebuildmd5}" + fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfile}" "nochmodx" "norun" "force" "${remotebuildmd5}" fn_dl_extract "${tmpdir}" "${remotebuildfile}" "${serverfiles}" fn_clear_tmp } @@ -66,7 +66,6 @@ fn_update_vs_remotebuild() { } fn_update_vs_compare() { - # Removes dots so if statement can compare version numbers. fn_print_dots "Checking for update: ${remotelocation}" if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" @@ -83,35 +82,39 @@ fn_update_vs_compare() { fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - unset updateonstart - check_status.sh - # If server stopped. - if [ "${status}" == "0" ]; then - exitbypass=1 - fn_update_vs_dl - if [ "${localbuild}" == "0" ]; then + if [ "${commandname}" == "UPDATE" ]; then + unset updateonstart + check_status.sh + # If server stopped. + if [ "${status}" == "0" ]; then exitbypass=1 - command_start.sh - fn_firstcommand_reset + fn_update_vs_dl + if [ "${localbuild}" == "0" ]; then + exitbypass=1 + command_start.sh + fn_firstcommand_reset + exitbypass=1 + command_stop.sh + fn_firstcommand_reset + fi + # If server started. + else + fn_print_restart_warning exitbypass=1 command_stop.sh fn_firstcommand_reset + exitbypass=1 + fn_update_vs_dl + exitbypass=1 + command_start.sh + fn_firstcommand_reset fi - # If server started. - else - fn_print_restart_warning - exitbypass=1 - command_stop.sh - fn_firstcommand_reset - exitbypass=1 - fn_update_vs_dl - exitbypass=1 - command_start.sh - fn_firstcommand_reset + unset exitbypass + date +%s > "${lockdir}/lastupdate.lock" + alert="update" + elif [ "${commandname}" == "CHECK-UPDATE" ]; then + alert="check-update" fi - unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" - alert="update" alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}"