On 5 April 2016 at 16:33, Oliver Lloyd <[email protected]> wrote: > In the end I wrote a function. It solved the closer.cgi issue I was having by > using the as_json=1 query param that Vladimir suggested. > > #!/bin/bash > > function install_jmeter() { > # ------------------------------------------------ > # Decide where to download jmeter from > # > # Order of preference: > # 1. Mirror, if the desired version is current > # 2. S3, if not current and we have a copy > # 3. Archive, as a backup > # ------------------------------------------------ > > # Mirrors only host the current version, get the preferred mirror for > this location > preferred_mirror=$(curl -s > 'http://www.apache.org/dyn/closer.cgi?as_json=1' | grep "preferred" | cut -d > ':' -f3 | cut -d'"' -f1 | awk -F// '{print $NF}' | sed 's/.$//')
There's no need to extract the preferred mirror, see below. > # Scrape the main binaries page to see what the current version is > current=$(curl -s 'http://www.apache.org/dist/jmeter/binaries/') Once you have the current version file stem, you can to use the URL I gave you earlier to download it directly using a preferred mirror: wget -q -O $REMOTE_HOME/$JMETER_VERSION.tgz "http://www.apache.org/dyn/closer.cgi?filename=jmeter/binaries/$JMETER_VERSION.tgz&action=download" I just tried it, and it works. > if [ $(echo $current | grep -c "$JMETER_VERSION") -gt "0" ] ; then > # This is the current version of jmeter so use the preferred mirror > to download > echo "downloading from preferred mirror: > http://$preferred_mirror/jmeter/binaries/$JMETER_VERSION.tgz" > wget -q -O $REMOTE_HOME/$JMETER_VERSION.tgz > http://$preferred_mirror/jmeter/binaries/$JMETER_VERSION.tgz > elif [ $(curl -sI https://s3.amazonaws.com/jmeter-ec2/$JMETER_VERSION.tgz > | grep -c "403 Forbidden") -eq "0" ] ; then > # It wasn't the current version but we have a copy on S3 so use that > echo "Downloading jmeter from S3" > wget -q -O $REMOTE_HOME/$JMETER_VERSION.tgz > https://s3.amazonaws.com/jmeter-ec2/$JMETER_VERSION.tgz > else > # Fall back to the archive server > echo "Downloading jmeter from Apache Archive" > wget -q -O $REMOTE_HOME/$JMETER_VERSION.tgz > http://archive.apache.org/dist/jmeter/binaries/$JMETER_VERSION.tgz > fi > > # Untar downloaded file > tar -xf $REMOTE_HOME/$JMETER_VERSION.tgz > } > JMETER_VERSION="apache-jmeter-2.13" > REMOTE_HOME="/tmp" > install_jmeter > > > > >> On 5 Apr 2016, at 13:21, Felix Schumacher >> <[email protected]> wrote: >> >> >> >> Am 4. April 2016 14:29:13 MESZ, schrieb Oliver Lloyd >> <[email protected]>: >>> That url is in theory exactly what I need and it works well in a >>> browser but I'm not able to make it work from the CLI using something >>> like wget or curl. Does anyone know how to make that cgi script serve >>> me the file and not just the html for the download page? >> >> Have you tried "curl -L 'http://..."? >> >> Regards, >> Felix >> >>> >>> >>>> On 3 Apr 2016, at 22:48, sebb <[email protected]> wrote: >>>> >>>> On 3 April 2016 at 20:46, Oliver Lloyd <[email protected]> >>> wrote: >>>>> Bintray sounds ideal. Speeds between dl.bintray.com and AWS are very >>> fast. >>>>> >>>>> My issue is I can't really use a mirror because they change but >>> linking to the host servers is bad because they're not designed to >>> serve these files. A distribution as a service provider like bintray >>> would definitely solve this problem. >>>> >>>> Why not? >>>> >>>> It's possible to use the automatic mirror chooser with a parameter >>>> that automatically downloads: >>>> >>>> >>> http://www.apache.org/dyn/closer.cgi?filename=jmeter/binaries/apache-jmeter-2.13.zip&action=download >>>> >>>>> In the meantime I'm experimenting with using 'www.apache.org/dist/ >>> <http://www.apache.org/dist/>...' vs. 'archive.apache.org/dist/ >>> <http://archive.apache.org/dist/>...' and this seems better. >>>> >>>> Neither of those should be used for normal downloads. >>>> They are for last resort backup purposes / archived releases only. >>>> >>>>> >>>>>> On 3 Apr 2016, at 20:31, Vladimir Sitnikov >>> <[email protected]> wrote: >>>>>> >>>>>> What if we deployed binary artifacts to maven, then they would get >>>>>> mirrored to bintray? >>>>>> >>>>>> Groovy is using bintray.com for distribution of their binaries: >>>>>> http://groovy-lang.org/download.html links to >>>>>> https://dl.bintray.com/groovy/maven/apache-groovy-sdk-2.4.6.zip >>>>>> >>>>>> Oliver, >>>>>> Can I kindly ask you to download something like >>>>>> https://dl.bintray.com/groovy/maven/apache-groovy-sdk-2.4.6.zip >>>>>> to check if that will be good enough? >>>>>> >>>>>> Vladimir >>>>>> >>>>> >>>> >> >> >
