From: <abe...@us...> - 2016-03-22 18:54:37
|
Revision: 7606 http://sourceforge.net/p/astlinux/code/7606 Author: abelbeck Date: 2016-03-22 18:54:35 +0000 (Tue, 22 Mar 2016) Log Message: ----------- download-file, replace hard-coded cloudfront.net HTTPS address with a CNAME lookup of mirror.astlinux.org Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/usr/sbin/download-file Modified: branches/1.0/project/astlinux/target_skeleton/usr/sbin/download-file =================================================================== --- branches/1.0/project/astlinux/target_skeleton/usr/sbin/download-file 2016-03-22 18:06:53 UTC (rev 7605) +++ branches/1.0/project/astlinux/target_skeleton/usr/sbin/download-file 2016-03-22 18:54:35 UTC (rev 7606) @@ -4,14 +4,34 @@ url="$2" -redirect_url() +redirect_url_to_https() { - local in_url="$1" out_url="$2" base_url + local host="$1" base_url cname - base_url="${url#$in_url}" - if [ "$url" != "$base_url" ]; then - url="$out_url$base_url" + base_url="$url" + base_url="${base_url#http://}" + base_url="${base_url#https://}" + + if [ "$host" != "${base_url%%/*}" ]; then + return fi + + if [ ! -x /usr/sbin/unbound-host ]; then + return + fi + + cname="$(/usr/sbin/unbound-host -t CNAME "$host" | sed -n -r -e 's/^.* CNAME .* ([^ ]+)$/\1/p' | head -n1)" + if [ -z "$cname" ]; then + return + fi + + if [ "$base_url" != "${base_url#*/}" ]; then + base_url="${base_url#*/}" + else + base_url="" + fi + + url="https://${cname%.}/${base_url}" } if [ -z "$file" -o -z "$url" ]; then @@ -19,10 +39,9 @@ exit 1 fi -## Redirect to AstLinux HTTPS mirror URL +## Redirect AstLinux mirror URL to HTTPS ## -redirect_url "http://mirror.astlinux.org/" "https://d7rzm9p7jly0z.cloudfront.net/" -redirect_url "https://mirror.astlinux.org/" "https://d7rzm9p7jly0z.cloudfront.net/" +redirect_url_to_https "mirror.astlinux.org" curl -sSfL --globoff --retry 1 --connect-timeout 15 --max-time 1800 -o "$file" "$url" >/dev/null This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |