Browse Source

centralise steamcmd downloads

pull/2959/head
Daniel Gibbs 5 years ago
parent
commit
0d4d5c150b
  1. 4
      lgsm/functions/core_dl.sh
  2. 103
      lgsm/functions/install_server_files.sh
  3. 104
      lgsm/functions/update_steamcmd.sh

4
lgsm/functions/core_dl.sh

@ -53,9 +53,9 @@ fn_dl_steamcmd(){
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}" "${branch}" +app_update "${appid}" -beta "${branch}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
${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}" "${branch}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
${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

103
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(){
if [ -d "${steamcmddir}" ]; then
cd "${steamcmddir}" || exit
fi
if [ "$(command -v unbuffer)" ]; then
unbuffer="unbuffer"
fi
counter="0"
while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
counter=$((counter+1))
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
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

104
lgsm/functions/update_steamcmd.sh

@ -6,98 +6,6 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_update_steamcmd_dl(){
fn_print_start_nl "${remotelocation}"
fn_script_log_info "Updating 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"
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}" "${branch}" +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}" "${branch}" +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 "Updating server: ${remotelocation}: Not enough space to download server files"
fn_script_log_fatal "Updating 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 "Updating server: ${remotelocation}: Game not owned by any authorised accounts"
fn_script_log_fatal "Updating server: ${remotelocation}: Game not owned by any authorised accounts"
core_exit.sh
# Two-factor authentication failure
elif [ -n "$(grep "Two-factor code mismatch" "${steamcmdlog}" | tail -1)" ]; then
fn_print_failure_nl "Updating server: ${remotelocation}: Two-factor authentication failure"
fn_script_log_fatal "Updating 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 "Updating server: ${remotelocation}: Update required but not completed - check network"
fn_script_log_error "Updating server: ${remotelocation}: Update required but not completed - check network"
else
fn_print_error2_nl "Updating server: ${remotelocation}: Unknown error occured"
fn_script_log_error "Updating server: ${remotelocation}: Unknown error occured"
fi
elif [ "${exitcode}" != "0" ]; then
fn_print_error2_nl "Updating server: ${remotelocation}: Exit code: ${exitcode}"
fn_script_log_error "Updating server: ${remotelocation}: Exit code: ${exitcode}"
else
fn_print_complete_nl "Updating server: ${remotelocation}"
fn_script_log_pass "Updating server: ${remotelocation}"
fi
if [ "${counter}" -gt "10" ]; then
fn_print_failure_nl "Updating server: ${remotelocation}: Did not complete the download, too many retrys"
fn_script_log_fatal "Updating server: ${remotelocation}: Did not complete the download, too many retrys"
core_exit.sh
fi
done
}
fn_update_steamcmd_localbuild(){
# Gets local build info.
fn_print_dots "Checking local build: ${remotelocation}"
@ -182,7 +90,7 @@ 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_print_restart_warning
@ -190,7 +98,7 @@ fn_update_steamcmd_compare(){
command_stop.sh
fn_commandname
exitbypass=1
fn_update_steamcmd_dl
fn_dl_steamcmd
exitbypass=1
command_start.sh
fn_commandname
@ -250,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"
@ -280,13 +188,13 @@ if [ "${forceupdate}" == "1" ]; then
exitbypass=1
command_stop.sh
fn_commandname
fn_update_steamcmd_dl
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

Loading…
Cancel
Save