diff options
Diffstat (limited to 'bin/sync-osm-planet.sh')
-rwxr-xr-x | bin/sync-osm-planet.sh | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/bin/sync-osm-planet.sh b/bin/sync-osm-planet.sh index 878ad5b..df9b538 100755 --- a/bin/sync-osm-planet.sh +++ b/bin/sync-osm-planet.sh @@ -22,43 +22,37 @@ TRACKER=( "udp://tracker.openbittorrent.com:80/announce" ) MKTORRENT_OPTS=( "-l 22" ) -lockfile=/tmp/`basename $0`.lock - -if lockfile -r 5 $lockfile -then - ${RSYNC} "${RSYNC_OPTS[@]}" ${SRC} ${DST} - - # create torrents - for file in ${DST}/*.bz2 - do - archiv="$(basename $file)" - if [ ! -L ${file} ] +${RSYNC} "${RSYNC_OPTS[@]}" ${SRC} ${DST} + +# create torrents +for file in ${DST}/*.bz2 +do + archiv="$(basename $file)" + if [ ! -L ${file} ] + then + torrent="${DST}/torrents/${archiv}.torrent" + torrent_tmp="/tmp/${archiv}.torrent" + + if [ ! -e "${torrent}" ] then - torrent="${DST}/torrents/${archiv}.torrent" - torrent_tmp="/tmp/${archiv}.torrent" - - if [ ! -e "${torrent}" ] - then - rm -f "${torrent_tmp}" - - TRACKER_OPT="" - for t in "${TRACKER[@]}" - do - TRACKER_OPT="${TRACKER_OPT} -a ${t}" - done - - ${MKTORRENT} ${TRACKER_OPT} "${MKTORRENT_OPTS[@]}" \ - -w "http://ftp.spline.inf.fu-berlin.de/pub/openstreetmap/${archiv}" \ - -w "http://planet.osm.org/${archiv}" \ - "${file}" -o "${torrent_tmp}" > /dev/null && \ - mv "${torrent_tmp}" "${torrent}" - fi - else - target="$(readlink ${file})" - ln -sf "$(basename ${target}).torrent" "${DST}/torrents/${archiv}.torrent" + rm -f "${torrent_tmp}" + + TRACKER_OPT="" + for t in "${TRACKER[@]}" + do + TRACKER_OPT="${TRACKER_OPT} -a ${t}" + done + + ${MKTORRENT} ${TRACKER_OPT} "${MKTORRENT_OPTS[@]}" \ + -w "http://ftp.spline.inf.fu-berlin.de/pub/openstreetmap/${archiv}" \ + -w "http://planet.osm.org/${archiv}" \ + "${file}" -o "${torrent_tmp}" > /dev/null && \ + mv "${torrent_tmp}" "${torrent}" fi - done + else + target="$(readlink ${file})" + ln -sf "$(basename ${target}).torrent" "${DST}/torrents/${archiv}.torrent" + fi +done - echo "End: $(date)" - rm -f $lockfile -fi +echo "End: $(date)" |