LXCize CC setup
This commit is contained in:
parent
367deb0897
commit
d3ecfbf4e7
@ -1,27 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/crisiscleanup
|
||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
|
||||
|
||||
# Check prerequisites
|
||||
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
||||
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
||||
service postgres start
|
||||
|
||||
# Build Docker container
|
||||
docker build -t crisiscleanup ${SOURCE_DIR}
|
||||
cp ${SOURCE_DIR}/etc/init.d/crisiscleanup /etc/init.d/crisiscleanup
|
||||
rc-update -u
|
||||
# TODO: Have setup prereqs in a manifest file
|
||||
for SERVICE in postgres; do
|
||||
[ ! -e /run/openrc/started/${SERVICE} ] && service ${SERVICE} start && STOP_SERVICES="${STOP_SERVICES} ${SERVICE}"
|
||||
done
|
||||
|
||||
# Create database
|
||||
export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64)
|
||||
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
||||
envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
||||
|
||||
# Copy existing config files into persistent storage
|
||||
mkdir -p /srv/crisiscleanup/conf
|
||||
chown 8005:8005 /srv/crisiscleanup/conf
|
||||
docker run --rm -v /srv/crisiscleanup/conf:/mnt/conf crisiscleanup cp -rp /srv/crisiscleanup/config/. /mnt/conf
|
||||
chown root:root /srv/crisiscleanup/conf
|
||||
cp -r /var/lib/lxc/crisiscleanup/crisiscleanup/srv/crisiscleanup/config/. /srv/crisiscleanup/conf
|
||||
|
||||
# Configure CrisisCleanup
|
||||
export CRISISCLEANUP_ADMIN_USER="Admin"
|
||||
@ -34,10 +29,16 @@ cp ${SOURCE_DIR}/srv/crisiscleanup/conf/environments/production.rb /srv/crisiscl
|
||||
vmmgr update-login crisiscleanup "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}"
|
||||
|
||||
# Populate database
|
||||
envsubst <${SOURCE_DIR}/srv/crisiscleanup/db/seeds.rb >/tmp/seeds.rb
|
||||
docker run --rm -h crisiscleanup --link postgres -v /srv/crisiscleanup/conf:/srv/crisiscleanup/config crisiscleanup rake db:schema:load
|
||||
docker run --rm -h crisiscleanup --link postgres -v /srv/crisiscleanup/conf:/srv/crisiscleanup/config -v /tmp/seeds.rb:/srv/crisiscleanup/db/seeds.rb crisiscleanup rake db:seed
|
||||
rm /tmp/seeds.rb
|
||||
envsubst <${SOURCE_DIR}/srv/crisiscleanup/db/seeds.rb >/var/lib/lxc/crisiscleanup/crisiscleanup/tmp/seeds.rb
|
||||
lxc-execute crisiscleanup -- rake db:schema:load
|
||||
lxc-execute crisiscleanup -- rake db:seed
|
||||
rm /var/lib/lxc/crisiscleanup/crisiscleanup/tmp/seeds.rb
|
||||
|
||||
# Stop services required for build
|
||||
service postgres stop
|
||||
# Install service
|
||||
cp ${SOURCE_DIR}/etc/init.d/crisiscleanup /etc/init.d/crisiscleanup
|
||||
rc-update -u
|
||||
|
||||
# Stop services required for setup
|
||||
for SERVICE in ${STOP_SERVICES}; do
|
||||
service ${SERVICE} stop
|
||||
done
|
||||
|
@ -1,19 +1,13 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="Crisis Cleanup docker container"
|
||||
description="Crisis Cleanup container"
|
||||
|
||||
depend() {
|
||||
need docker postfix postgres
|
||||
need cgroups postgres
|
||||
}
|
||||
|
||||
start() {
|
||||
/usr/bin/docker run -d --rm \
|
||||
--name crisiscleanup \
|
||||
-h crisiscleanup \
|
||||
--link postfix \
|
||||
--link postgres \
|
||||
-v /srv/crisiscleanup/conf:/srv/crisiscleanup/config \
|
||||
crisiscleanup
|
||||
lxc-start crisiscleanup
|
||||
}
|
||||
|
||||
start_post() {
|
||||
@ -25,5 +19,5 @@ stop_pre() {
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/bin/docker stop crisiscleanup
|
||||
lxc-stop crisiscleanup
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ ${SOURCE_DIR}/activemq/setup.sh
|
||||
${SOURCE_DIR}/ckan-datapusher/setup.sh
|
||||
${SOURCE_DIR}/mariadb/setup.sh
|
||||
${SOURCE_DIR}/postgres/setup.sh
|
||||
#${SOURCE_DIR}/rabbitmq/setup.sh
|
||||
${SOURCE_DIR}/rabbitmq/setup.sh
|
||||
${SOURCE_DIR}/redis/setup.sh
|
||||
${SOURCE_DIR}/solr/setup.sh
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user