WSL/SLF GitLab Repository

ckan-entrypoint.sh 721 Bytes
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
if [ -z "$CKAN_CONFIG_PATH" ]; then
    if [ -f "/run/secrets/ckan_config" ]; then
        echo "Linking existing config to $CONFIG"
        ln -sf /run/secrets/ckan_config "$CONFIG"
        echo "Extracting CKAN_SQLALCHEMY_URL"
        CKAN_SQLALCHEMY_URL=$(awk -F " = " '/sqlalchemy.url/ {print $2;exit;}' "$CONFIG")
Sam's avatar
Sam committed
18
    else
19
        abort "ERROR: CKAN_CONFIG_PATH specified, but file doesn't exist."
Sam's avatar
Sam committed
20
21
    fi

22
23
24
else
    abort "ERROR: No CKAN config file provided."
fi
Sam's avatar
Sam committed
25

Sam's avatar
Sam committed
26
# Wait for PostgreSQL
27
while ! pg_isready -d "$CKAN_SQLALCHEMY_URL"; do
Sam's avatar
Sam committed
28
    sleep 1;
Sam's avatar
Sam committed
29
30
31
done

exec "$@"