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

Last change on this file since 1259 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
Line 
1#!/bin/bash
2
3set -o errexit -o nounset
4
5CONFIG=${1:-/etc/mirror-urls.conf}
6
7# default value, may be overwritten by CONFIG
8DEST="/cds/linux/mirror/"
9
10if ! [ -r "$CONFIG" ]; then
11 echo "failed to read config file $CONFIG."
12 exit 1
13fi
14source $CONFIG
15
16FAILED=""
17SUCCESS=""
18
19cd $DEST
20
21for url in $PROJECTS; do
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"
42done
43
44if [ "${REPORT_SCRIPT:-}" ]; then
45 $REPORT_SCRIPT mirror-urls "$SUCCESS" "$FAILED"
46fi
Note: See TracBrowser for help on using the repository browser.