2018-01-02 11:19:00 +01:00
|
|
|
#!/bin/sh
|
2018-07-15 21:55:35 +02:00
|
|
|
set -e
|
2017-10-13 09:33:26 +02:00
|
|
|
|
2018-09-13 21:14:53 +02:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
|
2017-10-13 09:33:26 +02:00
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-09-13 20:38:36 +02:00
|
|
|
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
2017-10-14 10:30:47 +02:00
|
|
|
|
2017-10-13 09:33:26 +02:00
|
|
|
# Populate database
|
|
|
|
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-09-13 20:38:36 +02:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
|
|
|
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"
|
2017-10-13 09:33:26 +02:00
|
|
|
|
|
|
|
# Configure Kanboard
|
2018-09-14 18:13:11 +02:00
|
|
|
mkdir -p /srv/kanboard/conf /srv/kanboard/data
|
2018-01-24 15:42:57 +01:00
|
|
|
chown -R 8009:8009 /srv/kanboard/data
|
2018-01-02 11:19:00 +01:00
|
|
|
envsubst <${SOURCE_DIR}/srv/kanboard/conf/config.php >/srv/kanboard/conf/config.php
|
2017-10-13 09:33:26 +02:00
|
|
|
export KANBOARD_ADMIN_USER=admin
|
|
|
|
export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
2018-09-16 17:19:13 +02:00
|
|
|
export KANBOARD_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${KANBOARD_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
|
2018-09-13 20:38:36 +02:00
|
|
|
envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql kanboard
|
2018-09-04 21:42:26 +02:00
|
|
|
vmmgr update-login kanboard "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
|
2017-10-13 09:33:26 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install cron job
|
|
|
|
cp ${SOURCE_DIR}/etc/periodic/daily/kanboard /etc/periodic/daily/kanboard
|
|
|
|
|
2018-09-13 20:38:36 +02:00
|
|
|
# Install service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/kanboard /etc/init.d/kanboard
|
|
|
|
rc-update -u
|
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
|
|
|
cp ${SOURCE_DIR}/srv/kanboard/update-conf.sh /srv/kanboard/update-conf.sh
|
2018-07-15 21:55:35 +02:00
|
|
|
|
|
|
|
# Stop services required for build
|
2018-09-13 20:38:36 +02:00
|
|
|
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|