From c25418118a300c6e7efea21c0c0a0d3ddd97de0a Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Fri, 17 Jan 2014 00:55:57 +0000 Subject: [PATCH] Add initial grab_file helper for http download support --- tools/grab_file | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 tools/grab_file diff --git a/tools/grab_file b/tools/grab_file new file mode 100755 index 00000000..24b260ca --- /dev/null +++ b/tools/grab_file @@ -0,0 +1,32 @@ +#!/bin/sh +# +# grab_file +# +# extra utility script - if a file does not exist in our mirror and +# we've been told to use an http mirror, go grab it from there +# +# Takes 1 parameters: the the full path to the file (relative to the +# base dir of the mirror) +# +# The MIRROR env var must be set +# If we want to be able to download, HTTPMIRROR mus be set too + +set -e +#set -x + +WANTED=$1 + +if [ "$MIRROR"x = ""x ] ; then + echo $0: MIRROR not set + exit 1 +fi + +if [ -e "$MIRROR/$WANTED" ] ; then + exit 0 +fi + +# else + +DIR=$(dirname "$WANTED") +mkdir -p "$MIRROR/$DIR" +wget -o /tmp/log -q "$HTTPMIRROR/$WANTED" -O "$MIRROR/$WANTED"