Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | set -o errexit -o nounset
|
---|
4 |
|
---|
5 | CONFIG=${1:-/etc/mirror-obs.conf}
|
---|
6 |
|
---|
7 | if ! [ -r "$CONFIG" ]; then
|
---|
8 | echo "failed to read config file $CONFIG."
|
---|
9 | exit 1
|
---|
10 | fi
|
---|
11 | source $CONFIG
|
---|
12 |
|
---|
13 | RSYNC_DELETE="--delete"
|
---|
14 | RSYNC_OPTS="-v -rlLptx --safe-links --stats $RSYNC_EXTRA_OPTS"
|
---|
15 |
|
---|
16 | rsync_if_exists()
|
---|
17 | {
|
---|
18 | src=$1
|
---|
19 | dest=$2
|
---|
20 |
|
---|
21 | rsync -q $src || return 1
|
---|
22 | echo "found rsync source: $src"
|
---|
23 | [ -d "$dest" ] || return 2
|
---|
24 | rsync $RSYNC_OPTS $RSYNC_DELETE $src $dest
|
---|
25 | }
|
---|
26 |
|
---|
27 | # ---------------- mirror openSUSE repositories ------------------------
|
---|
28 | FAILED=""
|
---|
29 | SUCCESS=""
|
---|
30 |
|
---|
31 |
|
---|
32 | cd $DEST
|
---|
33 |
|
---|
34 | for DIR in $REPOS; do
|
---|
35 | SOURCE_DIR=${SOURCE_OPENSUSE}/${DIR}/.
|
---|
36 | DEST_DIR=${DEST}/${DIR}/.
|
---|
37 | mkdir -p ${DEST_DIR}
|
---|
38 | rc=0
|
---|
39 | rsync_if_exists "${SOURCE_DIR}" "${DEST_DIR}" || rc=$?
|
---|
40 | case $rc in
|
---|
41 | 1) echo Distribution $DIR nicht gefunden
|
---|
42 | FAILED="$FAILED $DIR"
|
---|
43 | ;;
|
---|
44 | 2) echo Zielverzeichnis ${DEST_DIR} nicht vorhanden
|
---|
45 | FAILED="$FAILED $DIR"
|
---|
46 | ;;
|
---|
47 | 0)
|
---|
48 | SUCCESS="$SUCCESS $DIR"
|
---|
49 | if [ "${POST_SCRIPT:-}" ]; then
|
---|
50 | $POST_SCRIPT ${DEST_DIR}
|
---|
51 | fi
|
---|
52 | ;;
|
---|
53 | *)
|
---|
54 | echo Fehler $?
|
---|
55 | FAILED="$FAILED $DIR"
|
---|
56 | ;;
|
---|
57 | esac
|
---|
58 | echo
|
---|
59 | echo
|
---|
60 | done
|
---|
61 |
|
---|
62 | if [ "${REPORT_SCRIPT:-}" ]; then
|
---|
63 | $REPORT_SCRIPT mirror-obs "$SUCCESS" "$FAILED"
|
---|
64 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.