Fix Dockerfile, again

master
andryyy 2017-05-17 21:16:48 +02:00
parent 61de3c354c
commit a7b854f7ce
1 changed files with 26 additions and 1 deletions

View File

@ -51,10 +51,35 @@ for file in $(ls /data/dkim/keys/); do
domain=${file%.dkim} domain=${file%.dkim}
if [[ -f /data/dkim/txt/${file} ]]; then if [[ -f /data/dkim/txt/${file} ]]; then
redis-cli -h redis-mailcow HSET DKIM_PUB_KEYS "${domain}" "$(cat /data/dkim/txt/${file})" redis-cli -h redis-mailcow HSET DKIM_PUB_KEYS "${domain}" "$(cat /data/dkim/txt/${file})"
redis-cli -h redis-mailcow HSET DKIM_PRIV_KEYS "${domain}" "$(cat /data/dkim/keys/${file})" redis-cli -h redis-mailcow HSET DKIM_PRIV_KEYS "dkim.${domain}" "$(cat /data/dkim/keys/${file})"
redis-cli -h redis-mailcow HSET DKIM_SELECTORS "${domain}" "dkim" redis-cli -h redis-mailcow HSET DKIM_SELECTORS "${domain}" "dkim"
fi fi
rm /data/dkim/{keys,txt}/${file} rm /data/dkim/{keys,txt}/${file}
done done
# Fix DKIM keys
# Fetch domains
declare -a DOMAIN_ARRAY
while read line
do
DOMAIN_ARRAY+=("$line")
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
while read line
do
DOMAIN_ARRAY+=("$line")
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT alias_domain FROM alias_domain" -Bs)
# Loop through array and fix keys
if [[ ! -z ${DOMAIN_ARRAY} ]]; then
for domain in "${DOMAIN_ARRAY[@]}"; do
WRONG_KEY=$(redis-cli -h redis-mailcow HGET DKIM_PRIV_KEYS ${domain} | tr -d \")
if [[ ! -z ${WRONG_KEY} ]]; then
echo "Migrating defect key for domain ${domain}"
redis-cli -h redis-mailcow HSET DKIM_PRIV_KEYS "dkim.${domain}" ${WRONG_KEY}
redis-cli -h redis-mailcow HDEL DKIM_PRIV_KEYS "${domain}"
fi
done
fi
exec "$@" exec "$@"