Commit 4c3f5d2f authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: add EGET_MIRRORS variable support with eterfund defaults

parent d5411856
...@@ -295,6 +295,8 @@ is_numeric() ...@@ -295,6 +295,8 @@ is_numeric()
# args: cmd <URL> <options> # args: cmd <URL> <options>
# will run cmd <options> <URL> # will run cmd <options> <URL>
# If CHECKMIRRORS is set and EGET_MIRRORS contains mirror hosts,
# will try each mirror on failure
download_with_mirroring() download_with_mirroring()
{ {
local CMD="$1" local CMD="$1"
...@@ -307,13 +309,14 @@ download_with_mirroring() ...@@ -307,13 +309,14 @@ download_with_mirroring()
res=$? res=$?
[ -n "$CHECKMIRRORS" ] || return $res [ -n "$CHECKMIRRORS" ] || return $res
MIRROR="https://mirror.eterfund.ru" # Default mirrors if EGET_MIRRORS is not set
SECONDURL="$(echo "$URL" | sed -e "s|^.*://|$MIRROR/|")" local mirrors="${EGET_MIRRORS:-https://mirror.eterfund.ru https://mirror.eterfund.org}"
$CMD "$@" "$SECONDURL" && URL="$SECONDURL" && return local MIRROR SECONDURL
for MIRROR in $mirrors ; do
MIRROR="https://mirror.eterfund.org" # Replace protocol:// with mirror/, preserving original host as path component
SECONDURL="$(echo "$URL" | sed -e "s|^.*://|$MIRROR/|")" SECONDURL="$(echo "$URL" | sed -e "s|^[a-z]*://|$MIRROR/|")"
$CMD "$@" "$SECONDURL" && URL="$SECONDURL" && return $CMD "$@" "$SECONDURL" && return
done
return $res return $res
} }
...@@ -437,7 +440,7 @@ Options: ...@@ -437,7 +440,7 @@ Options:
--load-cookies file - load cookies from file before the first HTTP retrieval --load-cookies file - load cookies from file before the first HTTP retrieval
--latest - print only latest version of a file --latest - print only latest version of a file
--second-latest - print only second to latest version of a file --second-latest - print only second to latest version of a file
--allow-mirrors - check mirrors if url is not accessible --allow-mirrors - try mirrors from EGET_MIRRORS if url is not accessible
--trust-server-names - use the name specified by the redirection --trust-server-names - use the name specified by the redirection
--list|--list-only - print only URLs --list|--list-only - print only URLs
...@@ -455,6 +458,7 @@ Supported backends (set like EGET_BACKEND=curl) ...@@ -455,6 +458,7 @@ Supported backends (set like EGET_BACKEND=curl)
wget, curl and partially aria2c, axel, rsync wget, curl and partially aria2c, axel, rsync
Also you can set EGET_OPTIONS variable with needed options Also you can set EGET_OPTIONS variable with needed options
Set EGET_MIRRORS to override default mirrors for --allow-mirrors (default: eterfund mirrors)
Examples: Examples:
$ eget http://ftp.somesite.ru/package-*.x64.tar $ eget http://ftp.somesite.ru/package-*.x64.tar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment