summaryrefslogtreecommitdiff
path: root/mirror-portage.sh
blob: 57a6190f8c37ed9071b3d02ac20add336382d4c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
# sync-portage.sh – wrapper for Gentoo Portage rsync mirror
#

RSYNC_OPTS="-avH --partial --delete --delete-delay \
  --safe-links --hard-links --numeric-ids \
  --timeout=300 --contimeout=60 --info=progress2"

TARGET="/brimstone1a/mirror/gentoo/portage"
SOURCE="rsync://masterportage.gentoo.org"

LOGFILE="/var/log/portage-sync.log"
STATUSFILE="/var/www/mirror-status/portage.lastsync"

# Run rsync and log output
rsync $RSYNC_OPTS "$SOURCE" "$TARGET" >> "$LOGFILE" 2>&1
RC=$?

# If rsync succeeded, update freshness marker
if [ $RC -eq 0 ]; then
    date -u +%s > "$STATUSFILE"
    echo "$(date -u) : sync OK" >> "$LOGFILE"
else
    echo "$(date -u) : sync FAILED with code $RC" >> "$LOGFILE"
fi

exit $RC