source: dass-tools/usr/bin/mirror-urls.sh@ 1236

Last change on this file since 1236 was 1210, checked in by joergs, on Apr 12, 2016 at 4:58:03 PM

make mirror script more flexible.

Use configuration files and helper scripts.

  • Property svn:executable set to *
File size: 1.0 KB
RevLine 
[1091]1#!/bin/bash
2
[1210]3set -o errexit -o nounset
[1091]4
[1210]5CONFIG=${1:-/etc/mirror-urls.conf}
[1091]6
[1210]7# default value, may be overwritten by CONFIG
8DEST="/cds/linux/mirror/"
[1091]9
[1210]10if ! [ -r "$CONFIG" ]; then
11 echo "failed to read config file $CONFIG."
12 exit 1
13fi
14source $CONFIG
[1091]15
16FAILED=""
[1210]17SUCCESS=""
[1091]18
19cd $DEST
20
21for url in $PROJECTS; do
[1210]22 printf "$url:\n"
23 protocol=`sed -r "s|^([a-zA-Z]+)://.*|\1|" <<< $url`
24 host=`sed -r "s|^$protocol://([^/]+)/.*|\1|" <<< $url`
25 path=`sed -r "s|$protocol://$host||" <<< $url`
26 mkdir -p $host/$path
27 DESTDIR=$DEST/$host/$path
28 #set -x
29 if ! lftp -c "open -e \"mirror --verbose=1 --parallel=20 --continue --delete $path/. ${DESTDIR}\" ${protocol}://${host}"; then
30 set +x
31 printf " failed\n"
32 FAILED="$FAILED $url"
33 else
34 set +x
35 if [ "${POST_SCRIPT:-}" ]; then
36 $POST_SCRIPT ${DESTDIR}
37 fi
38 printf " ${DESTDIR}\n"
39 SUCCESS="$SUCCESS $url"
40 fi
41 printf "\n"
[1091]42done
43
[1210]44if [ "${REPORT_SCRIPT:-}" ]; then
45 $REPORT_SCRIPT mirror-urls "$SUCCESS" "$FAILED"
46fi
Note: See TracBrowser for help on using the repository browser.