diff options
author | typebrook <typebrook@gmail.com> | 2020-02-27 16:32:37 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-02-27 16:32:37 +0800 |
commit | 00b136155183ae522ca458e540a8cf29bf525e74 (patch) | |
tree | c6e9d20d5021c95afc7149456d57eb435d808150 /tools/osm/sequence_number.sh | |
parent | 3fa79eb14a4c0244fb2dc4a5b805b7cffaa63770 (diff) |
update
Diffstat (limited to 'tools/osm/sequence_number.sh')
-rwxr-xr-x | tools/osm/sequence_number.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/osm/sequence_number.sh b/tools/osm/sequence_number.sh new file mode 100755 index 0000000..eb365d0 --- /dev/null +++ b/tools/osm/sequence_number.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # $1 as --hour or --minute, $2 as timestamp | ||
4 | # return the latest sequence number | ||
5 | |||
6 | case $1 in | ||
7 | # hour difference with Tue Jun 4 03:00:00 UTC 2019 | ||
8 | # sequence number=58940 | ||
9 | --hour) | ||
10 | echo $[($2 - 1559617200)/3600 + 58940] | ||
11 | ;; | ||
12 | |||
13 | # minute difference with latest planet state file | ||
14 | --minute) | ||
15 | benchmark=benchmark | ||
16 | curl https://planet.openstreetmap.org/replication/minute/state > $benchmark | ||
17 | timeString=$(tail -1 $benchmark | tr -d 'timestamp=\\') | ||
18 | timestamp=$(date -d "$timeString" +%s) | ||
19 | seq=$(sed -n 2p $benchmark | tr -d "sequenceNumber=") | ||
20 | rm $benchmark | ||
21 | echo $[$seq - ($timestamp - $2)/60 - 1 ] | ||
22 | esac | ||