Skip to content

Commit 48ac2b9

Browse files
author
Rub21
committed
Update start.sh file for taginfo
1 parent a9b37b6 commit 48ac2b9

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

images/taginfo/start.sh

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ UPDATE_DIR=$DATA_DIR/update
66
DOWNLOAD_DIR=$DATA_DIR/download
77

88
set_taginfo_config() {
9-
echo "Setting up $WORKDIR/taginfo-config.json file ..."
10-
9+
echo "Setting up...$WORKDIR/taginfo-config.json"
1110
# Update dir values in taginfo-config.json
1211
grep -v '^ *//' $WORKDIR/taginfo/taginfo-config-example.json |
1312
jq '.logging.directory = "'$UPDATE_DIR'/log"' |
@@ -27,7 +26,7 @@ set_taginfo_config() {
2726
[[ ! -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
2827

2928
# 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
3130
}
3231

3332
updates_create_db() {
@@ -36,12 +35,10 @@ updates_create_db() {
3635
}
3736

3837
updates_source_code() {
39-
echo "Updating source code, in order to make the code running..."
40-
38+
echo "Update...Procesor source code"
4139
# Function to replace the projects repo to get the projects information
4240
TAGINFO_PROJECT_REPO=${TAGINFO_PROJECT_REPO//\//\\/}
4341
sed -i -e 's/https:\/\/github.com\/taginfo\/taginfo-projects.git/'$TAGINFO_PROJECT_REPO'/g' $WORKDIR/taginfo/sources/projects/update.sh
44-
4542
# The follow line is requiered to avoid sqlite3 issues
4643
sed -i -e 's/run_ruby "$SRCDIR\/update_characters.rb"/ruby "$SRCDIR\/update_characters.rb"/g' $WORKDIR/taginfo/sources/db/update.sh
4744
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() {
5148

5249
download_planet_files() {
5350
mkdir -p $UPDATE_DIR/planet/
54-
5551
# Check if URL_PLANET_FILE_STATE exist and set URL_PLANET_FILE
5652
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)
5855
fi
59-
6056
# Check if URL_HISTORY_PLANET_FILE_STATE exist and set URL_HISTORY_PLANET_FILE
6157
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)
6360
fi
6461
# 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
6868
}
6969

7070
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
7473
download_planet_files
75-
7674
# 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
7978
$WORKDIR/taginfo/sources/update_all.sh $UPDATE_DIR
8079
done
81-
80+
echo "Update...$CREATE_DB"
8281
updates_create_db $CREATE_DB
8382
$WORKDIR/taginfo/sources/update_all.sh $UPDATE_DIR
84-
8583
# Copy db files into data folder
8684
cp $UPDATE_DIR/*/taginfo-*.db $DATA_DIR/
8785
cp $UPDATE_DIR/taginfo-*.db $DATA_DIR/
88-
8986
# Link to download db zip files
9087
chmod a=r $UPDATE_DIR/download
9188
ln -sf $UPDATE_DIR/download $WORKDIR/taginfo/web/public/download
9289
}
9390

9491
start_web() {
95-
echo "Start taginfo..."
92+
echo "Start...Taginfo web service"
9693
cd $WORKDIR/taginfo/web && bundle exec rackup --host 0.0.0.0 -p 4567
9794
}
9895

@@ -106,7 +103,6 @@ continuous_update() {
106103
main() {
107104
set_taginfo_config
108105
updates_source_code
109-
110106
# Check if db files are store in the $DATA_DIR in order to start the service or start procesing the file
111107
NUM_DB_FILES=$(ls $DATA_DIR/*.db | wc -l)
112108
if [ $NUM_DB_FILES -lt 7 ]; then
@@ -115,5 +111,4 @@ main() {
115111
start_web &
116112
continuous_update
117113
}
118-
119114
main

0 commit comments

Comments
 (0)