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

37 lines
1.6 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
2019-10-03 20:48:09 +02:00
# 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
2017-10-14 10:30:47 +02:00
2017-10-13 09:33:26 +02:00
# Populate database
2019-06-05 18:55:15 +02:00
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
2019-10-03 20:48:09 +02:00
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"
2017-10-13 09:33:26 +02:00
# Configure Kanboard
2019-10-03 20:48:09 +02:00
mkdir -p /srv/kanboard/kanboard_conf /srv/kanboard/kanboard_data
chown -R 8080:8080 /srv/kanboard/kanboard_data
2019-10-03 20:48:09 +02:00
envsubst <kanboard_conf/config.php >/srv/kanboard/kanboard_conf/config.php
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 '+/=')
export KANBOARD_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${KANBOARD_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
2019-10-03 20:48:09 +02:00
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 kanboard-postgres -- psql kanboard
2018-09-13 20:38:36 +02:00
# Install config update script
2019-10-03 20:48:09 +02:00
cp update-conf.sh /srv/kanboard/update-conf.sh
2019-10-03 21:41:02 +02:00
# Stop services required for setup
2019-10-03 20:48:09 +02:00
service kanboard-postgres stop
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}"