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

added check for missing remote file

Daniel Gibbs 10 лет назад
Родитель
Сommit
860e3e4ee5
1 измененных файлов с 14 добавлено и 6 удалено
  1. 14 6
      lgsm/functions/command_update_functions.sh

+ 14 - 6
lgsm/functions/command_update_functions.sh

@@ -27,13 +27,21 @@ if [ -n "${functionsdir}" ]; then
 		cd "${functionsdir}"
 		for functionfile in *
 		do
-			#functionfile=core_exit.sh
-			echo "FUNCTIONFILE: ${functionfile}"
-			function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl -s https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}))
+			echo -ne "   checking ${functionfile}...\c"
+			function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
 			if [ "${function_file_diff}" != "" ]; then
-				echo "rm -rfv ${functionsdir}/${functionfile}"
-				rm -rfv "${functionsdir}/${functionfile}"
-				fn_update_function
+				${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"
+				local exitcode=$?
+				if [ "${exitcode}" != "0" ]; then
+					echo -ne "   checking ${functionfile}...FAIL"
+					rm -rfv "${functionsdir}/${functionfile}"
+				else
+					echo -ne "   checking ${functionfile}...UPDATE"
+					rm -rfv "${functionsdir}/${functionfile}"
+					fn_update_function
+				fi
+			else
+				echo -ne "   checking ${functionfile}...OK"
 			fi
 		done
 	fi