diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-04-13 21:38:55 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-04-13 21:38:55 +0200 |
commit | f9025ac53340a341b731dfed6821bde40b950e03 (patch) | |
tree | bad88a0cdf3314a51730dfb8c86d58f13269ed9e /syncrepo | |
parent | d8192987285050173636239f4bbfa9725ad0d0b6 (diff) | |
download | bin-f9025ac53340a341b731dfed6821bde40b950e03.tar.gz bin-f9025ac53340a341b731dfed6821bde40b950e03.tar.xz |
add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'syncrepo')
-rwxr-xr-x | syncrepo | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/syncrepo b/syncrepo new file mode 100755 index 0000000..dd72a94 --- /dev/null +++ b/syncrepo @@ -0,0 +1,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))" |