mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 01:26:38 +00:00
[go-xcat] Fix github issue #2543, better error handling for wget
This commit is contained in:
parent
909bfae24c
commit
dbf5c23c8f
@ -2,7 +2,7 @@
|
||||
#
|
||||
# go-xcat - Install xCAT automatically.
|
||||
#
|
||||
# Version 1.0.13
|
||||
# Version 1.0.14
|
||||
#
|
||||
# Copyright (C) 2016 International Business Machines
|
||||
# Eclipse Public License, Version 1.0 (EPL-1.0)
|
||||
@ -636,7 +636,29 @@ function download_file()
|
||||
type wget >/dev/null 2>&1 || return 255
|
||||
local url="$1"
|
||||
local local_file="$2"
|
||||
wget -U "${user_agent}" -q "${url}" -O "${local_file}"
|
||||
local log_file="${TMP_DIR}/wget.log.${RANDOM}"
|
||||
local -i rc=0
|
||||
wget -U "${user_agent}" -nv "${url}" -O "${local_file}" -o "${log_file}"
|
||||
rc="$?"
|
||||
if [[ "${rc}" -ne "0" ]]
|
||||
then
|
||||
while read -r ; do echo "${REPLY}" ; done <"${log_file}"
|
||||
echo -n "${script}: \`wget' exited with an error: (exit code ${rc}, "
|
||||
case "${rc}" in
|
||||
1) echo -n "generic error" ;;
|
||||
2) echo -n "parse error" ;;
|
||||
3) echo -n "file I/O error" ;;
|
||||
4) echo -n "network failure" ;;
|
||||
5) echo -n "SSL verification failure" ;;
|
||||
6) echo -n "username/password authentication failure" ;;
|
||||
7) echo -n "protocol errors" ;;
|
||||
8) echo -n "server issued an error response" ;;
|
||||
*) echo -n "unknown error" ;;
|
||||
esac
|
||||
echo ")"
|
||||
echo " ... while downloading \`${url}'"
|
||||
fi >&2
|
||||
[[ "${rc}" -eq "0" ]]
|
||||
}
|
||||
|
||||
# $1 repo file
|
||||
|
Loading…
x
Reference in New Issue
Block a user