Explorar o código

refactor(fix): move steamclient.so fix to a seperate function

H3o66 %!s(int64=5) %!d(string=hai) anos
pai
achega
a6d564ccbe

+ 0 - 15
lgsm/functions/core_functions.sh

@@ -330,11 +330,6 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
-fix_cs.sh(){
-functionfile="${FUNCNAME[0]}"
-fn_fetch_function
-}
-
 fix_csgo.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function
@@ -390,11 +385,6 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
-fix_pz.sh(){
-functionfile="${FUNCNAME[0]}"
-fn_fetch_function
-}
-
 fix_ro.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function
@@ -435,11 +425,6 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
-fix_tu.sh(){
-functionfile="${FUNCNAME[0]}"
-fn_fetch_function
-}
-
 fix_ut3.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function

+ 0 - 6
lgsm/functions/fix.sh

@@ -42,8 +42,6 @@ if [ "${commandname}" != "INSTALL" ]&&[ -z "${fixbypass}" ]; then
 		fix_ark.sh
 	elif [ "${shortname}" == "bo" ]; then
 		fix_bo.sh
-	elif [ "${shortname}" == "cs" ]; then
-		fix_cs.sh
 	elif [ "${shortname}" == "csgo" ]; then
 		fix_csgo.sh
 	elif [ "${shortname}" == "cmw" ]; then
@@ -60,8 +58,6 @@ if [ "${commandname}" != "INSTALL" ]&&[ -z "${fixbypass}" ]; then
 		fix_nmrih.sh
 	elif [ "${shortname}" == "onset" ]; then
 		fix_onset.sh
-	elif [ "${shortname}" == "pz" ]; then
-		fix_pz.sh
 	elif [ "${shortname}" == "rust" ]; then
 		fix_rust.sh
 	elif [ "${shortname}" == "rw" ]; then
@@ -84,8 +80,6 @@ if [ "${commandname}" != "INSTALL" ]&&[ -z "${fixbypass}" ]; then
 		fix_terraria.sh
 	elif [ "${shortname}" == "ts3" ]; then
 		fix_ts3.sh
-	elif [ "${shortname}" == "tu" ]; then
-		fix_tu.sh
 	elif [ "${shortname}" == "mcb" ]; then
 		fix_mcb.sh
 	elif [ "${shortname}" == "mta" ]; then

+ 0 - 26
lgsm/functions/fix_bo.sh

@@ -7,29 +7,3 @@
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/BODS_Data/Plugins/x86_64"
-
-# steamclient.so x86 fix.
-if [ ! -f "${serverfiles}/BODS_Data/Plugins/x86/steamclient.so" ]; then
-	fixname="steamclient.so x86"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/BODS_Data/Plugins/x86"
-	if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/BODS_Data/Plugins/x86/steamclient.so"
-	elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
-		cp "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/BODS_Data/Plugins/x86/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi
-
-# steamclient.so x86_64 fix.
-if [ ! -f "${serverfiles}/BODS_Data/Plugins/x86_64/steamclient.so" ]; then
-	fixname="steamclient.so x86_64"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/BODS_Data/Plugins/x86_64"
-	if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${serverfiles}/BODS_Data/Plugins/x86_64/steamclient.so"
-	elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
-		cp "${steamcmddir}/linux64/steamclient.so" "${serverfiles}/BODS_Data/Plugins/x86_64/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi

+ 1 - 15
lgsm/functions/fix_cmw.sh

@@ -4,27 +4,13 @@
 # Website: https://linuxgsm.com
 # Description: Resolves the issue of the not starting server on linux
 
-fixname="steam_appid.txt"
-
 if [ ! -f "${executabledir}/steam_appid.txt" ]; then
+	fixname="steam_appid.txt"
 	fn_fix_msg_start
 	echo 219640 > "${executabledir}/steam_appid.txt"
 	fn_fix_msg_end
 fi
 
-# steamclient.so x86 fix.
-if [ ! -f "${executabledir}/lib/steamclient.so" ]; then
-	fixname="steamclient.so x86"
-	fn_fix_msg_start
-	mkdir -p "${executabledir}/lib"
-	if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${executabledir}/lib/steamclient.so"
-	elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
-		cp "${steamcmddir}/linux32/steamclient.so" "${executabledir}/lib/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi
-
 if [ ! -f "${servercfgfullpath}" ]; then
 	fn_fix_msg_start
 	fixname="copy config"

+ 0 - 20
lgsm/functions/fix_cs.sh

@@ -1,20 +0,0 @@
-#!/bin/bash
-# LinuxGSM fix_cs.sh function
-# Author: Christian Birk
-# Website: https://linuxgsm.com
-# Description: Resolves various issues with Counter Strike.
-
-functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-
-# steamclient.so x86 fix.
-if [ ! -f "${serverfiles}/steamclient.so" ]; then
-	fixname="steamclient.so x86"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}"
-	if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/steamclient.so"
-	elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
-		cp "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi

+ 0 - 33
lgsm/functions/fix_pz.sh

@@ -1,33 +0,0 @@
-#!/bin/bash
-# LinuxGSM fix_pz.sh function
-# Author: Christian Birk
-# Website: https://linuxgsm.com
-# Description: Resolves various issues with Project Zomboid.
-
-functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-
-# steamclient.so x86 fix.
-if [ ! -f "${serverfiles}/linux32/steamclient.so" ]; then
-	fixname="steamclient.so x86"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/linux32"
-	if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/linux32/steamclient.so"
-	elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
-		cp "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/linux32/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi
-
-# steamclient.so x86_64 fix.
-if [ ! -f "${serverfiles}/linux64/steamclient.so" ]; then
-	fixname="steamclient.so x86_64"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/linux64"
-	if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${serverfiles}/linux64/steamclient.so"
-	elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
-		cp "${steamcmddir}/linux64/steamclient.so" "${serverfiles}/linux64/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi

+ 4 - 6
lgsm/functions/fix_ss3.sh

@@ -7,12 +7,10 @@
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 # Fixes: https://steamcommunity.com/app/41070/discussions/0/353916981477716386/
-if [ ! -f "${serverfiles}/Bin/steamclient.so" ]||[ "$(diff "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/Bin/steamclient.so" 2>/dev/null)" ]; then
-	fixname="steamclient.so"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/Bin"
-	cp -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/Bin/steamclient.so"
-	fn_fix_msg_end
+if [ -f "${serverfiles}/Bin/steamclient.so" ] && [ "$(diff "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/Bin/steamclient.so" 2>/dev/null)" ]; then
+	# delete old steamclient.so file
+	rm -f "${serverfiles}/Bin/steamclient.so"
+	fn_fix_steamclient_so "32" "${serverfiles}/Bin"
 fi
 
 # Fixes: .steam/bin32/libsteam.so: cannot open shared object file: No such file or directory

+ 60 - 0
lgsm/functions/fix_steamcmd.sh

@@ -6,6 +6,45 @@
 
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
+# function to simplify the steamclient.so fix
+# example
+# fn_fix_steamclient_so 32|64 (bit) "${serverfiles}/linux32/"
+fn_fix_steamclient_so(){
+	# $1 type of fix 32 or 64 as possible values
+	# $2 as destination where the lib will be copied to
+	if [ "$1" == "32" ]; then
+		# steamclient.so x86 fix.
+		if [ ! -f "${2}/steamclient.so" ]; then
+			fixname="steamclient.so x86"
+			fn_fix_msg_start
+			if [ ! -d "${2}" ]; then
+				mkdir -p "${2}"
+			fi
+			if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
+				cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${2}/steamclient.so"
+			elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
+				cp "${steamcmddir}/linux32/steamclient.so" "${2}/steamclient.so"
+			fi
+			fn_fix_msg_end
+		fi
+	elif [ "$1" == "64" ]; then
+		# steamclient.so x86_64 fix.
+		if [ ! -f "${2}/steamclient.so" ]; then
+			fixname="steamclient.so x86_64"
+			fn_fix_msg_start
+			if [ ! -d "${2}" ]; then
+				mkdir -p "${2}"
+			fi
+			if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
+				cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${2}/steamclient.so"
+			elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
+				cp "${steamcmddir}/linux64/steamclient.so" "${2}/steamclient.so"
+			fi
+			fn_fix_msg_end
+		fi
+	fi
+}
+
 # Helps fix: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so.
 if [ ! -f "${HOME}/.steam/sdk64/steamclient.so" ]; then
 	fixname="steamclient.so sdk64"
@@ -31,3 +70,24 @@ if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then
 	fi
 	fn_fix_msg_end
 fi
+
+# steamclient.so fixes
+if [ "${shortname}" == "bo" ]; then
+	fn_fix_steamclient_so "32" "${serverfiles}/BODS_Data/Plugins/x86"
+	fn_fix_steamclient_so "64" "${serverfiles}/BODS_Data/Plugins/x86_64"
+elif [ "${shortname}" == "cmw" ]; then
+	fn_fix_steamclient_so "32" "${executabledir}/lib"
+elif [ "${shortname}" == "cs" ]; then
+	fn_fix_steamclient_so "32" "${serverfiles}"
+elif [ "${shortname}" == "pz" ]; then
+	fn_fix_steamclient_so "32" "${serverfiles}/linux32"
+	fn_fix_steamclient_so "64" "${serverfiles}/linux64"
+elif [ "${shortname}" == "ss3" ]; then
+	fn_fix_steamclient_so "32" "${serverfiles}/Bin"
+elif [ "${shortname}" == "tu" ];then
+	fn_fix_steamclient_so "64" "${executabledir}"
+elif [ "${shortname}" == "unt" ]; then
+	fn_fix_steamclient_so "64" "${serverfiles}"
+elif [ "${shortname}" == "wurm" ]; then
+	fn_fix_steamclient_so "64" "${serverfiles}/nativelibs"
+fi

+ 0 - 20
lgsm/functions/fix_tu.sh

@@ -1,20 +0,0 @@
-#!/bin/bash
-# LinuxGSM fix_tu.sh function
-# Author: Daniel Gibbs
-# Website: https://linuxgsm.com
-# Description: Resolves various issues with Tower Unite.
-
-functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-
-# steamclient.so x86_64 fix.
-if [ ! -f "${executabledir}/steamclient.so" ]; then
-	fixname="steamclient.so x86_64"
-	fn_fix_msg_start
-	mkdir -p "${executabledir}"
-	if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${executabledir}/steamclient.so"
-	elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
-		cp "${steamcmddir}/linux64/steamclient.so" "${executabledir}/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi

+ 0 - 13
lgsm/functions/fix_unt.sh

@@ -7,16 +7,3 @@
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/Unturned_Headless_Data/Plugins/x86_64"
-
-# steamclient.so x86_64 fix.
-if [ ! -f "${serverfiles}/steamclient.so" ]; then
-	fixname="steamclient.so x86_64"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}"
-	if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${serverfiles}/steamclient.so"
-	elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
-		cp "${steamcmddir}/linux64/steamclient.so" "${serverfiles}/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi

+ 0 - 13
lgsm/functions/fix_wurm.sh

@@ -6,19 +6,6 @@
 
 functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-# steamclient.so x86_64 fix.
-if [ ! -f "${serverfiles}/nativelibs/steamclient.so" ]; then
-	fixname="steamclient.so x86_64"
-	fn_fix_msg_start
-	mkdir -p "${serverfiles}/nativelibs"
-	if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
-		cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${serverfiles}/nativelibs/steamclient.so"
-	elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
-		cp "${steamcmddir}/linux64/steamclient.so" "${serverfiles}/nativelibs/steamclient.so"
-	fi
-	fn_fix_msg_end
-fi
-
 # First run requires start with no parms.
 # After first run new dirs are created.
 if [ ! -d "${serverfiles}/Creative" ]; then