Jelajahi Sumber

Added error checking

Daniel Gibbs 10 tahun lalu
induk
melakukan
ff4b712f47
1 mengubah file dengan 28 tambahan dan 16 penghapusan
  1. 28 16
      functions/fn_csgofix

+ 28 - 16
functions/fn_csgofix

@@ -22,31 +22,39 @@ fi
 fn_csgofixes(){
 # Fixes the following error:
 # Error parsing BotProfile.db - unknown attribute 'Rank".
-if ! grep -q "//Rank" "${systemdir}/botprofile.db" ; then
+if ! grep -q "//Rank" "${systemdir}/botprofile.db" > /dev/null 2>&1; then
+	echo "Applying botprofile.db fix."
+	sleep 1
+	echo ""
 	echo "botprofile.db fix removes the following error from appearing on the console:"
 	echo "	Error parsing BotProfile.db - unknown attribute 'Rank"
 	sleep 1
-	fn_printdots "Applying botprofile.db fix."
-	sleep 1
-	fn_printinfo "Applying botprofile.db fix."
-	sleep 1
-	sed -i 's/\tRank/\t\/\/Rank/g' "${systemdir}/botprofile.db"
+	sed -i 's/\tRank/\t\/\/Rank/g' "${systemdir}/botprofile.db" > /dev/null 2>&1
+	if [[ $? != 0 ]]; then
+		fn_printfailure "Applying botprofile.db fix."
+	else
+		fn_printcomplete "Applying botprofile.db fix."
+	fi
 	echo -en "\n"
 	echo ""
 fi
 
 # Fixes errors simular to the following:
 # Unknown command "cl_bobamt_vert".
-if ! grep -q "//exec default" "${servercfgdir}/valve.rc" || ! grep -q "//exec joystick" "${servercfgdir}/valve.rc"; then
+if ! grep -q "//exec default" "${servercfgdir}/valve.rc" > /dev/null 2>&1 || ! grep -q "//exec joystick" "${servercfgdir}/valve.rc" > /dev/null 2>&1; then
+	echo "Applying valve.rc fix."
+	sleep 1
+	echo ""	
 	echo "valve.rc fix removes the following error from appearing on the console:"
 	echo "	Unknown command \"cl_bobamt_vert\""
 	sleep 1
-	fn_printdots "Applying valve.rc fix."
-	sleep 1
-	fn_printinfo "Applying valve.rc fix."
-	sleep 1
-	sed -i 's/exec default.cfg/\/\/exec default.cfg/g' "${servercfgdir}/valve.rc"
-	sed -i 's/exec joystick.cfg/\/\/exec joystick.cfg/g' "${servercfgdir}/valve.rc"
+	sed -i 's/exec default.cfg/\/\/exec default.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1
+	sed -i 's/exec joystick.cfg/\/\/exec joystick.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1
+	if [[ $? != 0 ]]; then
+		fn_printfailure "Applying valve.rc fix."
+	else
+		fn_printcomplete "Applying valve.rc fix."
+	fi
 	echo -en "\n"
 	echo ""
 fi
@@ -57,13 +65,17 @@ if [ -f "${systemdir}/subscribed_collection_ids.txt" ]||[ -f "${systemdir}/subsc
 	echo "workshopmapfix fixes the following error:"
 	echo "	http://forums.steampowered.com/forums/showthread.php?t=3170366"
 	sleep 1
-	fn_printdots "Applying workshopmap fix."
-	sleep 1
-	fn_printinfo "Applying workshopmap fix."
+	echo ""
+	echo "Applying workshopmap fix."
 	sleep 1
 	rm -f "${systemdir}/subscribed_collection_ids.txt"
 	rm -f "${systemdir}/subscribed_file_ids.txt"
 	rm -f "${systemdir}/ugc_collection_cache.txt"
+	if [[ $? != 0 ]]; then
+		fn_printfailure "Applying workshopmap fix."
+	else
+		fn_printcomplete "Applying workshopmap fix."
+	fi
 	echo -en "\n"
 	echo ""
 fi