Parcourir la source

Added optionto delete unknown functions in function dir

should a non existant or random file be put in to the functions dir it will be removed
Daniel Gibbs il y a 9 ans
Parent
commit
9d046fcb8e
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8 2
      lgsm/functions/command_update_linuxgsm.sh

+ 8 - 2
lgsm/functions/command_update_linuxgsm.sh

@@ -75,8 +75,14 @@ if [ -n "${functionsdir}" ]; then
 		for functionfile in *
 		for functionfile in *
 		do
 		do
 			echo -ne "    checking function ${functionfile}...\c"
 			echo -ne "    checking function ${functionfile}...\c"
-			function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
-			if [ "${function_file_diff}" != "" ]; then
+			function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}";exitcode=$?))
+			exitcode=$?
+			if [ "${exitcode}" -ne 0 ]; then
+				fn_print_fail_eol_nl
+				echo -ne "    removing unknown function ${functionfile}...\c"
+				fn_script_log_fatal "removing unknown function ${functionfile}"
+				rm -f "${functionfile}"
+			elif [ "${function_file_diff}" != "" ]; then
 				fn_print_update_eol_nl
 				fn_print_update_eol_nl
 				fn_script_log_info "checking function ${functionfile}: UPDATE"
 				fn_script_log_info "checking function ${functionfile}: UPDATE"
 				rm -rf "${functionsdir}/${functionfile}"
 				rm -rf "${functionsdir}/${functionfile}"