WSL/SLF GitLab Repository

ckan-entrypoint.sh 1.06 KB
Newer Older
Sam's avatar
Sam committed
1
2
#!/bin/bash
set -eo pipefail
Sam's avatar
Sam committed
3
4

CONFIG="${CKAN_CONFIG}/production.ini"
Sam's avatar
Sam committed
5
export CKAN_STORAGE_PATH=/var/lib/ckan
Sam's avatar
Sam committed
6
7

abort () {
Sam's avatar
Sam committed
8
9
    echo "$@" >&2
    exit 1
Sam's avatar
Sam committed
10
11
}

12
13
14
15
16
17
18
if [ -f "/home/ckan/ckan.ini" ]; then
    echo "Linking existing config to $CONFIG"
    ln -sf /home/ckan/ckan.ini "$CONFIG"
    echo "Extracting CKAN_SQLALCHEMY_URL"
    CKAN_SQLALCHEMY_URL=$(awk -F " = " '/sqlalchemy.url/ {print $2;exit;}' "$CONFIG")
    SOLR_USER=$(awk -F " = " '/solr_user/ {print $2;exit;}' "$CONFIG")
    SOLR_PASS=$(awk -F " = " '/solr_password/ {print $2;exit;}' "$CONFIG")
19
else
20
    abort "ERROR: No ckan.ini file found."
21
fi
Sam's avatar
Sam committed
22

Sam's avatar
Sam committed
23
# Wait for PostgreSQL
24
while ! pg_isready -d "$CKAN_SQLALCHEMY_URL"; do
Sam's avatar
Sam committed
25
    sleep 1;
Sam's avatar
Sam committed
26
27
done

Sam's avatar
Sam committed
28
29
30
31
32
33
34
35
36
37
38
39
40
# Wait for Solr
while [[ $response != "200" ]]; do
    response=$(curl --user "$SOLR_USER:$SOLR_PASS" \
        -s -o /dev/null -I -w '%{http_code}' \
        http://solr:8983/solr/admin/cores?action=STATUS)
    if [[ $response != "200" ]]; then
        echo "No response from Solr. Is it running?"
        sleep 5;
    else
        echo "Successfully connected to Solr."
    fi
done

Sam's avatar
Sam committed
41
exec "$@"