lib/scripts/download_file
changeset 80213 d13b8ee54885
parent 77053 c839b84ee66f
equal deleted inserted replaced
80212:67b5e8b88728 80213:d13b8ee54885
    14   type -p curl > /dev/null || {
    14   type -p curl > /dev/null || {
    15     echo "Require \"curl\" to download files" >&2
    15     echo "Require \"curl\" to download files" >&2
    16     return 2
    16     return 2
    17   }
    17   }
    18 
    18 
    19   local CURL_OPTIONS="--fail --silent --location"
       
    20   if [ "$(uname -s)" = "Darwin" ]
       
    21   then
       
    22     case $(sw_vers -productVersion) in
       
    23       10.*)
       
    24         CURL_OPTIONS="$CURL_OPTIONS --insecure"
       
    25         ;;
       
    26     esac
       
    27   fi
       
    28 
       
    29   echo "Getting \"$REMOTE\""
    19   echo "Getting \"$REMOTE\""
    30   mkdir -p "$(dirname "$LOCAL")"
    20   mkdir -p "$(dirname "$LOCAL")"
    31 
    21 
    32   if curl $CURL_OPTIONS "$REMOTE" > "${LOCAL}.part"
    22   if curl --fail --silent --location "$REMOTE" > "${LOCAL}.part"
    33   then
    23   then
    34     mv -f "${LOCAL}.part" "$LOCAL"
    24     mv -f "${LOCAL}.part" "$LOCAL"
    35   else
    25   else
    36     rm -f "${LOCAL}.part"
    26     rm -f "${LOCAL}.part"
    37     echo "Failed to download \"$REMOTE\"" >&2
    27     echo "Failed to download \"$REMOTE\"" >&2