From bcee5a514fd0ec5675034fc0a50c547cca30d2de Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 27 Jan 2018 22:25:13 -0500 Subject: Initial commit --- mirror.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 mirror.sh (limited to 'mirror.sh') diff --git a/mirror.sh b/mirror.sh new file mode 100755 index 0000000..86c982d --- /dev/null +++ b/mirror.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +function mirror_parent_channel() { + # This is not a general purpose tool. Do not use it as such. + # + # mirror_parent_channel http://example-conda.com/some-channel /some/path/to/store/it + # + # /some/path/to/store/it will end up looking like so: + # + # + it + # `- linux-64 + # `- osx-64 + # `- win-64 + # `- noarch + # `- ... + # + + local url="$1" + local dest="$2" + local _retval= + + if [[ -z $url ]]; then + echo "URL required." + return 1 + fi + + if [[ -z $dest ]]; then + echo "Destination directory not defined." + return 1 + fi + + if [[ ! -d $dest ]]; then + mkdir -p "$dest" + fi + + pushd "$dest" &>/dev/null + wget \ + --no-verbose \ + --timestamping \ + --accept '*.bz2','*.json*' \ + --recursive \ + --no-parent \ + --no-host-directories \ + --cut-dirs=1 \ + --level=2 \ + "$url" + _retval=$? + + popd &>/dev/null + return $_retval +} + +mirror_parent_channel "$1" "$2" -- cgit