version as used after the move to new hardware in september 2022
[osmrrze.git] / scripts / deleteseatiles.sh
CommitLineData
cc9b12f0
UO
1#!/bin/bash
2
3# Script to delete tiles that only contain water (usually in the
4# middle of an ocean) in the higher numbered zoomlevels. These
5# are trivial to regenerate (far less than one second) at any
6# time.
7
8# Some settings
9# Minimum Zoom in which we delete
f591210a 10MINZ=10
cc9b12f0
UO
11
12# Maximum Zoom in which we delete
13MAXZ=20
14
15# Age in days after which we delete
16AGE=3
17
f591210a 18declare -A TMD5
cc9b12f0 19# the md5sum of a metatile containing only water?
f591210a
UO
20TMD5[osmde]="c6501cefd852a2c5b16f297948ca309c"
21TMD5[osmorg]="9d7ceeb7ab3a0905abf200f1a7608f92"
22TMD5[osmhd]="d47bd18df80dbefb2f89b81a672cae92"
cc9b12f0 23
f591210a 24declare -A TSIZE
cc9b12f0 25# the size of a metatile containing only water?
f591210a
UO
26TSIZE[osmde]=7124
27TSIZE[osmorg]=7124
28TSIZE[osmhd]=8596
cc9b12f0 29
f591210a 30declare -A TDIR
cc9b12f0 31# Directory that contains the tiles? (with trailing slash!)
f591210a
UO
32TDIR[osmde]="/mnt/tiles/tiles/osmde/"
33TDIR[osmorg]="/mnt/tiles/tiles/osm/"
34TDIR[osmhd]="/mnt/tiles/tiles/osmhd/"
cc9b12f0
UO
35
36NDELETED=0
f591210a 37for style in "osmde" "osmorg" "osmhd"
cc9b12f0 38do
f591210a
UO
39 echo "Handling style: $style - looking for files with size ${TSIZE[$style]} and md5sum ${TMD5[$style]} in ${TDIR[$style]}"
40 for z in `seq $MINZ $MAXZ`
cc9b12f0 41 do
f591210a
UO
42 if [ ! -d "${TDIR[$style]}${z}" ] ; then
43 continue
cc9b12f0 44 fi
f591210a
UO
45 for tiles in `find ${TDIR[$style]}${z} -xdev -type f -name '*.meta' -size ${TSIZE[$style]}c -mtime +${AGE} -print`
46 do
47 # We need to skip the first 20 bytes of the file as they contain the metafile
48 # header that contains the x/y location of the tile.
49 TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'`
50 if [ "$TILEMD5" == "${TMD5[$style]}" ] ; then
51 echo "Deleting $tiles"
52 rm $tiles
53 if [ $? -ne 0 ] ; then
54 echo "There was an error deleting $tiles."
55 echo "Aborting after deleting $NDELETED files."
56 exit 1
57 fi
58 let "NDELETED=NDELETED+1"
59 #else
60 # echo "$tiles is not a water tile."
cc9b12f0 61 fi
f591210a 62 done
cc9b12f0
UO
63 done
64done
65
66echo "$NDELETED files deleted."
67
This page took 0.058253 seconds and 4 git commands to generate.