Make CKAN SPOC-compatible, cont'd.

This commit is contained in:
Disassembler 2020-03-13 21:12:16 +01:00
parent 61ab0b0b48
commit 361bb2dc7b
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
3 changed files with 54 additions and 45 deletions

View File

@ -27,6 +27,8 @@ cd ${ROOT}/lxc-shared
spoc-image build -p alpine3.8/image spoc-image build -p alpine3.8/image
spoc-image build -p alpine3.8-php5.6/image spoc-image build -p alpine3.8-php5.6/image
spoc-image build -p alpine3.8-ruby2.4/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/image
spoc-image build -p alpine3.11-java8/image spoc-image build -p alpine3.11-java8/image
spoc-image build -p alpine3.11-php7.3/image spoc-image build -p alpine3.11-php7.3/image

View File

@ -1,80 +1,87 @@
#!/bin/sh #!/bin/sh
set -ev 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 # Create Postgres instance
mkdir -p /srv/ckan/postgres_data mkdir -p ${POSTGRES_DATA}
chown -R 105432:105432 /srv/ckan/postgres_data chown -R 105432:105432 ${POSTGRES_DATA}
chmod 700 /srv/ckan/postgres_data chmod 700 ${POSTGRES_DATA}
lxc-execute -n ckan-postgres -- initdb -D /var/lib/postgresql spoc-container exec ckan-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres # Configure Postgres
cp postgres_data/postgresql.conf /srv/ckan/postgres_data/postgresql.conf cp postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
cp postgres_data/pg_hba.conf /srv/ckan/postgres_data/pg_hba.conf cp postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
# Create database # Create database
export CKAN_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export CKAN_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
export CKAN_DS_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 spoc-container start ckan-postgres
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 ckan-postgres -- psql envsubst <createdb.sql | spoc-container exec ckan-postgres -- psql
# Configure Redis # Configure Redis
mkdir -p /srv/ckan/redis_conf /srv/ckan/redis_data mkdir -p ${REDIS_CONF} ${REDIS_DATA}
cp redis_conf/redis.conf /srv/ckan/redis_conf/redis.conf cp redis_conf/redis.conf ${REDIS_CONF}/redis.conf
chown -R 100000:100000 /srv/ckan/redis_conf chown -R 100000:100000 ${REDIS_CONF}
chown -R 106379:106379 /srv/ckan/redis_data chown -R 106379:106379 ${REDIS_DATA}
service lxc-ckan-redis start spoc-container start ckan-redis
# Configure Solr # Configure Solr
mkdir -p /srv/ckan/solr_data mkdir -p ${SOLR_DATA}
lxchelper extract ckan-solr /opt/solr/server/solr/solr.xml /srv/ckan/solr_data/solr.xml cp ${LAYERS_DIR}/solr6_6.5.1-200313/opt/solr/server/solr/solr.xml ${SOLR_DATA}/solr.xml
chown -R 108983:108983 /srv/ckan/solr_data chown -R 108983:108983 ${SOLR_DATA}
service lxc-ckan-solr start spoc-container start ckan-solr
# Configure CKAN Solr core # Configure CKAN Solr core
lxc-attach -u 8983 -g 8983 ckan-solr -- solr create -p 8983 -c ckan spoc-container exec ckan-solr -- solr create -p 8983 -c ckan
service lxc-ckan-solr stop spoc-container stop ckan-solr
cp solr_data/ckan/conf/schema.xml /srv/ckan/solr_data/ckan/conf/schema.xml cp solr_data/ckan/conf/schema.xml ${SOLR_DATA}/ckan/conf/schema.xml
cp solr_data/ckan/conf/solrconfig.xml /srv/ckan/solr_data/ckan/conf/solrconfig.xml cp solr_data/ckan/conf/solrconfig.xml ${SOLR_DATA}/ckan/conf/solrconfig.xml
chown -R 108983:108983 /srv/ckan/solr_data chown -R 108983:108983 ${SOLR_DATA}
service lxc-ckan-solr start spoc-container start ckan-solr
# Configure CKAN DataPusher # Configure CKAN DataPusher
mkdir -p /srv/ckan/datapusher_conf /srv/ckan/datapusher_data mkdir -p ${DATAPUSHER_CONF} ${DATAPUSHER_DATA}
cp datapusher_conf/datapusher.wsgi /srv/ckan/datapusher_conf/datapusher.wsgi cp datapusher_conf/datapusher.wsgi ${DATAPUSHER_CONF}/datapusher.wsgi
cp datapusher_conf/datapusher_settings.py /srv/ckan/datapusher_conf/datapusher_settings.py cp datapusher_conf/datapusher_settings.py ${DATAPUSHER_CONF}/datapusher_settings.py
chown -R 100000:100000 /srv/ckan/datapusher_conf chown -R 100000:100000 ${DATAPUSHER_CONF}
chown -R 108080:108080 /srv/ckan/datapusher_data chown -R 108080:108080 ${DATAPUSHER_DATA}
# Configure CKAN # Configure CKAN
mkdir -p /srv/ckan/ckan_conf /srv/ckan/ckan_data mkdir -p ${CKAN_CONF} ${CKAN_DATA}
export CKAN_SECRET=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export CKAN_SECRET=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
export CKAN_UUID=$(cat /proc/sys/kernel/random/uuid) export CKAN_UUID=$(cat /proc/sys/kernel/random/uuid)
envsubst <ckan_conf/ckan.ini >/srv/ckan/ckan_conf/ckan.ini envsubst <ckan_conf/ckan.ini >${CKAN_CONF}/ckan.ini
cp ckan_conf/who.ini /srv/ckan/ckan_conf/who.ini cp ckan_conf/who.ini ${CKAN_CONF}/who.ini
chown -R 100000:100000 /srv/ckan/ckan_conf chown -R 100000:100000 ${CKAN_CONF}
chown -R 108080:108080 /srv/ckan/ckan_data chown -R 108080:108080 ${CKAN_DATA}
# Populate database # Populate database
lxc-execute ckan -- paster --plugin=ckan db init -c /etc/ckan/ckan.ini spoc-container exec 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 spoc-container exec 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 datastore set-permissions -c /etc/ckan/ckan.ini | lxc-attach -u 5432 -g 5432 ckan-postgres -- psql
# Create admin account # Create admin account
export CKAN_ADMIN_USER="admin" export CKAN_ADMIN_USER="admin"
export CKAN_ADMIN_UUID=$(cat /proc/sys/kernel/random/uuid) export CKAN_ADMIN_UUID=$(cat /proc/sys/kernel/random/uuid)
export CKAN_ADMIN_APIKEY=$(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_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" export CKAN_ADMIN_EMAIL="admin@example.com"
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 ckan-postgres -- psql ckan envsubst <adminpwd.sql | spoc-container exec ckan-postgres -- psql ckan
# Install config update script
cp update-conf.sh /srv/ckan/update-conf.sh
# Stop services required for setup # Stop services required for setup
service lxc-ckan-solr stop spoc-container stop ckan-solr
service lxc-ckan-postgres stop spoc-container stop ckan-postgres
service lxc-ckan-redis stop spoc-container stop ckan-redis
# Register application # Register application
vmmgr register-app ckan ckan "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}" vmmgr register-app ckan ckan "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"

View File

@ -2,7 +2,7 @@
set -ev set -ev
# Remove persistent data # Remove persistent data
rm -rf /srv/ckan rm -rf "${VOLUMES_DIR}/ckan"
# Unregister application # Unregister application
vmmgr unregister-app ckan vmmgr unregister-app ckan