From 751b9255cf86afeee77e4cbb77a538399ef5d35a Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 20 Nov 2019 11:41:16 +0800 Subject: update --- scripts/osm/osm.pbf.update | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'scripts/osm') 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 @@ -#!/bin/sh +#!/bin/bash GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates +PBF_FILE=$1 # get next sequence number and store it into NEW_SEQ -osmium fileinfo $PBF_FILE | \ -grep osmosis_replication_sequence_number | \ -cut -d'=' -f2 | \ -sed 's/$/+1/' | bc | \ -read NEW_SEQ +NEW_SEQ=$(osmium fileinfo $PBF_FILE |\ +grep osmosis_replication_sequence_number |\ +cut -d'=' -f2 |\ +sed 's/$/+1/' | bc) # while server has osc file with given sequence number, # get it and do file update @@ -15,7 +15,7 @@ while SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt echo $STATE_URL - [ $(curl.code $STATE_URL) != "404" ] + [ $(curl -o /dev/null --silent -Iw "%{http_code}" $STATE_URL) != "404" ] do mkdir -p changes CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz @@ -26,7 +26,7 @@ do --overwrite \ --output $NEW_SEQ.osm.pbf - mv $1 $((NEW_SEQ-1)).osm.pbf - mv $NEW_SEQ.osm.pbf $1 - ((NEW_SEQ++)) + mv $PBF_FILE $((NEW_SEQ-1)).osm.pbf + mv $NEW_SEQ.osm.pbf $PBF_FILE + (( NEW_SEQ++ )) done -- cgit v1.2.3-70-g09d2