2 ulimit -m 4194304 -v 4194304
5 if [ -f /tmp/planet-notes-dump.lock ]; then
6 if [ "$(ps -p `cat /tmp/planet-notes-dump.lock` | wc -l)" -gt 1 ]; then
7 # process is still running
8 echo Error: Another planet-notes-dump is running
11 # process not running, but lock file not deleted?
12 rm /tmp/planet-notes-dump.lock
17 echo $$ > /tmp/planet-notes-dump.lock
20 cur_date=$(date +%y%m%d)
22 cur_planet_notes="planet-notes-${cur_date}.osn"
23 planet_dir=/store/planet/
25 export PATH='/usr/local/bin:/usr/bin:/bin:/usr/bin/X11'
28 if [ \! -d "${planet_dir}/notes/" ]
30 echo "${planet_dir}notes/ does not exist"
33 if [ \! -d "${planet_dir}/notes/${cur_year}/" ]; then mkdir "${planet_dir}/notes/${cur_year}/"; fi
34 cd "${planet_dir}/notes/${cur_year}/"
36 /usr/bin/python3 /opt/planet-notes-dump/dump.py --quiet --database openstreetmap --host <%= node[:web][:readonly_database_host] %> --user planetdump --password '<%= @password %>' ".${cur_planet_notes}"
37 pbzip2 -p6 -9 ".${cur_planet_notes}"
39 planet_notes_size=$(du -sb ".${cur_planet_notes}.bz2" | awk '{ print $1 }')
40 if ((planet_notes_size<12000000)); then
41 echo "Planet .${cur_planet_notes}.bz2 too small"
45 mv ".${cur_planet_notes}.bz2" "${cur_planet_notes}.bz2"
46 md5sum "${cur_planet_notes}.bz2" > "${cur_planet_notes}.bz2.md5"
48 #link planet latest to the new file
49 cd "${planet_dir}/notes/"
51 ln -fs "${cur_year}/${cur_planet_notes}.bz2" planet-notes-latest.osn.bz2
53 # mangle md5 files for 'latest' ones
54 rm -f planet-notes-latest.osn.bz2.md5
56 sed -e "s/${cur_planet_notes}.bz2/planet-notes-latest.osn.bz2/" "${cur_year}/${cur_planet_notes}.bz2.md5" > planet-notes-latest.osn.bz2.md5
58 /opt/awscli/v2/current/bin/aws --profile osm-pds-upload s3 cp --storage-class INTELLIGENT_TIERING "${cur_year}/${cur_planet_notes}.bz2.md5" "s3://osm-planet-eu-central-1/notes/osn/${cur_year}/${cur_planet_notes}.bz2.md5"
59 /opt/awscli/v2/current/bin/aws --profile osm-pds-upload s3 cp --storage-class INTELLIGENT_TIERING "${cur_year}/${cur_planet_notes}.bz2" "s3://osm-planet-eu-central-1/notes/osn/${cur_year}/${cur_planet_notes}.bz2"
61 rm /tmp/planet-notes-dump.lock