Rev | Line | |
---|
[1091] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[1210] | 3 | set -o errexit -o nounset
|
---|
[1091] | 4 |
|
---|
[1210] | 5 | CONFIG=${1:-/etc/mirror-obs.conf}
|
---|
[1091] | 6 |
|
---|
[1210] | 7 | if ! [ -r "$CONFIG" ]; then
|
---|
| 8 | echo "failed to read config file $CONFIG."
|
---|
| 9 | exit 1
|
---|
| 10 | fi
|
---|
| 11 | source $CONFIG
|
---|
[1091] | 12 |
|
---|
| 13 | RSYNC_DELETE="--delete"
|
---|
[1210] | 14 | RSYNC_OPTS="-v -rlLptx --safe-links --stats $RSYNC_EXTRA_OPTS"
|
---|
[1091] | 15 |
|
---|
| 16 | rsync_if_exists()
|
---|
| 17 | {
|
---|
[1210] | 18 | src=$1
|
---|
| 19 | dest=$2
|
---|
[1091] | 20 |
|
---|
[1210] | 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
|
---|
[1091] | 25 | }
|
---|
| 26 |
|
---|
| 27 | # ---------------- mirror openSUSE repositories ------------------------
|
---|
[1210] | 28 | FAILED=""
|
---|
| 29 | SUCCESS=""
|
---|
[1091] | 30 |
|
---|
[1210] | 31 |
|
---|
[1091] | 32 | cd $DEST
|
---|
| 33 |
|
---|
[1210] | 34 | for DIR in $REPOS; do
|
---|
[1091] | 35 | SOURCE_DIR=${SOURCE_OPENSUSE}/${DIR}/.
|
---|
| 36 | DEST_DIR=${DEST}/${DIR}/.
|
---|
| 37 | mkdir -p ${DEST_DIR}
|
---|
[1210] | 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 | ;;
|
---|
[1091] | 57 | esac
|
---|
[1210] | 58 | echo
|
---|
| 59 | echo
|
---|
[1091] | 60 | done
|
---|
| 61 |
|
---|
[1210] | 62 | if [ "${REPORT_SCRIPT:-}" ]; then
|
---|
[1217] | 63 | $REPORT_SCRIPT mirror-obs "$SUCCESS" "$FAILED"
|
---|
[1210] | 64 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.