From 361bb2dc7b883a00c884863cd8533314a644267f Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 13 Mar 2020 21:12:16 +0100 Subject: [PATCH] Make CKAN SPOC-compatible, cont'd. --- build/build-all.sh | 2 + lxc-apps/ckan/install.sh | 95 ++++++++++++++++++++------------------ lxc-apps/ckan/uninstall.sh | 2 +- 3 files changed, 54 insertions(+), 45 deletions(-) diff --git a/build/build-all.sh b/build/build-all.sh index 8390e31..fec66a0 100755 --- a/build/build-all.sh +++ b/build/build-all.sh @@ -27,6 +27,8 @@ cd ${ROOT}/lxc-shared spoc-image build -p alpine3.8/image spoc-image build -p alpine3.8-php5.6/image spoc-image build -p alpine3.8-ruby2.4/image +spoc-image build -p alpine3.10/image +spoc-image build -p alpine3.10-python2.7/image spoc-image build -p alpine3.11/image spoc-image build -p alpine3.11-java8/image spoc-image build -p alpine3.11-php7.3/image diff --git a/lxc-apps/ckan/install.sh b/lxc-apps/ckan/install.sh index ce620bc..3405208 100755 --- a/lxc-apps/ckan/install.sh +++ b/lxc-apps/ckan/install.sh @@ -1,80 +1,87 @@ #!/bin/sh set -ev +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/ckan/postgres_data" +REDIS_CONF="${VOLUMES_DIR}/ckan/redis_conf" +REDIS_DATA="${VOLUMES_DIR}/ckan/redis_data" +SOLR_DATA="${VOLUMES_DIR}/ckan/solr_data" +DATAPUSHER_CONF="${VOLUMES_DIR}/ckan/datapusher_conf" +DATAPUSHER_DATA="${VOLUMES_DIR}/ckan/datapusher_data" +CKAN_CONF="${VOLUMES_DIR}/ckan/ckan_conf" +CKAN_DATA="${VOLUMES_DIR}/ckan/ckan_data" + # Create Postgres instance -mkdir -p /srv/ckan/postgres_data -chown -R 105432:105432 /srv/ckan/postgres_data -chmod 700 /srv/ckan/postgres_data -lxc-execute -n ckan-postgres -- initdb -D /var/lib/postgresql +mkdir -p ${POSTGRES_DATA} +chown -R 105432:105432 ${POSTGRES_DATA} +chmod 700 ${POSTGRES_DATA} +spoc-container exec ckan-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf /srv/ckan/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf /srv/ckan/postgres_data/pg_hba.conf +cp postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf +cp postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf # Create database export CKAN_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export CKAN_DS_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') -service lxc-ckan-postgres start -envsubst /srv/ckan/ckan_conf/ckan.ini -cp ckan_conf/who.ini /srv/ckan/ckan_conf/who.ini -chown -R 100000:100000 /srv/ckan/ckan_conf -chown -R 108080:108080 /srv/ckan/ckan_data +envsubst ${CKAN_CONF}/ckan.ini +cp ckan_conf/who.ini ${CKAN_CONF}/who.ini +chown -R 100000:100000 ${CKAN_CONF} +chown -R 108080:108080 ${CKAN_DATA} # Populate database -lxc-execute ckan -- paster --plugin=ckan db init -c /etc/ckan/ckan.ini -lxc-execute ckan -- paster --plugin=ckanext-spatial spatial initdb -c /etc/ckan/ckan.ini -lxc-execute ckan -- paster --plugin=ckan datastore set-permissions -c /etc/ckan/ckan.ini | lxc-attach -u 5432 -g 5432 ckan-postgres -- psql +spoc-container exec ckan -- paster --plugin=ckan db init -c /etc/ckan/ckan.ini +spoc-container exec ckan -- paster --plugin=ckanext-spatial spatial initdb -c /etc/ckan/ckan.ini +spoc-container exec ckan -- paster --plugin=ckan datastore set-permissions -c /etc/ckan/ckan.ini | lxc-attach -u 5432 -g 5432 ckan-postgres -- psql # Create admin account export CKAN_ADMIN_USER="admin" export CKAN_ADMIN_UUID=$(cat /proc/sys/kernel/random/uuid) export CKAN_ADMIN_APIKEY=$(cat /proc/sys/kernel/random/uuid) export CKAN_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') -export CKAN_ADMIN_HASH=$(lxc-execute ckan -- python -c "from passlib.hash import pbkdf2_sha512;print pbkdf2_sha512.encrypt('${CKAN_ADMIN_PWD}')") +export CKAN_ADMIN_HASH=$(spoc-container exec ckan -- python -c "from passlib.hash import pbkdf2_sha512;print pbkdf2_sha512.encrypt('${CKAN_ADMIN_PWD}')") export CKAN_ADMIN_EMAIL="admin@example.com" -envsubst