LXCize KanBoard setup

This commit is contained in:
Disassembler 2018-09-13 20:38:36 +02:00
parent 986c13f4c7
commit 86f4f940c7
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
2 changed files with 14 additions and 24 deletions

View File

@ -4,19 +4,12 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/kanboard SOURCE_DIR=$(realpath $(dirname "${0}"))/kanboard
# 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 kanboard ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/kanboard /etc/init.d/kanboard
rc-update -u
# Populate database # Populate database
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64) export KANBOARD_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
docker run --rm kanboard cat /srv/kanboard/app/Schema/Sql/postgres.sql | docker exec -i -e PGPASSWORD=${KANBOARD_PWD} postgres psql kanboard kanboard cat /var/lib/lxc/kanboard/kanboard/srv/kanboard/app/Schema/Sql/postgres.sql | lxc-attach -u 5432 -g 5432 postgres -- sh -c "PGPASSWORD=${KANBOARD_PWD} psql kanboard kanboard"
# Configure Kanboard # Configure Kanboard
mkdir -p /srv/kanboard/conf /srv/kanboard/data/ mkdir -p /srv/kanboard/conf /srv/kanboard/data/
@ -24,12 +17,16 @@ chown -R 8009:8009 /srv/kanboard/data
envsubst <${SOURCE_DIR}/srv/kanboard/conf/config.php >/srv/kanboard/conf/config.php envsubst <${SOURCE_DIR}/srv/kanboard/conf/config.php >/srv/kanboard/conf/config.php
export KANBOARD_ADMIN_USER=admin export KANBOARD_ADMIN_USER=admin
export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export KANBOARD_ADMIN_HASH=$(docker run --rm kanboard php -r "echo password_hash('${KANBOARD_ADMIN_PWD}', PASSWORD_BCRYPT);") export KANBOARD_ADMIN_HASH=$(lxc-execute kanboard -- php -r "echo password_hash('${KANBOARD_ADMIN_PWD}', PASSWORD_BCRYPT);")
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql kanboard envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql kanboard
vmmgr update-login kanboard "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}" vmmgr update-login kanboard "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
# Install service
cp ${SOURCE_DIR}/etc/init.d/kanboard /etc/init.d/kanboard
rc-update -u
# Install cron job # Install cron job
cp ${SOURCE_DIR}/etc/periodic/daily/kanboard /etc/periodic/daily/kanboard cp ${SOURCE_DIR}/etc/periodic/daily/kanboard /etc/periodic/daily/kanboard
# Stop services required for build # Stop services required for build
service postgres stop [ ! -z ${STOP_POSTGRES} ] && service postgres stop

View File

@ -1,20 +1,13 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="KanBoard docker container" description="KanBoard container"
depend() { depend() {
need docker postfix postgres need cgroups postgres
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start kanboard
--name kanboard \
-h kanboard \
--link postfix \
--link postgres \
-v /srv/kanboard/data:/srv/kanboard/data/files \
-v /srv/kanboard/conf/config.php:/srv/kanboard/config.php \
kanboard
} }
start_post() { start_post() {
@ -26,5 +19,5 @@ stop_pre() {
} }
stop() { stop() {
/usr/bin/docker stop kanboard lxc-stop kanboard
} }