Skip to content

Commit e58293f

Browse files
committed
Add ulr path to download files
Update taginfo scrpit Fix scrpit Fix config for taginfo serviceAccount
1 parent e3ff53e commit e58293f

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

envs/.env.taginfo.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ INSTANCE_ICON=https://www.openhistoricalmap.org/assets/ohm_logo-2d97749faddd5bd0
1212
INSTANCE_CONTACT= "Anonymous"
1313
TAGINFO_PROJECT_REPO=https://github.com/OpenHistoricalMap/taginfo-projects.git
1414
DOWNLOAD_DB='languages wiki'
15-
CREATE_DB='db projects chronology'
15+
CREATE_DB='db projects chronology'
16+
TAGINFO_DB_BASE_URL=https://planet.openhistoricalmap.org.s3.amazonaws.com/taginfo

images/taginfo/start.sh

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ process_data() {
4646
# wikidata/update.sh $DATADIR
4747
chronology/update.sh $DATADIR
4848
./update_all.sh $DATADIR
49-
mv $DATADIR/*.db $DATADIR/
50-
mv $DATADIR/*/*.db $DATADIR/
51-
# if AWS_S3_BUCKET is set upload data
52-
if ! aws s3 ls "s3://$AWS_S3_BUCKET/taginfo/$ENVIRONMENT" 2>&1 | grep -q 'An error occurred'; then
53-
aws s3 sync $DATADIR/ s3://$AWS_S3_BUCKET/taginfo/$ENVIRONMENT/ --exclude "*" --include "*.db"
54-
fi
49+
# Move database files from subdirectories to main data directory
50+
aws s3 sync $DATADIR/ s3://$AWS_S3_BUCKET/taginfo/$ENVIRONMENT/ --exclude "*" --include "*.db"
5551
}
5652

5753
# Compress files to download
@@ -63,24 +59,60 @@ compress_files() {
6359
}
6460

6561
download_db_files() {
66-
if ! aws s3 ls "s3://$AWS_S3_BUCKET/$ENVIRONMENT" 2>&1 | grep -q 'An error occurred'; then
67-
aws s3 sync "s3://$AWS_S3_BUCKET/$ENVIRONMENT/" "$DATADIR/"
68-
mv $DATADIR/*.db $DATADIR/
69-
mv $DATADIR/*/*.db $DATADIR/
70-
compress_files
62+
local base_url=$1
63+
64+
if [ -z "$base_url" ]; then
65+
echo "Error: URL base is required for download_db_files"
66+
return 1
67+
fi
68+
69+
# Ensure base_url ends with /
70+
if [[ ! "$base_url" =~ /$ ]]; then
71+
base_url="${base_url}/"
7172
fi
73+
74+
# List of SQLite database files to download
75+
local db_files=(
76+
"projects-cache.db"
77+
"selection.db"
78+
"taginfo-chronology.db"
79+
"taginfo-db.db"
80+
"taginfo-history.db"
81+
"taginfo-languages.db"
82+
"taginfo-master.db"
83+
"taginfo-projects.db"
84+
"taginfo-wiki.db"
85+
"taginfo-wikidata.db"
86+
)
87+
88+
echo "Downloading SQLite database files from: $base_url"
89+
90+
for db_file in "${db_files[@]}"; do
91+
local file_url="${base_url}${db_file}"
92+
local output_path="${DATADIR}/${db_file}"
93+
94+
echo "Downloading: $db_file"
95+
if wget -q --show-progress -O "$output_path" --no-check-certificate "$file_url"; then
96+
echo "Successfully downloaded: $db_file"
97+
else
98+
echo "Warning: Failed to download $db_file from $file_url"
99+
# Continue with other files even if one fails
100+
fi
101+
done
102+
103+
echo "Database files download completed"
72104
}
73105

74106
sync_latest_db_version() {
75107
while true; do
76108
sleep "$INTERVAL_DOWNLOAD_DATA"
77-
download_db_files
109+
download_db_files "$TAGINFO_DB_BASE_URL"
78110
done
79111
}
80112

81113
start_web() {
82114
echo "Start...Taginfo web service"
83-
download_db_files
115+
download_db_files "$TAGINFO_DB_BASE_URL"
84116
cd $WORKDIR/taginfo/web && ./taginfo.rb & sync_latest_db_version
85117
}
86118

osm-seed/templates/taginfo/taginfo-configMap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ data:
1515
TIME_UPDATE_INTERVAL: {{ .Values.taginfo.env.TIME_UPDATE_INTERVAL | quote }}
1616
AWS_S3_BUCKET: {{ .Values.taginfo.env.AWS_S3_BUCKET | quote }}
1717
ENVIRONMENT: {{ .Values.taginfo.env.ENVIRONMENT | quote }}
18-
INTERVAL_DOWNLOAD_DATA: {{ .Values.taginfo.env.INTERVAL_DOWNLOAD_DATA | quote}}
18+
INTERVAL_DOWNLOAD_DATA: {{ .Values.taginfo.env.INTERVAL_DOWNLOAD_DATA | quote }}
19+
TAGINFO_DB_BASE_URL: {{ .Values.taginfo.env.TAGINFO_DB_BASE_URL | quote }}
1920
{{- end }}

osm-seed/templates/taginfo/taginfo-cronJob.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ spec:
1919
spec:
2020
template:
2121
spec:
22+
{{- if .Values.taginfo.serviceAccount.enabled }}
2223
serviceAccountName: {{ .Values.taginfo.serviceAccount.name }}
24+
automountServiceAccountToken: true
25+
{{- end }}
2326
containers:
2427
- name: {{ .Release.Name }}-taginfo-job
2528
image: "{{ .Values.taginfo.image.name }}:{{ .Values.taginfo.image.tag }}"

osm-seed/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ taginfo:
10301030
ENVIRONMENT: development
10311031
AWS_S3_BUCKET: taginfo
10321032
INTERVAL_DOWNLOAD_DATA: 3600
1033+
TAGINFO_DB_BASE_URL: https://planet.openhistoricalmap.org.s3.amazonaws.com/taginfo
10331034
resources:
10341035
enabled: false
10351036
requests:

0 commit comments

Comments
 (0)