@@ -6,8 +6,7 @@ UPDATE_DIR=$DATA_DIR/update
6
6
DOWNLOAD_DIR=$DATA_DIR /download
7
7
8
8
set_taginfo_config () {
9
- echo " Setting up $WORKDIR /taginfo-config.json file ..."
10
-
9
+ echo " Setting up...$WORKDIR /taginfo-config.json"
11
10
# Update dir values in taginfo-config.json
12
11
grep -v ' ^ *//' $WORKDIR /taginfo/taginfo-config-example.json |
13
12
jq ' .logging.directory = "' $UPDATE_DIR ' /log"' |
@@ -27,7 +26,7 @@ set_taginfo_config() {
27
26
[[ ! -z $INSTANCE_CONTACT +z} ]] && jq --arg a " ${INSTANCE_CONTACT} " ' .instance.contact = $a' $WORKDIR /taginfo-config.json > tmp.json && mv tmp.json $WORKDIR /taginfo-config.json
28
27
29
28
# languages wiki databases will be downloaded from OSM
30
- jq --arg a " languages wiki " ' .sources.download = $a' $WORKDIR /taginfo-config.json > tmp.json && mv tmp.json $WORKDIR /taginfo-config.json
29
+ [[ ! -z $DOWNLOAD_DB +z} ]] && jq --arg a " ${DOWNLOAD_DB} " ' .sources.download = $a' $WORKDIR /taginfo-config.json > tmp.json && mv tmp.json $WORKDIR /taginfo-config.json
31
30
}
32
31
33
32
updates_create_db () {
@@ -36,12 +35,10 @@ updates_create_db() {
36
35
}
37
36
38
37
updates_source_code () {
39
- echo " Updating source code, in order to make the code running..."
40
-
38
+ echo " Update...Procesor source code"
41
39
# Function to replace the projects repo to get the projects information
42
40
TAGINFO_PROJECT_REPO=${TAGINFO_PROJECT_REPO// \/ / \\ / }
43
41
sed -i -e ' s/https:\/\/github.com\/taginfo\/taginfo-projects.git/' $TAGINFO_PROJECT_REPO ' /g' $WORKDIR /taginfo/sources/projects/update.sh
44
-
45
42
# The follow line is requiered to avoid sqlite3 issues
46
43
sed -i -e ' s/run_ruby "$SRCDIR\/update_characters.rb"/ruby "$SRCDIR\/update_characters.rb"/g' $WORKDIR /taginfo/sources/db/update.sh
47
44
sed -i -e ' s/run_ruby "$SRCDIR\/import.rb"/ruby "$SRCDIR\/import.rb"/g' $WORKDIR /taginfo/sources/projects/update.sh
@@ -51,48 +48,48 @@ updates_source_code() {
51
48
52
49
download_planet_files () {
53
50
mkdir -p $UPDATE_DIR /planet/
54
-
55
51
# Check if URL_PLANET_FILE_STATE exist and set URL_PLANET_FILE
56
52
if [[ ${URL_PLANET_FILE_STATE} && ${URL_PLANET_FILE_STATE-x} ]]; then
57
- URL_PLANET_FILE=$( curl -D -X GET $URL_PLANET_FILE_STATE )
53
+ wget -q -O state.planet.txt --no-check-certificate - $URL_PLANET_FILE_STATE
54
+ URL_PLANET_FILE=$( cat state.planet.txt)
58
55
fi
59
-
60
56
# Check if URL_HISTORY_PLANET_FILE_STATE exist and set URL_HISTORY_PLANET_FILE
61
57
if [[ ${URL_HISTORY_PLANET_FILE_STATE} && ${URL_HISTORY_PLANET_FILE_STATE-x} ]]; then
62
- URL_HISTORY_PLANET_FILE=$( curl -D -X GET $URL_HISTORY_PLANET_FILE_STATE )
58
+ wget -q -O state.history.txt --no-check-certificate - $URL_HISTORY_PLANET_FILE_STATE
59
+ URL_HISTORY_PLANET_FILE=$( cat state.history.txt)
63
60
fi
64
61
# Download pbf files
65
- wget --no-check-certificate -O $UPDATE_DIR /planet/planet.osm.pbf $URL_PLANET_FILE
66
- wget --no-check-certificate -O $UPDATE_DIR /planet/history-planet.osh.pbf $URL_HISTORY_PLANET_FILE
67
-
62
+ echo " Downloading...$URL_PLANET_FILE "
63
+ wget -q -O $UPDATE_DIR /planet/planet.osm.pbf --no-check-certificate - $URL_PLANET_FILE
64
+ echo " Downloading...$URL_HISTORY_PLANET_FILE "
65
+ wget -q -O $UPDATE_DIR /planet/history-planet.osh.pbf --no-check-certificate - $URL_HISTORY_PLANET_FILE
66
+ rm state.planet.txt
67
+ rm state.history.txt
68
68
}
69
69
70
70
update () {
71
- echo " Update Sqlite DBs at $( date +%Y-%m-%d:%H-%M) ..."
72
-
73
- # Download OSM planet replication and full-history files,
71
+ echo " Update...sqlite databases at $( date +%Y-%m-%d:%H-%M) "
72
+ # Download OSM planet replication and full-history files
74
73
download_planet_files
75
-
76
74
# In order to make it work we need to pass first one by one the creation and then all of them "db projects chronology"
77
- for value in $CREATE_DB ; do
78
- updates_create_db $value
75
+ for db in $CREATE_DB ; do
76
+ echo " Update...taginfo-$db .db"
77
+ updates_create_db $db
79
78
$WORKDIR /taginfo/sources/update_all.sh $UPDATE_DIR
80
79
done
81
-
80
+ echo " Update... $CREATE_DB "
82
81
updates_create_db $CREATE_DB
83
82
$WORKDIR /taginfo/sources/update_all.sh $UPDATE_DIR
84
-
85
83
# Copy db files into data folder
86
84
cp $UPDATE_DIR /* /taginfo-* .db $DATA_DIR /
87
85
cp $UPDATE_DIR /taginfo-* .db $DATA_DIR /
88
-
89
86
# Link to download db zip files
90
87
chmod a=r $UPDATE_DIR /download
91
88
ln -sf $UPDATE_DIR /download $WORKDIR /taginfo/web/public/download
92
89
}
93
90
94
91
start_web () {
95
- echo " Start taginfo ..."
92
+ echo " Start...Taginfo web service "
96
93
cd $WORKDIR /taginfo/web && bundle exec rackup --host 0.0.0.0 -p 4567
97
94
}
98
95
@@ -106,7 +103,6 @@ continuous_update() {
106
103
main () {
107
104
set_taginfo_config
108
105
updates_source_code
109
-
110
106
# Check if db files are store in the $DATA_DIR in order to start the service or start procesing the file
111
107
NUM_DB_FILES=$( ls $DATA_DIR /* .db | wc -l)
112
108
if [ $NUM_DB_FILES -lt 7 ]; then
@@ -115,5 +111,4 @@ main() {
115
111
start_web &
116
112
continuous_update
117
113
}
118
-
119
114
main
0 commit comments