This repository has been archived by the owner on Sep 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·162 lines (147 loc) · 4.86 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
#===============================================================================
#
# FILE: setup.sh
#
# USAGE: ./scripts/setup.sh
# DESCRIPTION: ---
#
# OPTIONS: ---
#
# REQUIREMENTS: - curl
# - bzip2
# BUGS: ---
# NOTES: ---
# AUTHOR: Emerson Rocha <rocha[at]ieee.org>
# COMPANY: EticaAI
# LICENSE: Public Domain dedication
# SPDX-License-Identifier: Unlicense
# VERSION: v1.0
# CREATED: 2022-11-15 10:10 UTC
# REVISION: ---
#===============================================================================
set -e
ROOTDIR="$(pwd)"
CACHEDIR="${CACHEDIR:-"$ROOTDIR/data/cache"}"
#### Fancy colors constants - - - - - - - - - - - - - - - - - - - - - - - - - -
tty_blue=$(tput setaf 4)
tty_green=$(tput setaf 2)
# tty_red=$(tput setaf 1)
tty_normal=$(tput sgr0)
## Example
# printf "\n\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED ${tty_normal}"
# printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
# printf "\t%40s\n" "${tty_blue} INFO: [] ${tty_normal}"
# printf "\t%40s\n" "${tty_red} ERROR: [] ${tty_normal}"
#### Fancy colors constants - - - - - - - - - - - - - - - - - - - - - - - - - -
#### functions _________________________________________________________________
#######################################
# Download Taginfo (...)
# @see https://taginfo.openstreetmap.org/download
#
# Globals:
# CACHEDIR
# Arguments:
#
# Outputs:
#
#######################################
data_download_taginfo_dump_db() {
url_remote="https://taginfo.openstreetmap.org/download/taginfo-db.db.bz2"
local_file="${CACHEDIR}/taginfo-db.db.bz2"
local_db="${CACHEDIR}/taginfo-db.sqlite"
printf "\n\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED ${tty_normal}"
if [ ! -f "$local_file" ]; then
set -x
curl --output "${local_file}" "${url_remote}"
bzip2 --decompress "${local_file}" --stdout >"${local_db}"
set +x
else
printf "\t%40s\n" "${tty_blue} INFO: [cached] ${tty_normal}"
fi
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}
#######################################
# Download Taginfo (...)
#
# Globals:
# CACHEDIR
# Arguments:
#
# Outputs:
#
#######################################
data_download_taginfo_dump_master() {
url_remote="https://taginfo.openstreetmap.org/download/taginfo-master.db.bz2"
local_file="${CACHEDIR}/taginfo-master.db.bz2"
local_db="${CACHEDIR}/taginfo-master.sqlite"
printf "\n\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED ${tty_normal}"
if [ ! -f "$local_file" ]; then
set -x
curl --output "${local_file}" "${url_remote}"
bzip2 --decompress "${local_file}" --stdout >"${local_db}"
set +x
else
printf "\t%40s\n" "${tty_blue} INFO: [cached] ${tty_normal}"
fi
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}
#######################################
# Download Taginfo (...)
# @see https://taginfo.openstreetmap.org/download
#
# Globals:
# CACHEDIR
# Arguments:
#
# Outputs:
#
#######################################
data_download_taginfo_dump_projects() {
url_remote="https://taginfo.openstreetmap.org/download/taginfo-projects.db.bz2"
local_file="${CACHEDIR}/taginfo-projects.db.bz2"
local_db="${CACHEDIR}/taginfo-projects.sqlite"
printf "\n\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED ${tty_normal}"
if [ ! -f "$local_file" ]; then
set -x
curl --output "${local_file}" "${url_remote}"
bzip2 --decompress "${local_file}" --stdout >"${local_db}"
set +x
else
printf "\t%40s\n" "${tty_blue} INFO: [cached] ${tty_normal}"
fi
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}
#######################################
# Download Taginfo (...)
# @see https://taginfo.openstreetmap.org/download
#
# Globals:
# CACHEDIR
# Arguments:
#
# Outputs:
#
#######################################
data_download_taginfo_dump_wiki() {
url_remote="https://taginfo.openstreetmap.org/download/taginfo-wiki.db.bz2"
local_file="${CACHEDIR}/taginfo-wiki.db.bz2"
local_db="${CACHEDIR}/taginfo-wiki.sqlite"
printf "\n\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED ${tty_normal}"
if [ ! -f "$local_file" ]; then
set -x
curl --output "${local_file}" "${url_remote}"
bzip2 --decompress "${local_file}" --stdout >"${local_db}"
set +x
else
printf "\t%40s\n" "${tty_blue} INFO: [cached] ${tty_normal}"
fi
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}
#### main ______________________________________________________________________
# @TODO maybe use this https://stackoverflow.com/questions/2676041/is-it-possible-to-import-gzip-file-into-sqlite-could-i-skip-some-column-while
data_download_taginfo_dump_master
## data_download_taginfo_dump_db required >27 GB disk space
# data_download_taginfo_dump_db
data_download_taginfo_dump_projects
data_download_taginfo_dump_wiki