Преглед на файлове

fix(ct): keep Craftopia saves inside serverfiles (#5131)

Craftopia joins its install folder and the relative savePath from ServerSetting.ini with no separator, so saves went to serverfilesDedicatedServerSave beside serverfiles. A new pre-start fix (fix_ct.sh) moves an existing stray save folder into serverfiles and sets savePath to the absolute path. If saves exist in both places it warns and changes nothing, and an absolute savePath set by the owner is left alone.

Fixes #5130
Daniel Gibbs преди 6 дни
родител
ревизия
eeb6c9a7e5
променени са 3 файла, в които са добавени 43 реда и са изтрити 1 реда
  1. 5 0
      lgsm/modules/core_modules.sh
  2. 1 1
      lgsm/modules/fix.sh
  3. 37 0
      lgsm/modules/fix_ct.sh

+ 5 - 0
lgsm/modules/core_modules.sh

@@ -433,6 +433,11 @@ fix_csgo.sh() {
 	fn_fetch_module
 }
 
+fix_ct.sh() {
+	modulefile="${FUNCNAME[0]}"
+	fn_fetch_module
+}
+
 fix_dst.sh() {
 	modulefile="${FUNCNAME[0]}"
 	fn_fetch_module

+ 1 - 1
lgsm/modules/fix.sh

@@ -53,7 +53,7 @@ fn_apply_fix() {
 	fi
 }
 
-apply_pre_start_fix=(arma3 armar ark av bf1942 bfv bt bo csgo cmw cod cod2 coduo dst hw ins ios kf nd nmrih onset pvr ro rust rw samp sdtd sfc sm sof2 squad st tf2 terraria ts3 mcb mohaa mta unt vh wurm xnt zmr)
+apply_pre_start_fix=(arma3 armar ark av bf1942 bfv bt bo csgo cmw cod cod2 coduo ct dst hw ins ios kf nd nmrih onset pvr ro rust rw samp sdtd sfc sm sof2 squad st tf2 terraria ts3 mcb mohaa mta unt vh wurm xnt zmr)
 apply_post_install_fix=(av kf kf2 nd ro ut2k4 ut ut3)
 
 # validate registered fixes for safe development

+ 37 - 0
lgsm/modules/fix_ct.sh

@@ -0,0 +1,37 @@
+#!/bin/bash
+# LinuxGSM fix_ct.sh module
+# Author: Daniel Gibbs
+# Contributors: https://linuxgsm.com/contrib
+# Website: https://linuxgsm.com
+# Description: Resolves issues with Craftopia.
+
+moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+if [ -f "${servercfgfullpath}" ]; then
+	savepath="$(sed -n 's/^savePath=//p' "${servercfgfullpath}" | tr -d '\r')"
+	if [ -n "${savepath}" ] && [ "${savepath:0:1}" != "/" ]; then
+		oldsavedir="${serverfiles}${savepath%/}"
+		newsavedir="${serverfiles}/${savepath%/}"
+		if [ -e "${oldsavedir}" ] && [ -e "${newsavedir}" ]; then
+			fn_print_warn_nl "Craftopia saves found in both ${oldsavedir} and ${newsavedir}"
+			fn_script_log_warn "Craftopia saves found in both ${oldsavedir} and ${newsavedir}"
+			echo -e "* Keep the one you want in ${newsavedir}, remove the other, then start again."
+		else
+			if [ -e "${oldsavedir}" ]; then
+				fixname="move saves to ${newsavedir}"
+				fn_fix_msg_start
+				mkdir -p "$(dirname "${newsavedir}")"
+				mv "${oldsavedir}" "${newsavedir}"
+				exitcode=$?
+				fn_fix_msg_end
+			fi
+			if [ ! -e "${oldsavedir}" ]; then
+				fixname="savePath ${serverfiles}/${savepath}"
+				fn_fix_msg_start
+				sed -i "s|^savePath=[^\r]*|savePath=${serverfiles}/${savepath}|" "${servercfgfullpath}"
+				exitcode=$?
+				fn_fix_msg_end
+			fi
+		fi
+	fi
+fi