forked from earthquakesan/docker-ckan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathckan-entrypoint.sh
72 lines (60 loc) · 2.68 KB
/
ckan-entrypoint.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
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
CONFIG="${CKAN_CONFIG}/production.ini"
abort () {
echo "$@" >&2
exit 1
}
set_environment () {
#export CKAN_SITE_ID=${CKAN_SITE_ID}
export CKAN_SITE_TITLE=${CKAN_SITE_TITLE}
export CKAN_SITE_DESCRIPTION=${CKAN_SITE_DESCRIPTION}
export CKAN_SITE_URL=${CKAN_SITE_URL}
export CKAN_SQLALCHEMY_URL=${CKAN_SQLALCHEMY_URL}
export CKAN_SOLR_URL=${CKAN_SOLR_URL}
export CKAN_REDIS_URL=${CKAN_REDIS_URL}
export CKAN_STORAGE_PATH=/var/lib/ckan
#export CKAN_DATAPUSHER_URL=${CKAN_DATAPUSHER_URL}
#export CKAN_DATASTORE_WRITE_URL=${CKAN_DATASTORE_WRITE_URL}
#export CKAN_DATASTORE_READ_URL=${CKAN_DATASTORE_READ_URL}
#export CKAN_SMTP_SERVER=${CKAN_SMTP_SERVER}
#export CKAN_SMTP_STARTTLS=${CKAN_SMTP_STARTTLS}
#export CKAN_SMTP_USER=${CKAN_SMTP_USER}
#export CKAN_SMTP_PASSWORD=${CKAN_SMTP_PASSWORD}
#export CKAN_SMTP_MAIL_FROM=${CKAN_SMTP_MAIL_FROM}
#export CKAN_MAX_UPLOAD_SIZE_MB=${CKAN_MAX_UPLOAD_SIZE_MB}
}
write_config () {
ckan-paster make-config --no-interactive ckan "$CONFIG"
}
# If we don't already have a config file, bootstrap
if [ ! -e "$CONFIG" ]; then
write_config
fi
sed -i "/ckan.site_title/c ckan.site_title=$CKAN_SITE_TITLE" $CONFIG
sed -i "/ckan.site_description/c ckan.site_description=$CKAN_SITE_DESCRIPTION" $CONFIG
sed -i "/ckan.site_url/c ckan.site_url=$CKAN_SITE_URL" $CONFIG
sed -i "/sqlalchemy.url/c sqlalchemy.url=$CKAN_SQLALCHEMY_URL" $CONFIG
sed -i "/solr_url/c solr_url=$CKAN_SOLR_URL" $CONFIG
sed -i "/ckan.redis.url/c ckan.redis.url=$CKAN_REDIS_URL" $CONFIG
if [ ! -z "$CKAN_RECAPTCHA_PUBLICKEY" ]; then
if [ ! -z "$CKAN_RECAPTCHA_PRIVATEKEY" ]; then
sed -i "/ckan.recaptcha.publickey/c ckan.recaptcha.publickey=$CKAN_RECAPTCHA_PUBLICKEY" $CONFIG
sed -i "/ckan.recaptcha.privatekey/c ckan.recaptcha.privatekey=$CKAN_RECAPTCHA_PRIVATEKEY" $CONFIG
fi
else
echo "Recaptcha private/public keys are not set. Ignoring."
fi
export ORIGINAL_CKAN_PLUGINS="stats text_view image_view recline_view"
sed -i "/ckan.plugins/c ckan.plugins=$ORIGINAL_CKAN_PLUGINS $ADDITIONAL_CKAN_PLUGINS" $CONFIG
# add harvest configuration
sed -i "/\[app:main\]/a ckan.harvest.mq.type = redis" $CONFIG
sed -i "/\[app:main\]/a ckan.harvest.mq.hostname = $REDIS_HOSTNAME" $CONFIG
#sed -i "/ckan.datapusher.url/c ckan.datapusher.url=$CKAN_DATAPUSHER_URL" $CONFIG
#sed -i "/ckan.datastore.write_url/c ckan.datastore.write_url=$CKAN_DATASTORE_WRITE_URL" $CONFIG
#sed -i "/ckan.datastore.read_url/c ckan.datastore.read_url=$CKAN_DATASTORE_READ_URL" $CONFIG
set_environment
ckan-paster --plugin=ckan db init -c "${CKAN_CONFIG}/production.ini"
ckan-paster --plugin=ckanext-harvest harvester initdb -c "${CKAN_CONFIG}/production.ini"
exec "$@"