Browse Source

new: [mattermost] new charm

postgres
Valentin Lab 6 years ago
parent
commit
b83cbf56d4
  1. 26
      mattermost/hooks/init
  2. 26
      mattermost/hooks/postgres_database-relation-joined
  3. 16
      mattermost/metadata.yml

26
mattermost/hooks/init

@ -0,0 +1,26 @@
#!/bin/bash
## Init is run on host
## For now it is run every time the script is launched, but
## it should be launched only once after build.
## Accessible variables are:
## - SERVICE_NAME Name of current service
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
# Please note that postgres detect on its own if its datadir needs to be populated
##
## checking permission of base directory
##
dirs=("$SERVICE_CONFIGSTORE/mattermost/"{config,plugins} "$SERVICE_DATASTORE/mattermost/"{data,logs})
for dir in "${dirs[@]}"; do
mkdir -p "$dir"
find "$dir" \! -uid 2000 -exec chown -v 2000 {} \;
find "$dir" \! -gid 2000 -exec chgrp -v 2000 {} \;
done

26
mattermost/hooks/postgres_database-relation-joined

@ -0,0 +1,26 @@
#!/bin/bash
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
control=$(echo -en "$USER\0$DBNAME\0$PASSWORD" | md5_compat)
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DB_HOST: $MASTER_TARGET_SERVICE_NAME
MM_DBNAME: $DBNAME
MM_PASSWORD: $PASSWORD
MM_USERNAME: $USER
"
[ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
relation-set control "$control"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

16
mattermost/metadata.yml

@ -0,0 +1,16 @@
# description: "Mattermost"
# maintainer: "Valentin Lab <valentin.lab@kalysto.org>"
## We fix image here to be sure of what we install
docker-image: docker.0k.io/mattermost-team
# docker-image: docker.0k.io/mattermost-enterprise
config-resources:
- /mattermost/config
- /mattermost/plugins
data-resources:
- /mattermost/data
- /mattermost/logs
host-resources:
- /etc/localtime:ro
docker-compose:
restart: unless-stopped
Loading…
Cancel
Save