2016-12-15 10:07:09 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-12-19 15:19:35 +01:00
|
|
|
# Set config parameters, escape " in db password
|
|
|
|
DBPASS=$(echo ${DBPASS} | sed 's/"/\\"/g')
|
2016-12-15 10:07:09 +01:00
|
|
|
sed -i "/^connect/c\connect = \"host=mysql dbname=${DBNAME} user=${DBUSER} password=${DBPASS}\"" /etc/dovecot/sql/*
|
|
|
|
|
2016-12-19 15:19:35 +01:00
|
|
|
[[ ! -d /var/vmail/sieve ]] && mkdir -p /var/vmail/sieve
|
|
|
|
cat /etc/dovecot/sieve_after > /var/vmail/sieve/global.sieve
|
|
|
|
sievec /var/vmail/sieve/global.sieve
|
|
|
|
chown -R vmail:vmail /var/vmail/sieve
|
|
|
|
|
|
|
|
# Do not do this every start-up, it may take a very long time. So we use a stat check here.
|
2016-12-17 20:31:59 +01:00
|
|
|
if [[ $(stat -c %U /var/vmail/) != "vmail" ]] ; then chown -R vmail:vmail /var/vmail ; fi
|
|
|
|
|
2016-12-21 08:25:47 +01:00
|
|
|
# Create random master for SOGo sieve features
|
|
|
|
RAND_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
|
|
|
|
RAND_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
|
2016-12-21 09:34:08 +01:00
|
|
|
echo ${RAND_USER}:$(doveadm pw -s PBKDF2 -p ${RAND_PASS}) > /etc/dovecot/dovecot-master.passwd
|
2016-12-21 08:25:47 +01:00
|
|
|
echo ${RAND_USER}:${RAND_PASS} > /etc/sogo/sieve.creds
|
|
|
|
|
2016-12-15 10:07:09 +01:00
|
|
|
exec "$@"
|