diff options
-rwxr-xr-x | scripts/osm/osm.pbf.update | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/scripts/osm/osm.pbf.update b/scripts/osm/osm.pbf.update index 102d158..c7d0b2b 100755 --- a/scripts/osm/osm.pbf.update +++ b/scripts/osm/osm.pbf.update | |||
@@ -1,13 +1,13 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates | 3 | GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates |
4 | PBF_FILE=$1 | ||
4 | 5 | ||
5 | # get next sequence number and store it into NEW_SEQ | 6 | # get next sequence number and store it into NEW_SEQ |
6 | osmium fileinfo $PBF_FILE | \ | 7 | NEW_SEQ=$(osmium fileinfo $PBF_FILE |\ |
7 | grep osmosis_replication_sequence_number | \ | 8 | grep osmosis_replication_sequence_number |\ |
8 | cut -d'=' -f2 | \ | 9 | cut -d'=' -f2 |\ |
9 | sed 's/$/+1/' | bc | \ | 10 | sed 's/$/+1/' | bc) |
10 | read NEW_SEQ | ||
11 | 11 | ||
12 | # while server has osc file with given sequence number, | 12 | # while server has osc file with given sequence number, |
13 | # get it and do file update | 13 | # get it and do file update |
@@ -15,7 +15,7 @@ while | |||
15 | SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') | 15 | SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') |
16 | STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt | 16 | STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt |
17 | echo $STATE_URL | 17 | echo $STATE_URL |
18 | [ $(curl.code $STATE_URL) != "404" ] | 18 | [ $(curl -o /dev/null --silent -Iw "%{http_code}" $STATE_URL) != "404" ] |
19 | do | 19 | do |
20 | mkdir -p changes | 20 | mkdir -p changes |
21 | CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz | 21 | CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz |
@@ -26,7 +26,7 @@ do | |||
26 | --overwrite \ | 26 | --overwrite \ |
27 | --output $NEW_SEQ.osm.pbf | 27 | --output $NEW_SEQ.osm.pbf |
28 | 28 | ||
29 | mv $1 $((NEW_SEQ-1)).osm.pbf | 29 | mv $PBF_FILE $((NEW_SEQ-1)).osm.pbf |
30 | mv $NEW_SEQ.osm.pbf $1 | 30 | mv $NEW_SEQ.osm.pbf $PBF_FILE |
31 | ((NEW_SEQ++)) | 31 | (( NEW_SEQ++ )) |
32 | done | 32 | done |