diff --git a/functions/fn_versioncheck b/functions/fn_versioncheck index e18c9a641..7bb354cbf 100644 --- a/functions/fn_versioncheck +++ b/functions/fn_versioncheck @@ -2,23 +2,45 @@ # LGSM fn_versioncheck function # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 191214 +# Version: 231214 -fn_steamdbcheck(){ +fn_steamcmdcheck(){ # Checks for server update from SteamDB.info API. -fn_printdots "Checking ${servicename}: Checking for updates via steamdb.info" +fn_printdots "Checking ${servicename}: Checking for updates via SteamCMD" installedversion=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) -availableversion=$(wget -qO- "http://steamdb.info/api/GetRawDepots/?appid=${appid}" | sed 's/\\n/\n/g' | grep -EA 1000 "^\s+\[branches\]" | grep -EA 5 "^\s+\[public\]" | grep -m 1 -EB 10 "^\s+\)$" | grep -E "^\s+\[buildid\]\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f4) +availableversion=$(steamcmd/steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_print ${appid} +app_info_print ${appid} +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"public\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) sleep 1 if [ -z "${availableversion}" ]; then - fn_printfail "Checking ${servicename}: steamdb.info not returning version info" + fn_printfail "Checking ${servicename}: Checking for updates via SteamCMD" sleep 1 + fn_printfail "Checking ${servicename}: SteamCMD is not returning version info" + sleep 2 +else + fn_printok "Checking ${servicename}: Checking for updates via SteamCMD" + sleep 1 +fi + +if [ -z "${availableversion}" ]; then echo "" - fn_logupdaterequest -elif [ "${installedversion}" -ne "${availableversion}" ]; then - fn_printok "Checking ${servicename}: Checking for updates via steamdb.info" + fn_printdots "Checking ${servicename}: Checking for updates via SteamDB.info" + availableversion=$(wget -qO- "http://steamdb.info/api/GetRawDepots/?appid=${appid}" | sed 's/\\n/\n/g' | grep -EA 1000 "^\s+\[branches\]" | grep -EA 5 "^\s+\[public\]" | grep -m 1 -EB 10 "^\s+\)$" | grep -E "^\s+\[buildid\]\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f4) sleep 1 + if [ -z "${availableversion}" ]; then + fn_printfail "Checking ${servicename}: Checking for updates via SteamDB.info" + sleep 1 + fn_printfail "Checking ${servicename}: SteamDB.info is not returning version info" + sleep 2 + else + fn_printok "Checking ${servicename}: Checking for updates via SteamDB.info" + sleep 1 + fi +fi +if [ -z "${availableversion}" ]; then + fn_logupdaterequest +fi + +if [ "${installedversion}" -ne "${availableversion}" ]; then echo -e "\n" echo -e "Update available:" sleep 1 @@ -43,8 +65,6 @@ elif [ "${installedversion}" -ne "${availableversion}" ]; then fn_startserver fi else - fn_printok "Checking ${servicename}: Checking for updates via steamdb.info" - sleep 1 echo -e "\n" echo -e "No update available:" echo -e " Installed version: \e[0;32m${installedversion}\e[0;39m" @@ -56,13 +76,23 @@ fi fn_logupdaterequest(){ # Checks for server update from server logs. -fn_printdots "Checking ${servicename}: Checking logs for update requests" -sleep 1 +echo "" +fn_printdots "Checking ${servicename}: Checking server logs for update requests" requestrestart=$(grep -sc "MasterRequestRestart" "${consolelog}") +sleep 1 if [ "${requestrestart}" -ge "1" ]; then - fn_printok "Checking ${servicename}: Checking logs for update requests" + fn_printok "Checking ${servicename}: Checking server logs for update requests" sleep 1 fn_printoknl "Checking ${servicename}: Server requesting update" + sleep 1 + echo "" + echo -ne "Applying update.\r" + sleep 1 + echo -ne "Applying update..\r" + sleep 1 + echo -ne "Applying update...\r" + sleep 1 + echo -ne "\n" if [ ! -z "${norestart}" ]; then fn_updateserver else @@ -75,12 +105,12 @@ else sleep 1 fn_printok "Checking ${servicename}: No update request detected" sleep 1 - echo "" fi +echo "" +exit } - fn_appmanifestinfo(){ appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf") appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l) @@ -131,4 +161,4 @@ fi fn_printdots "Checking ${servicename}: Checking for updates" fn_appmanifestcheck -fn_steamdbcheck \ No newline at end of file +fn_steamcmdcheck \ No newline at end of file