Просмотр исходного кода

fix(arkserver): refactor and simplify how ark mods work (#2773)

Daniel Gibbs 6 лет назад
Родитель
Сommit
bb86a85719
2 измененных файлов с 47 добавлено и 18 удалено
  1. 28 3
      lgsm/functions/check_steamcmd.sh
  2. 19 15
      lgsm/functions/fix_ark.sh

+ 28 - 3
lgsm/functions/check_steamcmd.sh

@@ -7,6 +7,9 @@
 local modulename="CHECK"
 
 fn_install_steamcmd(){
+	if [ ${shortname} == "ark" ]&&[ "${installsteamcmd}" == "1" ]; then
+		steamcmddir="${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
+	fi
 	if [ ! -d "${steamcmddir}" ]; then
 		mkdir -pv "${steamcmddir}"
 	fi
@@ -50,8 +53,8 @@ fn_check_steamcmd(){
 		if [ "${function_selfname}" == "command_install.sh" ]; then
 			fn_install_steamcmd
 		else
-			fn_print_error_nl "SteamCMD is missing"
-			fn_script_log_error "SteamCMD is missing"
+			fn_print_warn_nl "SteamCMD is missing"
+			fn_script_log_warn "SteamCMD is missing"
 			fn_install_steamcmd
 		fi
 	elif [ "${function_selfname}" == "command_install.sh" ]; then
@@ -60,6 +63,25 @@ fn_check_steamcmd(){
 	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 [ "${function_selfname}" == "command_install.sh" ]; 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 [ "${function_selfname}" == "command_install.sh" ]; 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 "${steamcmddir}" ]; then
@@ -81,7 +103,10 @@ fn_check_steamcmd_exec(){
 	fi
 }
 
-fn_check_steamcmd
 fn_check_steamcmd_clear
+fn_check_steamcmd
+if [ ${shortname} == "ark" ]; then
+	fn_check_steamcmd_ark
+fi
 fn_check_steamcmd_user
 fn_check_steamcmd_exec

+ 19 - 15
lgsm/functions/fix_ark.sh

@@ -4,33 +4,37 @@
 # Website: https://linuxgsm.com
 # Description: Resolves various issues with ARK: Survival Evolved.
 
-# removes the symlink if broken. fixes issue with older versions of LinuxGSM linking to /home/arkserver/steamcmd
-# rather than ${HOME}/.steam. This fix could be deprecated eventually.
-if [ ! -e "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux" ]; then
-	fixname="broken steamcmd symlink"
+# removes the symlink if exists.
+# fixes issue with older versions of LinuxGSM linking to /home/arkserver/steamcmd
+if [ -L "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux" ]; then
+	fixname="broken SteamCMD symlink"
 	fn_fix_msg_start
-	rm -f "${serverfiles:?}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
+	unlink "${serverfiles:?}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
 	fn_fix_msg_end
+	check_steamcmd.sh
 fi
 
-if [ ! -e "${HOME}/.steam/steamcmd/steamapps" ]; then
-	fixname="broken steamcmd symlink"
+# removed ARK steamcmd directory if steamcmd is missing.
+if [ ! -f "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd.sh" ]; then
+	fixname="remove invalid ARK SteamCMD directory"
 	fn_fix_msg_start
-	rm -f "${HOME}/.steam/steamcmd/steamapps"
+	rm -rf "${serverfiles:?}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
 	fn_fix_msg_end
+	check_steamcmd.sh
 fi
 
-# Symlinking the SteamCMD directory into the correct ARK directory so that the mods auto-management will work.
-if [ ! -d "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux" ]; then
-	fixname="steamcmd symlink"
+# if the steamapps symlink is incorrect unlink it.
+if [ -d "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux" ]&&[ -L "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps" ]&&[ "$(readlink ${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps)" != "${HOME}/Steam/steamapps" ]; then
+	fixname="incorrect steamapps symlink"
 	fn_fix_msg_start
-	ln -s "${HOME}/.steam/steamcmd" "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
+	unlink "${serverfiles:?}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps"
 	fn_fix_msg_end
 fi
 
-if [ ! -d "${HOME}/.steam/steamcmd/steamapps" ]; then
-	fixname="steamcmd symlink"
+# Put symlink to steamapps directory into the ARK SteamCMD directory to link the downloaded mods to the correct location.
+if [ ! -L "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps" ]; then
+	fixname="steamapps symlink"
 	fn_fix_msg_start
-	ln -s "${HOME}/Steam/steamapps" "${HOME}/.steam/steamcmd/steamapps"
+	ln -s "${HOME}/Steam/steamapps" "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps"
 	fn_fix_msg_end
 fi