From be0c4488962e4b060cea93ec704d87d1500ef7bf Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 13 Jul 2020 00:28:05 +0100 Subject: [PATCH] feat(steamcmd): refactor how SteamCMD server downloads are handled (#2959) Handling of SteamCMD and error checking --- lgsm/functions/check.sh | 4 +- lgsm/functions/command_backup.sh | 17 +--- lgsm/functions/command_validate.sh | 68 +++----------- lgsm/functions/core_dl.sh | 96 +++++++++++++++++++ lgsm/functions/core_messages.sh | 15 +++ lgsm/functions/core_trap.sh | 3 + lgsm/functions/install_server_files.sh | 103 +-------------------- lgsm/functions/update_factorio.sh | 17 +--- lgsm/functions/update_minecraft.sh | 17 +--- lgsm/functions/update_minecraft_bedrock.sh | 17 +--- lgsm/functions/update_mta.sh | 17 +--- lgsm/functions/update_mumble.sh | 17 +--- lgsm/functions/update_steamcmd.sh | 71 +++----------- lgsm/functions/update_ts3.sh | 17 +--- 14 files changed, 147 insertions(+), 332 deletions(-) diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 3e8fa90a2..b50754e3d 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -48,7 +48,7 @@ if [ "$(whoami)" != "root" ]; then done fi -allowed_commands_array=( BACKUP CONSOLE DEBUG DETAILS MAP-COMPRESSOR FASTDL MODS-INSTALL MODS-REMOVE MODS-UPDATE MONITOR POST-DETAILS RESTART START STOP TEST-ALERT CHANGE-PASSWORD UPDATE UPDATE-LGSM VALIDATE WIPW ) +allowed_commands_array=( BACKUP CONSOLE DEBUG DETAILS MAP-COMPRESSOR FASTDL MODS-INSTALL MODS-REMOVE MODS-UPDATE MONITOR POST-DETAILS RESTART START STOP TEST-ALERT CHANGE-PASSWORD UPDATE UPDATE-LGSM VALIDATE WIPE ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${commandname}" ]; then @@ -82,7 +82,7 @@ do fi done -allowed_commands_array=( DEBUG START VALIDATE ) +allowed_commands_array=( DEBUG START UPDATE VALIDATE ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${commandname}" ]; then diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 7d62e965b..620820932 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -73,7 +73,7 @@ fn_backup_stop_server(){ # Server is running and will be stopped if stoponbackup=on or unset. # If server is started elif [ "${status}" != "0" ]; then - fn_stop_warning + fn_print_restart_warning startserver="1" exitbypass=1 command_stop.sh @@ -247,21 +247,6 @@ fn_backup_relpath() { fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during backup" - fn_script_log_warn "this game server will be stopped during backup" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during backup: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during backup" -} - # Start the server if it was stopped for the backup. fn_backup_start_server(){ if [ -n "${startserver}" ]; then diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index a00fb99ce..1ddded9c0 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -12,76 +12,30 @@ fn_commandname(){ fn_commandname fn_validate(){ - fn_script_log_warn "SteamCMD: Validate might overwrite some customised files" + fn_print_warn "Validate might overwrite some customised files" + fn_script_log_warn "${commandaction} server: Validate might overwrite some customised files" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "SteamCMD: Validate might overwrite some customised files: ${totalseconds}" + fn_print_warn "Validate might overwrite some customised files: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "SteamCMD: Validate might overwrite some customised files" - fn_print_start_nl "SteamCMD" - fn_script_log_info "Validating server: SteamCMD" - if [ -d "${steamcmddir}" ]; then - cd "${steamcmddir}" || exit - fi - # Detects if unbuffer command is available, for 32 bit distributions only. - info_distro.sh - if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then - unbuffer="stdbuf -i0 -o0 -e0" - fi + fn_print_warn_nl "Validate might overwrite some customised files" - # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. - if [ "${appid}" == "90" ]; then - # If using a specific branch. - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}" - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}" - fi - elif [ "${shortname}" == "ac" ]; then - ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}" - # All other servers. - elif [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}" - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}" - fi - - exitcode=$? - fn_print_dots "SteamCMD" - if [ "${exitcode}" != "0" ]; then - fn_print_fail_nl "SteamCMD" - fn_script_log_fatal "Validating server: SteamCMD: FAIL" - else - fn_print_ok_nl "SteamCMD" - fn_script_log_pass "Validating server: SteamCMD: OK" - fi - core_exit.sh -} - -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during validate" - fn_script_log_warn "this game server will be stopped during validate" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during validate: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during validate" + fn_dl_steamcmd } -fn_print_dots "SteamCMD" +# The location where the builds are checked and downloaded. +remotelocation="SteamCMD" check.sh + +fn_print_dots "${remotelocation}" + if [ "${status}" != "0" ]; then - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 514eb3da8..6cd481506 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -19,6 +19,102 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_dl_steamcmd(){ + fn_print_start_nl "${remotelocation}" + fn_script_log_info "${commandaction} server: ${remotelocation}" + + if [ -d "${steamcmddir}" ]; then + cd "${steamcmddir}" || exit + fi + + # Unbuffer will allow the output of steamcmd not buffer allowing a smooth output. + # unbuffer us part of the expect package. + if [ "$(command -v unbuffer)" ]; then + unbuffer="unbuffer" + fi + + # Validate will be added as a parameter if required. + if [ "${commandname}" == "VALIDATE" ]||[ "${commandname}" == "INSTALL" ]; then + validate="validate" + fi + + # To do error checking for SteamCMD the output of steamcmd will be saved to a log. + steamcmdlog="${lgsmlogdir}/${selfname}-steamcmd.log" + + # clear previous steamcmd log + if [ -f "${steamcmdlog}" ]; then + rm -f "${steamcmdlog:?}" + fi + counter=0 + while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do + counter=$((counter+1)) + # Select SteamCMD parameters + # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. + if [ "${appid}" == "90" ]; then + # If using a specific branch. + if [ -n "${branch}" ]; then + ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + else + ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + fi + # Force Windows Platform type. + elif [ "${shortname}" == "ac" ]; then + if [ -n "${branch}" ]; then + ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + else + ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + fi + # All other servers. + else + if [ -n "${branch}" ]; then + ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + else + ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}" + fi + fi + + # Error checking for SteamCMD. Some errors will loop to try again and some will just exit. + exitcode=$? + if [ -n "$(grep "Error!" "${steamcmdlog}" | tail -1)" ]||[ -n "$(grep "ERROR!" "${steamcmdlog}" | tail -1)" ]; then + # Not enough space. + if [ -n "$(grep "0x202" "${steamcmdlog}" | tail -1)" ]; then + fn_print_failure_nl "${commandaction} server: ${remotelocation}: Not enough space to download server files" + fn_script_log_fatal "${commandaction} server: ${remotelocation}: Not enough space to download server files" + core_exit.sh + # Need tp purchase game. + elif [ -n "$(grep "No subscription" "${steamcmdlog}" | tail -1)" ]; then + fn_print_failure_nl "${commandaction} server: ${remotelocation}: Steam account does not have a license for the required game" + fn_script_log_fatal "${commandaction} server: ${remotelocation}: Steam account does not have a license for the required game" + core_exit.sh + # Two-factor authentication failure + elif [ -n "$(grep "Two-factor code mismatch" "${steamcmdlog}" | tail -1)" ]; then + fn_print_failure_nl "${commandaction} server: ${remotelocation}: Two-factor authentication failure" + fn_script_log_fatal "${commandaction} server: ${remotelocation}: Two-factor authentication failure" + core_exit.sh + # Update did not finish. + elif [ -n "$(grep "0x402" "${steamcmdlog}" | tail -1)" ]||[ -n "$(grep "0x602" "${steamcmdlog}" | tail -1)" ]; then + fn_print_error2_nl "${commandaction} server: ${remotelocation}: Update required but not completed - check network" + fn_script_log_error "${commandaction} server: ${remotelocation}: Update required but not completed - check network" + else + fn_print_error2_nl "${commandaction} server: ${remotelocation}: Unknown error occured" + fn_script_log_error "${commandaction} server: ${remotelocation}: Unknown error occured" + fi + elif [ "${exitcode}" != "0" ]; then + fn_print_error2_nl "${commandaction} server: ${remotelocation}: Exit code: ${exitcode}" + fn_script_log_error "${commandaction} server: ${remotelocation}: Exit code: ${exitcode}" + else + fn_print_complete_nl "${commandaction} server: ${remotelocation}" + fn_script_log_pass "${commandaction} server: ${remotelocation}" + fi + + if [ "${counter}" -gt "10" ]; then + fn_print_failure_nl "${commandaction} server: ${remotelocation}: Did not complete the download, too many retrys" + fn_script_log_fatal "${commandaction} server: ${remotelocation}: Did not complete the download, too many retrys" + core_exit.sh + fi + done +} + # Emptys contents of the LinuxGSM tmpdir. fn_clear_tmp(){ echo -en "clearing LinuxGSM tmp directory..." diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 8a13cc6ea..ee4807bd5 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -529,3 +529,18 @@ fn_print_ascii_logo(){ echo -e "${lightyellow}LinuxGSM${default} ${lightyellow}888${default} ${lightyellow}888${default} ${lightyellow}888${default} ${lightyellow}Y8888Y${default} ${lightyellow}888${default} ${lightyellow}888${default} Y2012P88 Y8888P 888 888" echo -e "" } + +fn_print_restart_warning(){ + fn_print_warn "${selfname} will be restarted" + fn_script_log_warn "${selfname} will be restarted" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "${selfname} will be restarted: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "${selfname} will be restarted" +} diff --git a/lgsm/functions/core_trap.sh b/lgsm/functions/core_trap.sh index f943c5c33..52c00b107 100644 --- a/lgsm/functions/core_trap.sh +++ b/lgsm/functions/core_trap.sh @@ -7,6 +7,9 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_exit_trap(){ + if [ -z "${exitcode}" ]; then + exitcode=$? + fi echo -e "" core_exit.sh } diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index ec5c60989..0264a7f11 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -68,114 +68,13 @@ fn_install_server_files(){ fn_dl_extract "${local_filedir}" "${local_filename}" "${serverfiles}" } -fn_install_server_files_steamcmd(){ - counter="0" - while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do - counter=$((counter+1)) - if [ -d "${steamcmddir}" ]; then - cd "${steamcmddir}" || exit - fi - if [ "${counter}" -le "10" ]; then - # Attempt 1-4: Standard attempt. - # Attempt 5-6: Validate attempt. - # Attempt 7-8: Validate, delete long name dir. - # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD. - # Attempt 11: Failure. - - if [ "${counter}" -ge "2" ]; then - fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}" - fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}" - fi - - if [ "${counter}" -ge "7" ]; then - echo -e "Removing $(find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$')" - find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf - fi - if [ "${counter}" -ge "9" ]; then - rm -rf "${steamcmddir:?}" - check_steamcmd.sh - fi - - # Detects if unbuffer command is available for 32 bit distributions only. - info_distro.sh - if [ "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then - unbuffer="stdbuf -i0 -o0 -e0" - fi - - if [ "${counter}" -le "4" ]; then - # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. - if [ "${appid}" == "90" ]; then - # If using a specific branch. - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" +quit - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit - fi - elif [ "${shortname}" == "ac" ]; then - ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit - # All other servers. - else - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update -beta "${branch}" +quit - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit - fi - fi - local exitcode=$? - elif [ "${counter}" -ge "5" ]; then - # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. - if [ "${appid}" == "90" ]; then - # If using a specific branch. - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" validate +quit - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" validate +quit - fi - local exitcode=$? - elif [ "${shortname}" == "ac" ]; then - ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit - local exitcode=$? - # All other servers. - else - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit - fi - local exitcode=$? - fi - fi - elif [ "${counter}" -ge "11" ]; then - fn_print_failure_nl "SteamCMD did not complete the download, too many retrys" - fn_script_log "SteamCMD did not complete the download, too many retrys" - break - fi - done - - # GoldSrc (appid 90) servers commonly fail to download all the server files required. - # Validating a few of times may reduce the chance of this issue. - if [ "${appid}" == "90" ]; then - fn_print_information_nl "GoldSrc servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." - counter="0" - while [ "${counter}" -le "4" ]; do - counter=$((counter+1)) - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" validate +quit - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" validate +quit - fi - local exitcode=$? - done - fi -} - echo -e "" echo -e "${lightyellow}Installing ${gamename} Server${default}" echo -e "=================================" fn_sleep_time if [ "${appid}" ]; then - fn_install_server_files_steamcmd + fn_dl_steamcmd fi if [ "${shortname}" == "ts3" ]; then diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index 869314d60..e8b5c5e5c 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -102,7 +102,7 @@ fn_update_factorio_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -134,21 +134,6 @@ fn_update_factorio_compare(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="factorio.com" diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index 62cf6a80c..fad5d903f 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -162,7 +162,7 @@ fn_update_minecraft_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -194,21 +194,6 @@ fn_update_minecraft_compare(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="mojang.com" diff --git a/lgsm/functions/update_minecraft_bedrock.sh b/lgsm/functions/update_minecraft_bedrock.sh index 1e22053a1..8f6193302 100644 --- a/lgsm/functions/update_minecraft_bedrock.sh +++ b/lgsm/functions/update_minecraft_bedrock.sh @@ -129,7 +129,7 @@ fn_update_minecraft_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -155,21 +155,6 @@ fn_update_minecraft_compare(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="minecraft.net" diff --git a/lgsm/functions/update_mta.sh b/lgsm/functions/update_mta.sh index caf6bc57b..6f1250d6c 100644 --- a/lgsm/functions/update_mta.sh +++ b/lgsm/functions/update_mta.sh @@ -158,7 +158,7 @@ fn_update_mta_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -184,21 +184,6 @@ fn_update_mta_compare(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="linux.mtasa.com" diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh index 969913ba3..4b60b0cae 100644 --- a/lgsm/functions/update_mumble.sh +++ b/lgsm/functions/update_mumble.sh @@ -94,7 +94,7 @@ fn_update_mumble_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -120,21 +120,6 @@ fn_update_mumble_compare(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="mumble.info" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index cfa6d6aa2..1a3a1cfb3 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -6,38 +6,6 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -fn_update_steamcmd_dl(){ - info_config.sh - # Detects if unbuffer command is available for 32 bit distributions only. - info_distro.sh - if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then - unbuffer="stdbuf -i0 -o0 -e0" - fi - if [ -d "${steamcmddir}" ]; then - cd "${steamcmddir}" || exit - fi - - # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. - if [ "${appid}" == "90" ]; then - # If using a specific branch. - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" +quit | tee -a "${lgsmlog}" - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit | tee -a "${lgsmlog}" - fi - elif [ "${shortname}" == "ac" ]; then - ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit - # All other servers. - else - if [ -n "${branch}" ]; then - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" +quit | tee -a "${lgsmlog}" - else - ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit | tee -a "${lgsmlog}" - fi - fi - fix.sh -} - fn_update_steamcmd_localbuild(){ # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" @@ -122,15 +90,15 @@ fn_update_steamcmd_compare(){ check_status.sh # If server stopped. if [ "${status}" == "0" ]; then - fn_update_steamcmd_dl + fn_dl_steamcmd # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname exitbypass=1 - fn_update_steamcmd_dl + fn_dl_steamcmd exitbypass=1 command_start.sh fn_commandname @@ -190,14 +158,14 @@ fn_appmanifest_check(){ fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" - fn_update_steamcmd_dl + fn_dl_steamcmd fi elif [ "${appmanifestfilewc}" -eq "0" ]; then fn_print_error_nl "No appmanifest_${appid}.acf found" fn_script_log_error "No appmanifest_${appid}.acf found" fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" - fn_update_steamcmd_dl + fn_dl_steamcmd fn_appmanifest_info if [ "${appmanifestfilewc}" -eq "0" ]; then fn_print_fail_nl "Still no appmanifest_${appid}.acf found" @@ -207,44 +175,29 @@ fn_appmanifest_check(){ fi } -fn_stop_warning(){ - fn_print_warn "this game server will be stopped during update" - fn_script_log_warn "this game server will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "this game server will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "this game server will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="SteamCMD" -check_steamcmd.sh +check.sh + +fn_print_dots "${remotelocation}" if [ "${forceupdate}" == "1" ]; then # forceupdate bypasses update checks. - check_status.sh if [ "${status}" != "0" ]; then - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh - fn_update_steamcmd_dl + fn_commandname + fn_dl_steamcmd date +%s > "${lockdir}/lastupdate.lock" exitbypass=1 command_start.sh fn_commandname else - fn_update_steamcmd_dl + fn_dl_steamcmd date +%s > "${lockdir}/lastupdate.lock" fi else - fn_print_dots "Checking for update" - fn_print_dots "Checking for update: ${remotelocation}" fn_update_steamcmd_localbuild fn_update_steamcmd_remotebuild fn_update_steamcmd_compare diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 5bcf14bff..4f1168bb0 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -156,7 +156,7 @@ fn_update_ts3_compare(){ fn_commandname # If server started. else - fn_stop_warning + fn_print_restart_warning exitbypass=1 command_stop.sh fn_commandname @@ -194,21 +194,6 @@ else core_exit.sh fi -fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - totalseconds=3 - for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" - totalseconds=$((totalseconds - 1)) - sleep 1 - if [ "${seconds}" == "0" ]; then - break - fi - done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" -} - # The location where the builds are checked and downloaded. remotelocation="teamspeak.com"