aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sync-distfiles.sh')
-rwxr-xr-xsync-distfiles.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/sync-distfiles.sh b/sync-distfiles.sh
new file mode 100755
index 0000000..1abaf2d
--- /dev/null
+++ b/sync-distfiles.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+DATADIR="/data/gmirror-distfiles"
+LOGDIR="${DATADIR}/log"
+RSYNC="/usr/bin/rsync"
+RSYNC_ARGS="--no-motd --recursive --times --links --ignore-errors --timeout=300 --quiet"
+RSYNC_ARGS_DELETE="--delete --delete-after"
+[[ -d ${LOGDIR} ]] || mkdir ${LOGDIR}
+
+# get the helper files
+${RSYNC} ${RSYNC_ARGS} ${RSYNC_ARGS_DELETE} \
+ woodpecker.gentoo.org::distfiles-local/ \
+ ${DATADIR}/distfiles-local
+# Do NOT delete old whitelist entries; they must explicitly be set to empty if
+# you want to remove them.
+${RSYNC} ${RSYNC_ARGS} \
+ woodpecker.gentoo.org::distfiles-whitelist/ \
+ ${DATADIR}/distfiles-whitelist
+# Copy distfiles-local files to distfiles dir so that emirrordist can process
+# them
+# Do NOT --delete, let emirrordist handle the deletion logic
+# TODO: we could make this a hardlink for speed?
+${RSYNC} ${RSYNC_ARGS} \
+ ${DATADIR}/distfiles{-local/*,}
+
+# build one master file due to bug 500030
+cat $(/usr/bin/find ${DATADIR}/distfiles-whitelist -type f ) > \
+ ${DATADIR}/tmp/whitelist-master.txt
+
+# Clear out the success/fail.log so that we can report on it
+# (emirrordist appends)
+> ${LOGDIR}/failure.log
+if [[ $(/bin/date '+%k') -eq 0 ]]; then
+ > ${LOGDIR}/success.log
+fi
+
+# human readable time format, 1814400 seconds equals 3 weeks
+DELAY=1814400
+/usr/bin/emirrordist \
+ --distfiles=${DATADIR}/distfiles/ \
+ --delete --jobs=10 --repo=gentoo \
+ --deletion-delay=${DELAY} \
+ --failure-log=${LOGDIR}/failure.log \
+ --success-log=${LOGDIR}/success.log \
+ --scheduled-deletion-log=${LOGDIR}/deletion.log \
+ --deletion-db=${LOGDIR}/deletion-db.bdb \
+ --distfiles-db=${LOGDIR}/distfile-db.bdb \
+ --temp-dir=${DATADIR}/tmp/ \
+ --whitelist-from=${DATADIR}/tmp/whitelist-master.txt \
+ --distfiles-local=${DATADIR}/distfiles-local \
+ --mirror
+
+/bin/date -u '+%s' > ${DATADIR}/distfiles/timestamp.mirmon