Quellcode durchsuchen

Changes & echoing for diagnose purposes

UltimateByte vor 9 Jahren
Ursprung
Commit
d47652db63
1 geänderte Dateien mit 10 neuen und 7 gelöschten Zeilen
  1. 10 7
      lgsm/functions/mods_core.sh

+ 10 - 7
lgsm/functions/mods_core.sh

@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
 # Website: https://gameservermanagers.com
-# Description: List and installs available mods along with mods_list.sh.
+# Description: Core functions for mods list/install/update/remove
 
 
 local commandname="MODS"
 local commandname="MODS"
 local commandaction="Core functions for mods"
 local commandaction="Core functions for mods"
@@ -12,6 +12,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 ## Useful variables
 ## Useful variables
 # Files and Directories
 # Files and Directories
 modstmpdir="${tmpdir}/mods"
 modstmpdir="${tmpdir}/mods"
+extractdir="${modstmpdir}/extracted"
 modsdatadir="${lgsmdir}/data/mods"
 modsdatadir="${lgsmdir}/data/mods"
 modslockfile="installed-mods-listing"
 modslockfile="installed-mods-listing"
 modslockfilefullpath="${modsdatadir}/${modslockfile}"
 modslockfilefullpath="${modsdatadir}/${modslockfile}"
@@ -65,7 +66,6 @@ fn_mod_dl(){
 fn_mod_extract(){
 fn_mod_extract(){
 	# fn_dl_extract "${filedir}" "${filename}" "${extractdir}"
 	# fn_dl_extract "${filedir}" "${filename}" "${extractdir}"
 	filename="${modfilename}"
 	filename="${modfilename}"
-	extractdir="${modstmpdir}/extracted"
 	if [ ! -d "${extractdir}" ]; then
 	if [ ! -d "${extractdir}" ]; then
 		mkdir -p "${extractdir}"
 		mkdir -p "${extractdir}"
 	fi
 	fi
@@ -89,15 +89,18 @@ fn_remove_cfg_files(){
 	if [ "${modkeepfiles}" !=  "OVERWRITE" ]&&[ "${modkeepfiles}" != "NOUPDATE" ]; then
 	if [ "${modkeepfiles}" !=  "OVERWRITE" ]&&[ "${modkeepfiles}" != "NOUPDATE" ]; then
 		# Upon mods updates, config files should not be overwritten
 		# Upon mods updates, config files should not be overwritten
 		# We will just remove these files before copying the mod to the destination
 		# We will just remove these files before copying the mod to the destination
+		# Let's count how many files there are to remove
 		removefilesamount="$(echo "${modkeepfiles}" | awk -F ';' '{ print NF }')"
 		removefilesamount="$(echo "${modkeepfiles}" | awk -F ';' '{ print NF }')"
 		# Test all subvalue of "modgames" using the ";" separator
 		# Test all subvalue of "modgames" using the ";" separator
 		for ((removefilesindex=1; removefilesindex < ${removefilesamount}; removefilesindex++)); do
 		for ((removefilesindex=1; removefilesindex < ${removefilesamount}; removefilesindex++)); do
-			# Put current game name into modtest variable
-			removefiletest="$( echo "${modkeepfiles}" | awk -F ';' -v x=${removefilesindex} '{ print $x }' )"
-			# If it matches
-			if [ -f "${extractdir}/${removefiletest}" ]||[ -d "${extractdir}/${removefiletest}" ]; then
+			# Put current file we're looking for into a variable
+			filetoremove="$( echo "${modkeepfiles}" | awk -F ';' -v x=${removefilesindex} '{ print $x }' )"
+			echo "Testing ${filetoremove}"
+			# If it matches an existing file that have been extracted
+			if [ -f "${extractdir}/${filetoremove}" ]||[ -d "${extractdir}/${filetoremove}" ]; then
+				echo "Removing ${extractdir}/${filetoremove}"
 				# Then delete the file!
 				# Then delete the file!
-				rm -R "${extractdir}/${removefiletest}"
+				rm -R "${extractdir}/${filetoremove}"
 				# Write this file path in a tmp file, to rebuild a full file list
 				# Write this file path in a tmp file, to rebuild a full file list
 				if [ ! -f "${modsdatadir}/.removedfiles.tmp" ]; then
 				if [ ! -f "${modsdatadir}/.removedfiles.tmp" ]; then
 					touch "${modsdatadir}/.removedfiles.tmp"
 					touch "${modsdatadir}/.removedfiles.tmp"