27 lines
596 B
Bash
Executable file
27 lines
596 B
Bash
Executable file
#!/bin/bash
|
|
|
|
base=$1
|
|
target=$2
|
|
dir=`mktemp -d`
|
|
|
|
if [ -z $MIRROR_MDQ_POST ]; then
|
|
MIRROR_MDQ_POST=/etc/mirror-mdq/post.d
|
|
fi
|
|
|
|
function cleanup() {
|
|
rm -rf $dir
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
mkdir -p $target && (
|
|
cd $dir
|
|
WGET_ARGS="--mirror --no-host-directories -q"
|
|
idx_obj=".well-known/webfinger?rel=urn:oasis:names:tc:SAML:2.0:metadata"
|
|
wget $WGET_ARGS "$base/$idx_obj" && jq -r '.links[].href' < "$idx_obj" | wget $WGET_ARGS -i -
|
|
if [ -d $MIRROR_MDQ_POST ]; then
|
|
env SOURCE=$1 TARGET=$target IDX_OBJ=$idx_obj run-parts $MIRROR_MDQ_POST
|
|
fi
|
|
)
|
|
|
|
rsync -az $RSYNC_ARGS --delete $dir/ $target/
|