diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-01-27 22:25:13 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-01-27 22:40:33 -0500 |
commit | bcee5a514fd0ec5675034fc0a50c547cca30d2de (patch) | |
tree | e784efa4e1cb5846129cb93ca209933c47efe16f /mirror.sh | |
download | mirror-util-bcee5a514fd0ec5675034fc0a50c547cca30d2de.tar.gz |
Initial commit
Diffstat (limited to 'mirror.sh')
-rwxr-xr-x | mirror.sh | 53 |
1 files changed, 53 insertions, 0 deletions
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" |