2017-03-02 18:23:23 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2017-05-14 20:26:07 +08:00
|
|
|
if [[ ! -d "/data/dkim/txt" || ! -d "/data/dkim/keys" ]] ; then mkdir -p /data/dkim/{txt,keys} ; chown -R www-data:www-data /data/dkim; fi
|
2017-03-02 18:23:23 +08:00
|
|
|
if [[ $(stat -c %U /data/dkim/) != "www-data" ]] ; then chown -R www-data:www-data /data/dkim ; fi
|
|
|
|
|
2017-05-08 21:35:24 +08:00
|
|
|
# Wait for containers
|
|
|
|
|
2017-09-13 02:57:02 +08:00
|
|
|
while ! mysqladmin ping --host mysql -u${DBUSER} -p${DBPASS} --silent; do
|
2017-05-08 21:35:24 +08:00
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
|
|
|
until [ $(redis-cli -h redis-mailcow PING) == "PONG" ]; do
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
|
|
|
# Migrate domain map
|
|
|
|
declare -a DOMAIN_ARR
|
|
|
|
redis-cli -h redis-mailcow DEL DOMAIN_MAP
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
DOMAIN_ARR+=("$line")
|
|
|
|
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
|
2018-01-17 22:23:33 +08:00
|
|
|
while read line
|
|
|
|
do
|
|
|
|
DOMAIN_ARR+=("$line")
|
|
|
|
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT alias_domain FROM alias_domain" -Bs)
|
|
|
|
|
2017-05-08 21:35:24 +08:00
|
|
|
|
|
|
|
if [[ ! -z ${DOMAIN_ARR} ]]; then
|
|
|
|
for domain in "${DOMAIN_ARR[@]}"; do
|
|
|
|
redis-cli -h redis-mailcow HSET DOMAIN_MAP ${domain} 1
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2017-03-02 18:23:23 +08:00
|
|
|
exec "$@"
|