Răsfoiți Sursa

fixing issues with curl

Daniel Gibbs 9 ani în urmă
părinte
comite
16c94f854a

+ 7 - 6
lgsm/functions/command_update_functions.sh

@@ -21,17 +21,18 @@ if [ -n "${rootdir}" ]; then
 		exitcode=$?
 	fi
 fi
-# Check if curl exists and use available path
+# Check curl exists and use available path
 curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
-for curlcmd in ${curlpaths}
+for curlpath in ${curlpaths}
 do
-	if [ -x "${curlcmd}" ]; then
-		curlcmd=${curlcmd}
+	if [ -x "${curlpath}" ]; then
 		break
 	fi
 done
+
+
 echo -ne "    checking _default.cfg...\c"
-function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${servername}/_default.cfg"))
+function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${servername}/_default.cfg"))
 if [ "${function_file_diff}" != "" ]; then
 	fn_print_update_eol_nl
 	fn_script_log_info "checking ${functionfile}: UPDATE"
@@ -48,7 +49,7 @@ if [ -n "${functionsdir}" ]; then
 		for functionfile in *
 		do
 			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}"))
+			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
 				fn_print_update_eol_nl
 				fn_script_log_info "checking ${functionfile}: UPDATE"

+ 5 - 5
lgsm/functions/core_dl.sh

@@ -106,25 +106,25 @@ fn_fetch_file(){
 
 		# Check curl exists and use available path
 		curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
-		for curlcmd in ${curlpaths}
+		for curlpath in ${curlpaths}
 		do
-			if [ -x "${curlcmd}" ]; then
+			if [ -x "${curlpath}" ]; then
 				break
 			fi
 		done
 		# If curl exists download file
-		if [ "$(basename ${curlcmd})" == "curl" ]; then
+		if [ "$(basename ${curlpath})" == "curl" ]; then
 			# trap to remove part downloaded files
 			trap fn_fetch_trap INT
 			# if larger file shows progress bar
 			if [ "${filename##*.}" == "bz2" ]||[ "${filename##*.}" == "gz" ]||[ "${filename##*.}" == "zip" ]||[ "${filename##*.}" == "jar" ]; then
 				echo -ne "downloading ${filename}..."
 				sleep 1
-				curlcmd=$(${curlcmd} --progress-bar --fail -L -o "${filedir}/${filename}" "${fileurl}")
+				curlcmd=$(${curlpath} --progress-bar --fail -L -o "${filedir}/${filename}" "${fileurl}")
 				echo -ne "downloading ${filename}..."
 			else
 				echo -ne "    fetching ${filename}...\c"
-				curlcmd=$(${curlcmd} -s --fail -L -o "${filedir}/${filename}" "${fileurl}" 2>&1)
+				curlcmd=$(${curlpath} -s --fail -L -o "${filedir}/${filename}" "${fileurl}" 2>&1)
 			fi
 			local exitcode=$?
 			if [ ${exitcode} -ne 0 ]; then

+ 5 - 5
lgsm/functions/core_functions.sh

@@ -56,18 +56,18 @@ if [ ! -f "${filedir}/${filename}" ]; then
 	echo -e "    fetching ${filename}...\c"
 	# Check curl exists and use available path
 	curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
-	for curlcmd in ${curlpaths}
+	for curlpath in ${curlpaths}
 	do
-		if [ -x "${curlcmd}" ]; then
+		if [ -x "${curlpath}" ]; then
 			break
 		fi
 	done
 	# If curl exists download file
-	if [ "$(basename ${curlcmd})" == "curl" ]; then
-		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
+	if [ "$(basename ${curlpath})" == "curl" ]; then
+		curlcmd=$(${curlpath} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
 		if [ $? -ne 0 ]; then
 			echo -e "${red}FAIL${default}\n"
-			echo "${curlfetch}"
+			echo "${curlcmd}"
 			echo -e "${githuburl}\n"
 			exit 1
 		else

+ 4 - 4
linuxgsm.sh

@@ -72,17 +72,17 @@ fn_bootstrap_fetch_file(){
 		fi
 		# Check curl exists and use available path
 		curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
-		for curlcmd in ${curlpaths}
+		for curlpath in ${curlpaths}
 		do
-			if [ -x "${curlcmd}" ]; then
+			if [ -x "${curlpath}" ]; then
 				break
 			fi
 		done
 		# If curl exists download file
-		if [ "$(basename ${curlcmd})" == "curl" ]; then
+		if [ "$(basename ${curlpath})" == "curl" ]; then
 			# trap to remove part downloaded files
 			echo -ne "    fetching ${filename}...\c"
-			curlcmd=$(${curlcmd} -s --fail -L -o "${filedir}/${filename}" "${fileurl}" 2>&1)
+			curlcmd=$(${curlpath} -s --fail -L -o "${filedir}/${filename}" "${fileurl}" 2>&1)
 			local exitcode=$?
 			if [ ${exitcode} -ne 0 ]; then
 				echo -e "\e[0;31mFAIL\e[0m\n"