Forráskód Böngészése

feat(check-update): add new command check-update for steamcmd game servers (#3146)

Christian 5 éve
szülő
commit
a075300589

+ 11 - 0
lgsm/functions/alert.sh

@@ -60,6 +60,15 @@ fn_alert_update(){
 	alertbody="${gamename} received update"
 	alertbody="${gamename} received update"
 }
 }
 
 
+fn_alert_check_update(){
+	fn_script_log_info "Sending alert: Update available"
+	alertsubject="Alert - ${selfname} - Update available"
+	alertemoji="🎮"
+	alertsound="1"
+	alerturl="not enabled"
+	alertbody="${gamename} update available"
+}
+
 fn_alert_permissions(){
 fn_alert_permissions(){
 	fn_script_log_info "Sending alert: Permissions error"
 	fn_script_log_info "Sending alert: Permissions error"
 	alertsubject="Alert - ${selfname}: Permissions error"
 	alertsubject="Alert - ${selfname}: Permissions error"
@@ -88,6 +97,8 @@ elif [ "${alert}" == "test" ]; then
 	fn_alert_test
 	fn_alert_test
 elif [ "${alert}" == "update" ]; then
 elif [ "${alert}" == "update" ]; then
 	fn_alert_update
 	fn_alert_update
+elif [ "${alert}" == "check-update" ]; then
+	fn_alert_check_update
 elif [ "${alert}" == "config" ]; then
 elif [ "${alert}" == "config" ]; then
 	fn_alert_config
 	fn_alert_config
 fi
 fi

+ 2 - 139
lgsm/functions/check_steamcmd.sh

@@ -6,145 +6,8 @@
 
 
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 
-fn_install_steamcmd(){
-	if [ "${shortname}" == "ark" ]&&[ "${installsteamcmd}" == "1" ]; then
-		steamcmddir="${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
-	fi
-	if [ ! -d "${steamcmddir}" ]; then
-		mkdir -p "${steamcmddir}"
-	fi
-	remote_fileurl="${1}"
-	remote_fileurl_backup="${2}"
-	remote_fileurl_name="${3}"
-	remote_fileurl_backup_name="${4}"
-	local_filedir="${5}"
-	local_filename="${6}"
-	chmodx="${7:-0}"
-	run="${8:-0}"
-	forcedl="${9:-0}"
-	md5="${10:-0}"
-	fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "" "" "" "${tmpdir}" "steamcmd_linux.tar.gz" "" "norun" "noforce" "nomd5"
-	fn_dl_extract "${tmpdir}" "steamcmd_linux.tar.gz" "${steamcmddir}"
-	chmod +x "${steamcmddir}/steamcmd.sh"
-}
-
-fn_check_steamcmd_user(){
-	# Checks if steamuser is setup.
-	if [ "${steamuser}" == "username" ]; then
-		fn_print_fail_nl "Steam login not set. Update steamuser in ${configdirserver}"
-		echo -e "	* Change steamuser=\"username\" to a valid steam login."
-		if [ -d "${lgsmlogdir}" ]; then
-			fn_script_log_fatal "Steam login not set. Update steamuser in ${configdirserver}"
-		fi
-		core_exit.sh
-	fi
-	# Anonymous user is set if steamuser is missing.
-	if [ -z "${steamuser}" ]; then
-		if [ -d "${lgsmlogdir}" ]; then
-			fn_script_log_info "Using anonymous Steam login"
-		fi
-		steamuser="anonymous"
-		steampass=''
-	fi
-}
-
-fn_check_steamcmd(){
-	# Checks if SteamCMD exists when starting or updating a server.
-	# Only install if steamcmd package is missing or steamcmd dir is missing.
-	if [ ! -f "${steamcmddir}/steamcmd.sh" ]&&[ -z "$(command -v steamcmd 2>/dev/null)" ]; then
-		if [ "${commandname}" == "INSTALL" ]; then
-			fn_install_steamcmd
-		else
-			fn_print_warn_nl "SteamCMD is missing"
-			fn_script_log_warn "SteamCMD is missing"
-			fn_install_steamcmd
-		fi
-	elif [ "${commandname}" == "INSTALL" ]; then
-		fn_print_information "SteamCMD is already installed..."
-		fn_print_ok_eol_nl
-	fi
-}
-
-fn_check_steamcmd_dir(){
-	# Worksround that pre-installs the correct steam directories to ensure all packages use the correct Standard.
-	# https://github.com/ValveSoftware/steam-for-linux/issues/6976#issuecomment-610446347
-
-	# Create Steam installation directory.
-	if [ ! -d "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
-		mkdir -p "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam"
-	fi
-
-	# Create common Steam directory.
-	if [ ! -d "${HOME}/.steam" ]; then
-		mkdir -p "${HOME}/.steam"
-	fi
-
-	# Symbolic links to Steam installation directory.
-	if [ ! -L "${HOME}/.steam/root" ]; then
-		if [ -d "${HOME}/.steam/root" ]; then
-			rm "${HOME}/.steam/root"
-		fi
-		ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/root"
-	fi
-
-	if [ ! -L "${HOME}/.steam/steam" ]; then
-		if [ -d "${HOME}/.steam/steam" ]; then
-			rm -rf "${HOME}/.steam/steam"
-		fi
-		ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/steam"
-	fi
-}
-
-fn_check_steamcmd_dir_legacy(){
-	# Remove old Steam installation directories ~/Steam and ${rootdir}/steamcmd
-	if [ -d "${rootdir}/steamcmd" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
-		rm -rf "${rootdir:?}/steamcmd"
-	fi
-
-	if [ -d "${HOME}/Steam" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
-		rm -rf "${HOME}/Steam"
-	fi
-}
-
-fn_check_steamcmd_ark(){
-	# Checks if SteamCMD exists in
-	# Engine/Binaries/ThirdParty/SteamCMD/Linux
-	# to allow ark mods to work
-	if [ ! -f "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd.sh" ]; then
-		installsteamcmd=1
-		if [ "${commandname}" == "INSTALL" ]; then
-			fn_install_steamcmd
-		else
-			fn_print_warn_nl "ARK mods SteamCMD is missing"
-			fn_script_log_warn "ARK mods SteamCMD is missing"
-			fn_install_steamcmd
-		fi
-	elif [ "${commandname}" == "INSTALL" ]; then
-		fn_print_information "ARK mods SteamCMD is already installed..."
-		fn_print_ok_eol_nl
-	fi
-}
-
-fn_check_steamcmd_clear(){
-# Will remove steamcmd dir if steamcmd package is installed.
-if [ "$(command -v steamcmd 2>/dev/null)" ]&&[ -d "${rootdir}/steamcmd" ]; then
-	rm -rf "${steamcmddir:?}"
-	exitcode=$?
-	if [ "${exitcode}" != 0 ]; then
-		fn_script_log_fatal "Removing ${rootdir}/steamcmd"
-	else
-		fn_script_log_pass "Removing ${rootdir}/steamcmd"
-	fi
-fi
-}
-
-fn_check_steamcmd_exec(){
-	if [ "$(command -v steamcmd 2>/dev/null)" ]; then
-		steamcmdcommand="steamcmd"
-	else
-		steamcmdcommand="./steamcmd.sh"
-	fi
-}
+# init steamcmd functions
+core_steamcmd.sh
 
 
 fn_check_steamcmd_clear
 fn_check_steamcmd_clear
 fn_check_steamcmd
 fn_check_steamcmd

+ 24 - 0
lgsm/functions/command_check_update.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+# LinuxGSM command_check_update.sh function
+# Author: Daniel Gibbs
+# Website: https://linuxgsm.com
+# Description: Handles updating of servers.
+
+commandname="CHECK-UPDATE"
+commandaction="check for Update"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
+
+fn_print_dots ""
+check.sh
+core_logs.sh
+
+core_steamcmd.sh
+
+check_steamcmd.sh
+
+fn_update_steamcmd_localbuild
+fn_update_steamcmd_remotebuild
+fn_update_steamcmd_compare
+
+core_exit.sh

+ 10 - 0
lgsm/functions/core_functions.sh

@@ -53,6 +53,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function
 }
 }
 
 
+core_steamcmd.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 # Commands
 # Commands
 
 
 command_backup.sh(){
 command_backup.sh(){
@@ -599,6 +604,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function
 }
 }
 
 
+command_check_update.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 update_ts3.sh(){
 update_ts3.sh(){
 functionfile="${FUNCNAME[0]}"
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function

+ 3 - 2
lgsm/functions/core_getopt.sh

@@ -27,6 +27,7 @@ cmd_console=( "c;console" "command_console.sh" "Access server console." )
 cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." )
 cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." )
 # Update servers only.
 # Update servers only.
 cmd_update=( "u;update" "command_update.sh" "Check and apply any server updates." )
 cmd_update=( "u;update" "command_update.sh" "Check and apply any server updates." )
+cmd_check_update=( "cu;check-update" "command_check_update.sh" "Check if a gameserver update is available" )
 cmd_force_update=( "fu;force-update;update-restart;ur" "forceupdate=1; command_update.sh" "Apply server updates bypassing check." )
 cmd_force_update=( "fu;force-update;update-restart;ur" "forceupdate=1; command_update.sh" "Apply server updates bypassing check." )
 # SteamCMD servers only.
 # SteamCMD servers only.
 cmd_validate=( "v;validate" "command_validate.sh" "Validate server files with SteamCMD." )
 cmd_validate=( "v;validate" "command_validate.sh" "Validate server files with SteamCMD." )
@@ -72,9 +73,9 @@ if [ "${shortname}" == "jk2" ]||[ "${engine}" != "idtech3" ];then
 	fi
 	fi
 fi
 fi
 
 
-# Validate command.
+# Validate and check-update command.
 if [ "${appid}" ]; then
 if [ "${appid}" ]; then
-	currentopt+=( "${cmd_validate[@]}" )
+	currentopt+=( "${cmd_validate[@]}" "${cmd_check_update[@]}" )
 fi
 fi
 
 
 # Backup.
 # Backup.

+ 332 - 0
lgsm/functions/core_steamcmd.sh

@@ -0,0 +1,332 @@
+#!/bin/bash
+# LinuxGSM core_steamcmd.sh function
+# Author: Daniel Gibbs
+# Website: https://linuxgsm.com
+# Description: Core functions for SteamCMD
+
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+fn_install_steamcmd(){
+	if [ "${shortname}" == "ark" ]&&[ "${installsteamcmd}" == "1" ]; then
+		steamcmddir="${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
+	fi
+	if [ ! -d "${steamcmddir}" ]; then
+		mkdir -p "${steamcmddir}"
+	fi
+	remote_fileurl="${1}"
+	remote_fileurl_backup="${2}"
+	remote_fileurl_name="${3}"
+	remote_fileurl_backup_name="${4}"
+	local_filedir="${5}"
+	local_filename="${6}"
+	chmodx="${7:-0}"
+	run="${8:-0}"
+	forcedl="${9:-0}"
+	md5="${10:-0}"
+	fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "" "" "" "${tmpdir}" "steamcmd_linux.tar.gz" "" "norun" "noforce" "nomd5"
+	fn_dl_extract "${tmpdir}" "steamcmd_linux.tar.gz" "${steamcmddir}"
+	chmod +x "${steamcmddir}/steamcmd.sh"
+}
+
+fn_check_steamcmd_user(){
+	# Checks if steamuser is setup.
+	if [ "${steamuser}" == "username" ]; then
+		fn_print_fail_nl "Steam login not set. Update steamuser in ${configdirserver}"
+		echo -e "	* Change steamuser=\"username\" to a valid steam login."
+		if [ -d "${lgsmlogdir}" ]; then
+			fn_script_log_fatal "Steam login not set. Update steamuser in ${configdirserver}"
+		fi
+		core_exit.sh
+	fi
+	# Anonymous user is set if steamuser is missing.
+	if [ -z "${steamuser}" ]; then
+		if [ -d "${lgsmlogdir}" ]; then
+			fn_script_log_info "Using anonymous Steam login"
+		fi
+		steamuser="anonymous"
+		steampass=''
+	fi
+}
+
+fn_check_steamcmd(){
+	# Checks if SteamCMD exists when starting or updating a server.
+	# Only install if steamcmd package is missing or steamcmd dir is missing.
+	if [ ! -f "${steamcmddir}/steamcmd.sh" ]&&[ -z "$(command -v steamcmd 2>/dev/null)" ]; then
+		if [ "${commandname}" == "INSTALL" ]; then
+			fn_install_steamcmd
+		else
+			fn_print_warn_nl "SteamCMD is missing"
+			fn_script_log_warn "SteamCMD is missing"
+			fn_install_steamcmd
+		fi
+	elif [ "${commandname}" == "INSTALL" ]; then
+		fn_print_information "SteamCMD is already installed..."
+		fn_print_ok_eol_nl
+	fi
+}
+
+fn_check_steamcmd_dir(){
+	# Worksround that pre-installs the correct steam directories to ensure all packages use the correct Standard.
+	# https://github.com/ValveSoftware/steam-for-linux/issues/6976#issuecomment-610446347
+
+	# Create Steam installation directory.
+	if [ ! -d "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
+		mkdir -p "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam"
+	fi
+
+	# Create common Steam directory.
+	if [ ! -d "${HOME}/.steam" ]; then
+		mkdir -p "${HOME}/.steam"
+	fi
+
+	# Symbolic links to Steam installation directory.
+	if [ ! -L "${HOME}/.steam/root" ]; then
+		if [ -d "${HOME}/.steam/root" ]; then
+			rm "${HOME}/.steam/root"
+		fi
+		ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/root"
+	fi
+
+	if [ ! -L "${HOME}/.steam/steam" ]; then
+		if [ -d "${HOME}/.steam/steam" ]; then
+			rm -rf "${HOME}/.steam/steam"
+		fi
+		ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/steam"
+	fi
+}
+
+fn_check_steamcmd_dir_legacy(){
+	# Remove old Steam installation directories ~/Steam and ${rootdir}/steamcmd
+	if [ -d "${rootdir}/steamcmd" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
+		rm -rf "${rootdir:?}/steamcmd"
+	fi
+
+	if [ -d "${HOME}/Steam" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
+		rm -rf "${HOME}/Steam"
+	fi
+}
+
+fn_check_steamcmd_ark(){
+	# Checks if SteamCMD exists in
+	# Engine/Binaries/ThirdParty/SteamCMD/Linux
+	# to allow ark mods to work
+	if [ ! -f "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd.sh" ]; then
+		installsteamcmd=1
+		if [ "${commandname}" == "INSTALL" ]; then
+			fn_install_steamcmd
+		else
+			fn_print_warn_nl "ARK mods SteamCMD is missing"
+			fn_script_log_warn "ARK mods SteamCMD is missing"
+			fn_install_steamcmd
+		fi
+	elif [ "${commandname}" == "INSTALL" ]; then
+		fn_print_information "ARK mods SteamCMD is already installed..."
+		fn_print_ok_eol_nl
+	fi
+}
+
+fn_check_steamcmd_clear(){
+	# Will remove steamcmd dir if steamcmd package is installed.
+	if [ "$(command -v steamcmd 2>/dev/null)" ]&&[ -d "${rootdir}/steamcmd" ]; then
+		rm -rf "${steamcmddir:?}"
+		exitcode=$?
+		if [ "${exitcode}" != 0 ]; then
+			fn_script_log_fatal "Removing ${rootdir}/steamcmd"
+		else
+			fn_script_log_pass "Removing ${rootdir}/steamcmd"
+		fi
+	fi
+}
+
+fn_check_steamcmd_exec(){
+	if [ "$(command -v steamcmd 2>/dev/null)" ]; then
+		steamcmdcommand="steamcmd"
+	else
+		steamcmdcommand="./steamcmd.sh"
+	fi
+}
+
+fn_update_steamcmd_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking local build: ${remotelocation}"
+	fn_appmanifest_check
+	# Uses appmanifest to find local build.
+	localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
+
+	# Set branch to public if no custom branch.
+	if [ -z "${branch}" ]; then
+		branch="public"
+	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"
+		core_exit.sh
+	else
+		fn_print_ok "Checking local build: ${remotelocation}"
+		fn_script_log_pass "Checking local build"
+	fi
+}
+
+fn_update_steamcmd_remotebuild(){
+	# Gets remote build info.
+	if [ -d "${steamcmddir}" ]; then
+		cd "${steamcmddir}" || exit
+	fi
+
+	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD.
+	if [ "$(find "${HOME}" -type f -name "appinfo.vdf" | wc -l)" -ne "0" ]; then
+		find "${HOME}" -type f -name "appinfo.vdf" -exec rm -f {} \;
+	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:]')
+
+	if [ "${firstcommandname}" != "INSTALL" ]; then
+		fn_print_dots "Checking remote build: ${remotelocation}"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking remote build: ${remotelocation}"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking remote build: ${remotelocation}"
+			fn_script_log_pass "Checking remote build"
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_steamcmd_compare(){
+	fn_print_dots "Checking for update: ${remotelocation}"
+	if [ "${localbuild}" != "${remotebuild}" ]; 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}"
+		if [ -n "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		if [ -n "${betapassword}" ]; then
+			echo -e "* Branch password: ${betapassword}"
+		fi
+		echo -e "https://steamdb.info/app/${appid}/"
+		echo -en "\n"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		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}"
+
+		if [ "${commandname}" == "UPDATE" ]; then
+			unset updateonstart
+			check_status.sh
+			# If server stopped.
+			if [ "${status}" == "0" ]; then
+				fn_dl_steamcmd
+			# If server started.
+			else
+				fn_print_restart_warning
+				exitbypass=1
+				command_stop.sh
+				fn_firstcommand_reset
+				exitbypass=1
+				fn_dl_steamcmd
+				exitbypass=1
+				command_start.sh
+				fn_firstcommand_reset
+			fi
+			unset exitbypass
+			date +%s > "${lockdir}/lastupdate.lock"
+			alert="update"
+		elif [ "${commandname}" == "CHECK-UPDATE" ]; then
+			alert="check-update"
+		fi
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		if [ -n "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		if [ -n "${betapassword}" ]; then
+			echo -e "* Branch password: ${betapassword}"
+		fi
+		echo -e "https://steamdb.info/app/${appid}/"
+		echo -en "\n"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		if [ -n "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
+		if [ -n "${betapassword}" ]; then
+			fn_script_log_info "Branch password: ${betapassword}"
+		fi
+	fi
+}
+
+fn_appmanifest_info(){
+	appmanifestfile=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf")
+	appmanifestfilewc=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l)
+}
+
+fn_appmanifest_check(){
+	fn_appmanifest_info
+	# Multiple or no matching appmanifest files may sometimes be present.
+	# This error is corrected if required.
+	if [ "${appmanifestfilewc}" -ge "2" ]; then
+		fn_print_error "Multiple appmanifest_${appid}.acf files found"
+		fn_script_log_error "Multiple appmanifest_${appid}.acf files found"
+		fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
+		for appfile in ${appmanifestfile}; do
+			rm -f "${appfile:?}"
+		done
+		appmanifestfilewc1="${appmanifestfilewc}"
+		fn_appmanifest_info
+		# if error can not be resolved.
+		if [ "${appmanifestfilewc}" -ge "2" ]; then
+			fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+			fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+			echo -e "* Check user permissions"
+			for appfile in ${appmanifestfile}; do
+				echo -e "	${appfile}"
+			done
+			core_exit.sh
+		else
+			fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
+			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_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_dl_steamcmd
+		fn_appmanifest_info
+		if [ "${appmanifestfilewc}" -eq "0" ]; then
+			fn_print_fail_nl "Still no appmanifest_${appid}.acf found"
+			fn_script_log_fatal "Still no appmanifest_${appid}.acf found"
+			core_exit.sh
+		fi
+	fi
+}

+ 2 - 180
lgsm/functions/update_steamcmd.sh

@@ -6,186 +6,8 @@
 
 
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 
-fn_update_steamcmd_localbuild(){
-	# Gets local build info.
-	fn_print_dots "Checking local build: ${remotelocation}"
-	fn_appmanifest_check
-	# Uses appmanifest to find local build.
-	localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
-
-	# Set branch to public if no custom branch.
-	if [ -z "${branch}" ]; then
-		branch="public"
-	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"
-		core_exit.sh
-	else
-		fn_print_ok "Checking local build: ${remotelocation}"
-		fn_script_log_pass "Checking local build"
-	fi
-}
-
-fn_update_steamcmd_remotebuild(){
-	# Gets remote build info.
-	if [ -d "${steamcmddir}" ]; then
-		cd "${steamcmddir}" || exit
-	fi
-
-	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD.
-	if [ "$(find "${HOME}" -type f -name "appinfo.vdf" | wc -l)" -ne "0" ]; then
-		find "${HOME}" -type f -name "appinfo.vdf" -exec rm -f {} \;
-	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:]')
-
-	if [ "${firstcommandname}" != "INSTALL" ]; then
-		fn_print_dots "Checking remote build: ${remotelocation}"
-		# Checks if remotebuild variable has been set.
-		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
-			fn_print_fail "Checking remote build: ${remotelocation}"
-			fn_script_log_fatal "Checking remote build"
-			core_exit.sh
-		else
-			fn_print_ok "Checking remote build: ${remotelocation}"
-			fn_script_log_pass "Checking remote build"
-		fi
-	else
-		# Checks if remotebuild variable has been set.
-		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
-			fn_print_failure "Unable to get remote build"
-			fn_script_log_fatal "Unable to get remote build"
-			core_exit.sh
-		fi
-	fi
-}
-
-fn_update_steamcmd_compare(){
-	fn_print_dots "Checking for update: ${remotelocation}"
-	if [ "${localbuild}" != "${remotebuild}" ]; 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}"
-		if [ -n "${branch}" ]; then
-			echo -e "* Branch: ${branch}"
-		fi
-		if [ -n "${betapassword}" ]; then
-			echo -e "* Branch password: ${betapassword}"
-		fi
-		echo -e "https://steamdb.info/app/${appid}/"
-		echo -en "\n"
-		fn_script_log_info "Update available"
-		fn_script_log_info "Local build: ${localbuild}"
-		fn_script_log_info "Remote build: ${remotebuild}"
-		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}"
-
-		unset updateonstart
-		check_status.sh
-		# If server stopped.
-		if [ "${status}" == "0" ]; then
-			fn_dl_steamcmd
-		# If server started.
-		else
-			fn_print_restart_warning
-			exitbypass=1
-			command_stop.sh
-			fn_firstcommand_reset
-			exitbypass=1
-			fn_dl_steamcmd
-			exitbypass=1
-			command_start.sh
-			fn_firstcommand_reset
-		fi
-		unset exitbypass
-		date +%s > "${lockdir}/lastupdate.lock"
-		alert="update"
-		alert.sh
-	else
-		fn_print_ok_nl "Checking for update: ${remotelocation}"
-		echo -en "\n"
-		echo -e "No update available"
-		echo -e "* Local build: ${green}${localbuild}${default}"
-		echo -e "* Remote build: ${green}${remotebuild}${default}"
-		if [ -n "${branch}" ]; then
-			echo -e "* Branch: ${branch}"
-		fi
-		if [ -n "${betapassword}" ]; then
-			echo -e "* Branch password: ${betapassword}"
-		fi
-		echo -e "https://steamdb.info/app/${appid}/"
-		echo -en "\n"
-		fn_script_log_info "No update available"
-		fn_script_log_info "Local build: ${localbuild}"
-		fn_script_log_info "Remote build: ${remotebuild}"
-		if [ -n "${branch}" ]; then
-			fn_script_log_info "Branch: ${branch}"
-		fi
-		if [ -n "${betapassword}" ]; then
-			fn_script_log_info "Branch password: ${betapassword}"
-		fi
-	fi
-}
-
-fn_appmanifest_info(){
-	appmanifestfile=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf")
-	appmanifestfilewc=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l)
-}
-
-fn_appmanifest_check(){
-	fn_appmanifest_info
-	# Multiple or no matching appmanifest files may sometimes be present.
-	# This error is corrected if required.
-	if [ "${appmanifestfilewc}" -ge "2" ]; then
-		fn_print_error "Multiple appmanifest_${appid}.acf files found"
-		fn_script_log_error "Multiple appmanifest_${appid}.acf files found"
-		fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
-		for appfile in ${appmanifestfile}; do
-			rm -f "${appfile:?}"
-		done
-		appmanifestfilewc1="${appmanifestfilewc}"
-		fn_appmanifest_info
-		# if error can not be resolved.
-		if [ "${appmanifestfilewc}" -ge "2" ]; then
-			fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
-			fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
-			echo -e "* Check user permissions"
-			for appfile in ${appmanifestfile}; do
-				echo -e "	${appfile}"
-			done
-			core_exit.sh
-		else
-			fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
-			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_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_dl_steamcmd
-		fn_appmanifest_info
-		if [ "${appmanifestfilewc}" -eq "0" ]; then
-			fn_print_fail_nl "Still no appmanifest_${appid}.acf found"
-			fn_script_log_fatal "Still no appmanifest_${appid}.acf found"
-			core_exit.sh
-		fi
-	fi
-}
+# init steamcmd functions
+core_steamcmd.sh
 
 
 # The location where the builds are checked and downloaded.
 # The location where the builds are checked and downloaded.
 remotelocation="SteamCMD"
 remotelocation="SteamCMD"