2018-01-02 11:19:00 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-10-13 09:33:26 +02:00
|
|
|
|
2020-02-22 16:58:26 +01:00
|
|
|
# Prepare variables
|
|
|
|
POSTGRES_DATA_DIR=${VOLUMES_DIR}/kanboard/postgres_data
|
|
|
|
KANBOARD_DATA_DIR=${VOLUMES_DIR}/kanboard/kanboard_data
|
|
|
|
KANBOARD_CONF_DIR=${VOLUMES_DIR}/kanboard/kanboard_conf
|
|
|
|
POSTGRES_NSUID=100070
|
|
|
|
POSTGRES_NSGID=100070
|
|
|
|
KANBOARD_NSUID=100102
|
|
|
|
KANBOARD_NSGID=100102
|
|
|
|
|
2019-10-03 20:48:09 +02:00
|
|
|
# Create Postgres instance
|
2020-02-22 16:58:26 +01:00
|
|
|
install -d -o ${POSTGRES_NSUID} -g ${POSTGRES_NSGID} -m 700 ${POSTGRES_DATA_DIR}
|
|
|
|
spoc-container exec kanboard-postgres -- initdb -D /var/lib/postgresql
|
2019-10-03 20:48:09 +02:00
|
|
|
|
|
|
|
# Configure Postgres
|
2020-02-22 16:58:26 +01:00
|
|
|
cp postgres_data/postgresql.conf ${POSTGRES_DATA_DIR}/postgresql.conf
|
|
|
|
cp postgres_data/pg_hba.conf ${POSTGRES_DATA_DIR}/pg_hba.conf
|
2017-10-14 10:30:47 +02:00
|
|
|
|
2019-12-09 22:28:11 +01:00
|
|
|
# Configure Kanboard
|
2020-02-22 16:58:26 +01:00
|
|
|
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
|
|
|
mkdir -p ${KANBOARD_CONF_DIR} ${KANBOARD_DATA_DIR}
|
|
|
|
envsubst <kanboard_conf/config.php >${KANBOARD_CONF_DIR}/config.php
|
|
|
|
chown -R ${KANBOARD_NSUID}:${KANBOARD_NSGID} ${KANBOARD_CONF_DIR} ${KANBOARD_DATA_DIR}
|
2019-12-09 22:28:11 +01:00
|
|
|
|
2017-10-13 09:33:26 +02:00
|
|
|
# Populate database
|
2020-02-22 16:58:26 +01:00
|
|
|
spoc-container start kanboard-postgres
|
|
|
|
envsubst <createdb.sql | spoc-container exec kanboard-postgres -- psql
|
|
|
|
spoc-container exec kanboard -- cat /srv/kanboard/app/Schema/Sql/postgres.sql | spoc-container exec kanboard-postgres -- sh -c "PGPASSWORD=${KANBOARD_PWD} psql kanboard kanboard"
|
2017-10-13 09:33:26 +02:00
|
|
|
|
2019-12-09 22:28:11 +01:00
|
|
|
# Create admin account
|
2017-10-13 09:33:26 +02:00
|
|
|
export KANBOARD_ADMIN_USER=admin
|
2019-06-05 18:55:15 +02:00
|
|
|
export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
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'))")
|
2020-02-22 16:58:26 +01:00
|
|
|
envsubst <adminpwd.sql | spoc-container exec kanboard-postgres -- psql kanboard
|
2018-09-13 20:38:36 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2020-02-22 16:58:26 +01:00
|
|
|
cp update-conf.sh ${VOLUMES_DIR}/kanboard/update-conf.sh
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2019-10-03 21:41:02 +02:00
|
|
|
# Stop services required for setup
|
2020-02-22 16:58:26 +01:00
|
|
|
spoc-container stop kanboard-postgres
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app kanboard kb "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
|