[PHP-FPM] Check if master, write to Redis master only
parent
423104db61
commit
f6b3a6e874
|
@ -8,21 +8,28 @@ while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${D
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
until [[ $(redis-cli -h redis-mailcow PING) == "PONG" ]]; do
|
# Do not attempt to write to slave
|
||||||
|
if [[ ! -z ${REDIS_SLAVEOF_IP} ]]; then
|
||||||
|
REDIS_CMDLINE="redis-cli -h ${REDIS_SLAVEOF_IP} -p ${REDIS_SLAVEOF_PORT}"
|
||||||
|
else
|
||||||
|
REDIS_CMDLINE="redis-cli -h redis -p 6379"
|
||||||
|
fi
|
||||||
|
|
||||||
|
until [[ $(${REDIS_CMDLINE} PING) == "PONG" ]]; do
|
||||||
echo "Waiting for Redis..."
|
echo "Waiting for Redis..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
|
||||||
|
echo "We are master, preparing..."
|
||||||
# Set a default release format
|
# Set a default release format
|
||||||
|
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_RELEASE_FORMAT) ]]; then
|
||||||
if [[ -z $(redis-cli --raw -h redis-mailcow GET Q_RELEASE_FORMAT) ]]; then
|
${REDIS_CMDLINE} --raw SET Q_RELEASE_FORMAT raw
|
||||||
redis-cli --raw -h redis-mailcow SET Q_RELEASE_FORMAT raw
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set max age of q items - if unset
|
# Set max age of q items - if unset
|
||||||
|
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_MAX_AGE) ]]; then
|
||||||
if [[ -z $(redis-cli --raw -h redis-mailcow GET Q_MAX_AGE) ]]; then
|
${REDIS_CMDLINE} --raw SET Q_MAX_AGE 365
|
||||||
redis-cli --raw -h redis-mailcow SET Q_MAX_AGE 365
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check mysql_upgrade
|
# Check mysql_upgrade
|
||||||
|
@ -90,7 +97,7 @@ php -c /usr/local/etc/php -f /web/inc/init_db.inc.php
|
||||||
# Recreating domain map
|
# Recreating domain map
|
||||||
echo "Rebuilding domain map in Redis..."
|
echo "Rebuilding domain map in Redis..."
|
||||||
declare -a DOMAIN_ARR
|
declare -a DOMAIN_ARR
|
||||||
redis-cli -h redis-mailcow DEL DOMAIN_MAP > /dev/null
|
${REDIS_CMDLINE} DEL DOMAIN_MAP > /dev/null
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
DOMAIN_ARR+=("$line")
|
DOMAIN_ARR+=("$line")
|
||||||
|
@ -102,15 +109,11 @@ done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${D
|
||||||
|
|
||||||
if [[ ! -z ${DOMAIN_ARR} ]]; then
|
if [[ ! -z ${DOMAIN_ARR} ]]; then
|
||||||
for domain in "${DOMAIN_ARR[@]}"; do
|
for domain in "${DOMAIN_ARR[@]}"; do
|
||||||
redis-cli -h redis-mailcow HSET DOMAIN_MAP ${domain} 1 > /dev/null
|
${REDIS_CMDLINE} HSET DOMAIN_MAP ${domain} 1 > /dev/null
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create dummy for custom overrides of mailcow style
|
|
||||||
[[ ! -f /web/css/build/0081-custom-mailcow.css ]] && echo '/* Autogenerated by mailcow */' > /web/css/build/0081-custom-mailcow.css
|
|
||||||
|
|
||||||
# Set API options if env vars are not empty
|
# Set API options if env vars are not empty
|
||||||
|
|
||||||
if [[ ${API_ALLOW_FROM} != "invalid" ]] && \
|
if [[ ${API_ALLOW_FROM} != "invalid" ]] && \
|
||||||
[[ ${API_KEY} != "invalid" ]] && \
|
[[ ${API_KEY} != "invalid" ]] && \
|
||||||
[[ ! -z ${API_KEY} ]] && \
|
[[ ! -z ${API_KEY} ]] && \
|
||||||
|
@ -157,6 +160,10 @@ END;
|
||||||
//
|
//
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create dummy for custom overrides of mailcow style
|
||||||
|
[[ ! -f /web/css/build/0081-custom-mailcow.css ]] && echo '/* Autogenerated by mailcow */' > /web/css/build/0081-custom-mailcow.css
|
||||||
|
|
||||||
# Run hooks
|
# Run hooks
|
||||||
for file in /hooks/*; do
|
for file in /hooks/*; do
|
||||||
|
|
Loading…
Reference in New Issue