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