blob: dd72a948eeeea81ba6d39c25fd3042e67772d7f6 (
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
29
30
31
32
33
34
35
36
37
|
#!/bin/bash
home="/srv"
target="${home}/repo"
tmp="${home}/tmp"
lock='/tmp/mirrorsync.lck'
bwlimit=4096
#source='rsync://rsync.archlinux.org/ftp_tier1'
#lastupdate_url="http://rsync.archlinux.org/lastupdate"
source='mirror.pkgbuild.com::packages/'
lastupdate_url="http://mirror.pkgbuild.com/lastupdate"
[ ! -d "${target}" ] && mkdir -p "${target}"
[ ! -d "${tmp}" ] && mkdir -p "${tmp}"
exec 9>"${lock}"
flock -n 9 || exit
if diff -b <(curl -s "$lastupdate_url") "$target/lastupdate" >/dev/null; then
exit 0
fi
if ! stty &>/dev/null; then
QUIET="-q"
fi
rsync -rtlvH --safe-links --delete-after --progress -h ${QUIET} --timeout=600 --contimeout=60 -p \
--delay-updates --no-motd --bwlimit=$bwlimit \
--temp-dir="${tmp}" \
--exclude='*.links.tar.gz*' \
--exclude='/other' \
--exclude='/sources' \
--exclude='/iso' \
${source} \
"${target}"
#echo "Last sync was $(date -d @$(cat ${target}/lastsync))"
|