]> asedeno.scripts.mit.edu Git - sipb-mirrors.git/blob - fetch-scripts/fedora-buffet
fedora-buffet: exit early if bind mounts appear to be missing
[sipb-mirrors.git] / fetch-scripts / fedora-buffet
1 #!/bin/bash
2
3 set -e
4
5 # This script serves to sync the following modules from fedora-buffet:
6 # - fedora -> ${MIRRORDIR}/fedora
7 # - epel   -> ${MIRRORDIR}/epel
8
9 # To make quick-fedora-mirror happy, it does so through a bind mount,
10 # separate from the symlink farm at ${MIRRORDIR}.
11
12 # mirrors.mit.edu is on the IP ACL for fedora-buffet0 here
13 # so we'll use it. Adjust these values if switching upstreams.
14 #RSYNCSOURCE=rsync://download-i2.fedoraproject.org
15 RSYNCSOURCE=rsync://dl.fedoraproject.org
16 MASTERMODULE=fedora-buffet0
17 PREBITFLIP=1
18
19 TIMEFILE="${MIRRORDIR}/.locks/fedora-buffet.timefile"
20 QFM="./tools/fedora/quick-fedora-mirror"
21
22 if ! [ -x "${QFM}" ]; then
23     # It is expected that this script is sourced by fetch-hudson
24     # and that cwd is the workspace where the root of this repository
25     # is checked out.
26     echo "Could not find quick-fedora-mirror."
27     exit 1
28 fi
29
30 # Early ownership checks for bind-mounted target directories.
31 exit_early=
32 for dir in epel fedora; do
33     check_target="${MIRRORDIR}/fedora-buffet/${dir}"
34     if ! [ -O "${check_target}" ]; then
35         echo "${check_target} ownership is wrong; is the bind mount missing?"
36         exit_early=yes
37     fi
38 done
39 if [ -n "${exit_early}" ]; then
40     exit 1
41 fi
42
43 exittrap() { :; }
44 trap 'exittrap' EXIT
45
46 TMPDIR=$(mktemp -d /tmp/fedora-buffet.XXXXXX) || die "Unable to mktemp"
47 exittrap() { rm -rf "${TMPDIR}"; }
48
49 CONF="${TMPDIR}/qfm.conf"
50 cat >"${CONF}" <<EOF
51 # This will be sourced by qfm, which uses zsh.
52 # Where our mirrors live
53 DESTD=${MIRRORDIR}/fedora-buffet
54 # State regarding last sync, and also a lockfile for qfm
55 TIMEFILE=${TIMEFILE}
56 # Upstream mirror that contains MASTERMODULE
57 REMOTE=${RSYNCSOURCE}
58 MASTERMODULE=${MASTERMODULE}
59 PREBITFLIP=${PREBITFLIP}
60 # Which module to sync
61 MODULES=(fedora epel)
62 # Map from module to location in DESTD
63 MODULEMAPPING=(fedora fedora epel epel)
64 # Add --progress to rsync
65 VERBOSE=7
66 TMPDIR=${TMPDIR}
67 EOF
68
69 "${QFM}" --config "${CONF}" --alwayscheck
70
71 rm -rf "${TMPDIR}"
72 exittrap() { :; }