Spotter-VM/lxc-apps/kanboard/install.sh

39 lines
1.7 KiB
Bash
Raw Normal View History

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-03-17 16:49:00 +01:00
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/kanboard/postgres_data"
KANBOARD_CONF="${VOLUMES_DIR}/kanboard/kanboard_conf"
KANBOARD_DATA="${VOLUMES_DIR}/kanboard/kanboard_data"
2019-10-03 20:48:09 +02:00
# Create Postgres instance
2020-03-17 16:49:00 +01:00
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec kanboard-postgres -- initdb -D /var/lib/postgresql
2019-10-03 20:48:09 +02:00
# Configure Postgres
2020-03-17 16:49:00 +01:00
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
2017-10-14 10:30:47 +02:00
2019-12-09 22:28:11 +01:00
# Configure Kanboard
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
2020-03-17 16:49:00 +01:00
install -o 108080 -g 108080 -m 750 -d ${KANBOARD_CONF}
install -o 108080 -g 108080 -m 750 -d ${KANBOARD_DATA}
envsubst <kanboard_conf/config.php | install -o 108080 -g 108080 -m 640 /dev/stdin ${KANBOARD_CONF}/config.php
2019-12-09 22:28:11 +01:00
2017-10-13 09:33:26 +02:00
# Populate database
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
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 '+/=')
export KANBOARD_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${KANBOARD_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
envsubst <adminpwd.sql | spoc-container exec kanboard-postgres -- psql kanboard
2018-09-13 20:38:36 +02:00
2019-10-03 21:41:02 +02:00
# Stop services required for setup
spoc-container stop kanboard-postgres
2018-10-28 19:50:35 +01:00
# Register application
2019-02-26 21:12:41 +01:00
vmmgr register-app kanboard kb "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"