Update KanBoard install scripts for spoc

This commit is contained in:
Disassembler 2020-02-22 16:58:26 +01:00
parent 2ee9b97020
commit 99c39d5ee9
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
3 changed files with 27 additions and 20 deletions

View File

@ -13,14 +13,14 @@
"kanboard-postgres" "kanboard-postgres"
], ],
"mounts": { "mounts": {
"kanboard/kanboard_data": "/srv/kanboard/data/files", "kanboard/kanboard_data": "srv/kanboard/data/files",
"kanboard/kanboard_conf/config.php": "file:/srv/kanboard/config.php" "kanboard/kanboard_conf/config.php": "srv/kanboard/config.php:file"
} }
}, },
"kanboard-postgres": { "kanboard-postgres": {
"image": "postgres_12.1.0-200207", "image": "postgres_12.1.0-200207",
"mounts": { "mounts": {
"kanboard/postgres_data": "/var/lib/postgresql" "kanboard/postgres_data": "var/lib/postgresql"
} }
} }
} }

View File

@ -1,38 +1,45 @@
#!/bin/sh #!/bin/sh
set -ev set -ev
# 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
# Create Postgres instance # Create Postgres instance
mkdir -p /srv/kanboard/postgres_data install -d -o ${POSTGRES_NSUID} -g ${POSTGRES_NSGID} -m 700 ${POSTGRES_DATA_DIR}
chown -R 105432:105432 /srv/kanboard/postgres_data spoc-container exec kanboard-postgres -- initdb -D /var/lib/postgresql
chmod 700 /srv/kanboard/postgres_data
lxc-execute -n kanboard-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres # Configure Postgres
cp postgres_data/postgresql.conf /srv/kanboard/postgres_data/postgresql.conf cp postgres_data/postgresql.conf ${POSTGRES_DATA_DIR}/postgresql.conf
cp postgres_data/pg_hba.conf /srv/kanboard/postgres_data/pg_hba.conf cp postgres_data/pg_hba.conf ${POSTGRES_DATA_DIR}/pg_hba.conf
# Configure Kanboard # Configure Kanboard
mkdir -p /srv/kanboard/kanboard_conf /srv/kanboard/kanboard_data export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
chown -R 108080:108080 /srv/kanboard/kanboard_data mkdir -p ${KANBOARD_CONF_DIR} ${KANBOARD_DATA_DIR}
envsubst <kanboard_conf/config.php >/srv/kanboard/kanboard_conf/config.php envsubst <kanboard_conf/config.php >${KANBOARD_CONF_DIR}/config.php
chown -R ${KANBOARD_NSUID}:${KANBOARD_NSGID} ${KANBOARD_CONF_DIR} ${KANBOARD_DATA_DIR}
# Populate database # Populate database
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') spoc-container start kanboard-postgres
service lxc-kanboard-postgres start envsubst <createdb.sql | spoc-container exec kanboard-postgres -- psql
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 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"
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"
# Create admin account # Create admin account
export KANBOARD_ADMIN_USER=admin export KANBOARD_ADMIN_USER=admin
export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') 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'))") 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 envsubst <adminpwd.sql | spoc-container exec kanboard-postgres -- psql kanboard
# Install config update script # Install config update script
cp update-conf.sh /srv/kanboard/update-conf.sh cp update-conf.sh ${VOLUMES_DIR}/kanboard/update-conf.sh
# Stop services required for setup # Stop services required for setup
service lxc-kanboard-postgres stop spoc-container stop kanboard-postgres
# Register application # Register application
vmmgr register-app kanboard kb "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}" vmmgr register-app kanboard kb "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"

View File

@ -2,7 +2,7 @@
set -ev set -ev
# Remove persistent data # Remove persistent data
rm -rf /srv/kanboard rm -rf ${VOLUME_DIR}/kanboard
# Unregister application # Unregister application
vmmgr unregister-app kanboard vmmgr unregister-app kanboard