summaryrefslogtreecommitdiffstats
path: root/bin/sync-osm-planet.sh
diff options
context:
space:
mode:
authorsyncer <root@plopp.spline.de>2012-01-11 18:17:09 +0100
committersyncer <root@plopp.spline.de>2012-01-11 18:18:29 +0100
commit657d1fc484fa0b21b979525a92ace5c9e6f63da2 (patch)
treef395b3a6f1993f4b5c4b46b8bebf04f730987739 /bin/sync-osm-planet.sh
downloadmirror-sync-657d1fc484fa0b21b979525a92ace5c9e6f63da2.tar.gz
mirror-sync-657d1fc484fa0b21b979525a92ace5c9e6f63da2.tar.bz2
mirror-sync-657d1fc484fa0b21b979525a92ace5c9e6f63da2.zip
inital import
Diffstat (limited to 'bin/sync-osm-planet.sh')
-rwxr-xr-xbin/sync-osm-planet.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/bin/sync-osm-planet.sh b/bin/sync-osm-planet.sh
new file mode 100755
index 0000000..878ad5b
--- /dev/null
+++ b/bin/sync-osm-planet.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+RSYNC="/usr/bin/rsync"
+SRC="rsync://planet.openstreetmap.org/planet/"
+DST="/mirror/ftp/pub/openstreetmap/"
+RSYNC_OPTS=(
+ "-Hax"
+ "--delete"
+ "--delete-excluded"
+ "--include=*-$(date +%y%m)*"
+ "--include=*-$(date -d '-1month' +%y%m)*"
+ "--include=*-$(date -d '-2month' +%y%m)*"
+ "--include=*-$(date -d '-3month' +%y%m)*"
+ "--include=*-latest*"
+ "--exclude=*"
+ "--filter=protect torrents/" )
+
+MKTORRENT="/usr/bin/mktorrent"
+TRACKER=(
+ "http://tracker.ipv6tracker.org:80/announce,udp://tracker.ipv6tracker.org:80/announce"
+ "udp://tracker.publicbt.com:80/announce,http://tracker.publicbt.com:80/announce"
+ "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} ]
+ 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"
+ fi
+ done
+
+ echo "End: $(date)"
+ rm -f $lockfile
+fi