Skip to content

Commit efdc530

Browse files
namrathaursmambelli
authored andcommitted
added suitable handling for proxy availability
1 parent 022eb8e commit efdc530

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

creation/web_base/glidein_startup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,29 @@ add_config_file() {
834834
fi
835835
}
836836

837+
test_proxy_availability() {
838+
# Return 1 if the URL retrieval via HTTP proxy is failing,
839+
# 0 otherwise (success or `wget` and `curl` not available)
840+
local proxy_url_test=$1
841+
local test_file=$2
842+
843+
# check whether wget or curl is available for use
844+
if wget --version > /dev/null 2>&1; then
845+
# wget found, use wget for the test
846+
if ! wget -qO /dev/null -e use_proxy=yes -e http_proxy="$proxy_url_test" "${test_file}" 2>&1; then
847+
return 1
848+
fi
849+
elif curl --version > /dev/null 2>&1; then
850+
# curl found, use curl for the test
851+
if ! curl -so /dev/null --proxy "$proxy_url_test" "$test_file" 2>&1; then
852+
return 1
853+
fi
854+
else
855+
echo "Neither wget nor curl command found. Skipping proxy availability test." 1>&2
856+
fi
857+
# implied return of exit status 0
858+
}
859+
837860
#####################
838861
# Fetch a single file
839862
#
@@ -1479,6 +1502,14 @@ if [ "${proxy_url}" = "OSG" ]; then
14791502
fi
14801503
fi
14811504

1505+
# testing proxy availability now...
1506+
if [[ -n "${proxy_url}" && "${proxy_url}" != "None" ]]; then
1507+
if ! test_proxy_availability "${proxy_url}" "${repository_url}/glidein_startup.sh"; then
1508+
echo "Resetting the HTTP proxy. The configured one ($proxy_url) seems unavailable!" 1>&2
1509+
proxy_url="None"
1510+
fi
1511+
fi
1512+
14821513
if [ -z "${sign_id}" ]; then
14831514
warn "Missing signature."
14841515
usage

0 commit comments

Comments
 (0)