diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-08-02 20:31:00 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-08-02 20:31:00 +0200 |
commit | 280294bb1690a98349f17a2798aee0ef06abbcce (patch) | |
tree | 594bab2e7aae79b522bd061e7579e5bd53a1d7b3 /syncrepo.sh | |
parent | 465769cd00069d8c0b0af73bc8072012f242d5a9 (diff) | |
download | bin-280294bb1690a98349f17a2798aee0ef06abbcce.tar.gz bin-280294bb1690a98349f17a2798aee0ef06abbcce.tar.xz |
rename syncrepo to fix name clashes with installed one
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'syncrepo.sh')
-rwxr-xr-x | syncrepo.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/syncrepo.sh b/syncrepo.sh new file mode 100755 index 0000000..25f8223 --- /dev/null +++ b/syncrepo.sh @@ -0,0 +1,38 @@ +#!/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 we are called without a tty (cronjob) only run when there are changes +if ! tty -s && 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))" |