diff --git a/common.sh b/common.sh index b070738baa182d1967cbf647e843e64307904854..7794eb202502a30c91d78e0e184b6a801e132f67 100644 --- a/common.sh +++ b/common.sh @@ -36,3 +36,24 @@ function getProxyConf() puid=$(grep "^puid=" ${PROXYCONF} | cut -f2 -d=) ppasswd=$(grep "^ppasswd=" ${PROXYCONF} | cut -f2 -d=) } + +function tryWget(){ + getProxyConf + if test -z "$phost"; then + PROXY="" + else + PROXY="http://${phost}:${pport}" + fi + + if which wget &>/dev/null; then + WGETBIN="$(which wget)" + else + WGETBIN="${PREFIX}/bin/wget" + fi + + http_proxy="${PROXY}" ${WGETBIN} --tries=${UPDATETRIES} \ + --timeout=${UPDATETIMEOUT} \ + --proxy-user="${puid}" \ + --proxy-password="${ppasswd}" \ + $* || return 1 +}