LXCize Sahana setup
This commit is contained in:
parent
f747b89a5d
commit
b47df1d71d
@ -49,7 +49,7 @@ COPY lxc
|
|||||||
RUN EOF
|
RUN EOF
|
||||||
# Create OS user
|
# Create OS user
|
||||||
addgroup -S -g 8001 sahana
|
addgroup -S -g 8001 sahana
|
||||||
adduser -S -u 8001 -h /srv/web2py -s /bin/sh -g sahana -G sahana sahana
|
adduser -S -u 8001 -h /srv/web2py -s /bin/false -g sahana -G sahana sahana
|
||||||
chown -R sahana:sahana /srv/web2py
|
chown -R sahana:sahana /srv/web2py
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
@ -1,21 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
|
||||||
|
|
||||||
# Check prerequisites
|
# Check prerequisites
|
||||||
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
||||||
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
|
||||||
service postgres start
|
|
||||||
|
|
||||||
# Build Docker container
|
|
||||||
docker build -t sahana ${SOURCE_DIR}
|
|
||||||
cp ${SOURCE_DIR}/etc/init.d/sahana /etc/init.d/sahana
|
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Create PostgreSQL user and database
|
# Create PostgreSQL user and database
|
||||||
export SAHANA_PWD=$(head -c 18 /dev/urandom | base64)
|
export SAHANA_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
|
||||||
|
|
||||||
# Prepare persistent directory structure
|
# Prepare persistent directory structure
|
||||||
mkdir -p /srv/sahana/conf /srv/sahana/data/databases /srv/sahana/data/uploads
|
mkdir -p /srv/sahana/conf /srv/sahana/data/databases /srv/sahana/data/uploads
|
||||||
@ -36,7 +29,7 @@ cp ${SOURCE_DIR}/srv/sahana/conf/00_settings.py /srv/sahana/conf/00_settings.py
|
|||||||
vmmgr update-login sahana "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}"
|
vmmgr update-login sahana "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}"
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
docker run --rm -h sahana --link postgres -v /srv/sahana/conf:/srv/web2py/applications/eden/models -v /srv/sahana/data/Spotter:/srv/web2py/applications/eden/modules/templates/Spotter -v /srv/sahana/data/databases:/srv/web2py/applications/eden/databases sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py"
|
lxc-execute -u 8001 -g 8001 sahana -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py'
|
||||||
|
|
||||||
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
||||||
if [ ${DEBUG:-0} -eq 0 ]; then
|
if [ ${DEBUG:-0} -eq 0 ]; then
|
||||||
@ -45,5 +38,9 @@ if [ ${DEBUG:-0} -eq 0 ]; then
|
|||||||
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sahana/conf/000_config.py
|
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sahana/conf/000_config.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Install service
|
||||||
|
cp ${SOURCE_DIR}/etc/init.d/sahana /etc/init.d/sahana
|
||||||
|
rc-update -u
|
||||||
|
|
||||||
# Stop services required for build
|
# Stop services required for build
|
||||||
service postgres stop
|
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
||||||
|
@ -1,22 +1,13 @@
|
|||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
description="Sahana Eden docker container"
|
description="Sahana Eden container"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need docker postfix postgres
|
need cgroups postgres
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
/usr/bin/docker run -d --rm \
|
lxc-start sahana
|
||||||
--name sahana \
|
|
||||||
-h sahana \
|
|
||||||
--link postfix \
|
|
||||||
--link postgres \
|
|
||||||
-v /srv/sahana/conf:/srv/web2py/applications/eden/models \
|
|
||||||
-v /srv/sahana/data/Spotter:/srv/web2py/applications/eden/modules/templates/Spotter \
|
|
||||||
-v /srv/sahana/data/databases:/srv/web2py/applications/eden/databases \
|
|
||||||
-v /srv/sahana/data/uploads:/srv/web2py/applications/eden/uploads \
|
|
||||||
sahana
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_post() {
|
start_post() {
|
||||||
@ -28,5 +19,5 @@ stop_pre() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
/usr/bin/docker stop sahana
|
lxc-stop sahana
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user