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