39 lines
1.6 KiB
Bash
Executable File
39 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -ev
|
|
|
|
cd $(realpath $(dirname "${0}"))/install
|
|
|
|
# Create Postgres instance
|
|
mkdir -p /srv/kanboard/postgres_data
|
|
chown -R 105432:105432 /srv/kanboard/postgres_data
|
|
chmod 700 /srv/kanboard/postgres_data
|
|
lxc-execute -n kanboard-postgres -- initdb -D /var/lib/postgresql
|
|
|
|
# Configure Postgres
|
|
cp postgres_data/postgresql.conf /srv/kanboard/postgres_data/postgresql.conf
|
|
cp postgres_data/pg_hba.conf /srv/kanboard/postgres_data/pg_hba.conf
|
|
|
|
# Populate database
|
|
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
|
service kanboard-postgres start
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 kanboard-postgres -- psql
|
|
lxc-execute kanboard -- cat /srv/kanboard/app/Schema/Sql/postgres.sql | lxc-attach -u 5432 -g 5432 kanboard-postgres -- sh -c "PGPASSWORD=${KANBOARD_PWD} psql kanboard kanboard"
|
|
|
|
# Configure Kanboard
|
|
mkdir -p /srv/kanboard/kanboard_conf /srv/kanboard/kanboard_data
|
|
chown -R 8080:8080 /srv/kanboard/kanboard_data
|
|
envsubst <kanboard_conf/config.php >/srv/kanboard/kanboard_conf/config.php
|
|
export KANBOARD_ADMIN_USER=admin
|
|
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 | lxc-attach -u 5432 -g 5432 kanboard-postgres -- psql kanboard
|
|
|
|
# Install config update script
|
|
cp update-conf.sh /srv/kanboard/update-conf.sh
|
|
|
|
# Stop services required for setup
|
|
service kanboard-postgres stop
|
|
|
|
# Register application
|
|
vmmgr register-app kanboard kb "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
|