[PHP-FPM] Minor changes to prepare routine
parent
a6af7cbc2e
commit
6ea8560de6
|
@ -20,20 +20,7 @@ until [[ $(${REDIS_CMDLINE} PING) == "PONG" ]]; do
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
|
# Check mysql_upgrade (master and slave)
|
||||||
echo "We are master, preparing..."
|
|
||||||
# Set a default release format
|
|
||||||
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_RELEASE_FORMAT) ]]; then
|
|
||||||
${REDIS_CMDLINE} --raw SET Q_RELEASE_FORMAT raw
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set max age of q items - if unset
|
|
||||||
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_MAX_AGE) ]]; then
|
|
||||||
${REDIS_CMDLINE} --raw SET Q_MAX_AGE 365
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check mysql_upgrade
|
|
||||||
|
|
||||||
CONTAINER_ID=
|
CONTAINER_ID=
|
||||||
until [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ ^[[:alnum:]]*$ ]]; do
|
until [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ ^[[:alnum:]]*$ ]]; do
|
||||||
CONTAINER_ID=$(curl --silent --insecure https://dockerapi/containers/json | jq -r ".[] | {name: .Config.Labels[\"com.docker.compose.service\"], id: .Id}" 2> /dev/null | jq -rc "select( .name | tostring | contains(\"mysql-mailcow\")) | .id" 2> /dev/null)
|
CONTAINER_ID=$(curl --silent --insecure https://dockerapi/containers/json | jq -r ".[] | {name: .Config.Labels[\"com.docker.compose.service\"], id: .Id}" 2> /dev/null | jq -rc "select( .name | tostring | contains(\"mysql-mailcow\")) | .id" 2> /dev/null)
|
||||||
|
@ -69,7 +56,7 @@ until [[ ${SQL_UPGRADE_STATUS} == 'success' ]]; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# doing post-installation stuff, if SQL was upgraded
|
# doing post-installation stuff, if SQL was upgraded (master and slave)
|
||||||
if [ ${SQL_CHANGED} -eq 1 ]; then
|
if [ ${SQL_CHANGED} -eq 1 ]; then
|
||||||
POSTFIX=($(curl --silent --insecure https://dockerapi/containers/json | jq -r '.[] | {name: .Config.Labels["com.docker.compose.service"], id: .Id}' | jq -rc 'select( .name | tostring | contains("postfix-mailcow")) | .id' | tr "\n" " "))
|
POSTFIX=($(curl --silent --insecure https://dockerapi/containers/json | jq -r '.[] | {name: .Config.Labels["com.docker.compose.service"], id: .Id}' | jq -rc 'select( .name | tostring | contains("postfix-mailcow")) | .id' | tr "\n" " "))
|
||||||
if [[ -z ${POSTFIX} ]]; then
|
if [[ -z ${POSTFIX} ]]; then
|
||||||
|
@ -82,7 +69,7 @@ if [ ${SQL_CHANGED} -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check mysql tz import
|
# Check mysql tz import (master and slave)
|
||||||
TZ_CHECK=$(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT CONVERT_TZ('2019-11-02 23:33:00','Europe/Berlin','UTC') AS time;" -BN 2> /dev/null)
|
TZ_CHECK=$(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT CONVERT_TZ('2019-11-02 23:33:00','Europe/Berlin','UTC') AS time;" -BN 2> /dev/null)
|
||||||
if [[ -z ${TZ_CHECK} ]] || [[ "${TZ_CHECK}" == "NULL" ]]; then
|
if [[ -z ${TZ_CHECK} ]] || [[ "${TZ_CHECK}" == "NULL" ]]; then
|
||||||
SQL_FULL_TZINFO_IMPORT_RETURN=$(curl --silent --insecure -XPOST https://dockerapi/containers/${CONTAINER_ID}/exec -d '{"cmd":"system", "task":"mysql_tzinfo_to_sql"}' --silent -H 'Content-type: application/json')
|
SQL_FULL_TZINFO_IMPORT_RETURN=$(curl --silent --insecure -XPOST https://dockerapi/containers/${CONTAINER_ID}/exec -d '{"cmd":"system", "task":"mysql_tzinfo_to_sql"}' --silent -H 'Content-type: application/json')
|
||||||
|
@ -90,31 +77,43 @@ if [[ -z ${TZ_CHECK} ]] || [[ "${TZ_CHECK}" == "NULL" ]]; then
|
||||||
echo ${SQL_FULL_TZINFO_IMPORT_RETURN}
|
echo ${SQL_FULL_TZINFO_IMPORT_RETURN}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Trigger db init
|
if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
|
||||||
echo "Running DB init..."
|
echo "We are master, preparing..."
|
||||||
php -c /usr/local/etc/php -f /web/inc/init_db.inc.php
|
# Set a default release format
|
||||||
|
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_RELEASE_FORMAT) ]]; then
|
||||||
|
${REDIS_CMDLINE} --raw SET Q_RELEASE_FORMAT raw
|
||||||
|
fi
|
||||||
|
|
||||||
# Recreating domain map
|
# Set max age of q items - if unset
|
||||||
echo "Rebuilding domain map in Redis..."
|
if [[ -z $(${REDIS_CMDLINE} --raw GET Q_MAX_AGE) ]]; then
|
||||||
declare -a DOMAIN_ARR
|
${REDIS_CMDLINE} --raw SET Q_MAX_AGE 365
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trigger db init
|
||||||
|
echo "Running DB init..."
|
||||||
|
php -c /usr/local/etc/php -f /web/inc/init_db.inc.php
|
||||||
|
|
||||||
|
# Recreating domain map
|
||||||
|
echo "Rebuilding domain map in Redis..."
|
||||||
|
declare -a DOMAIN_ARR
|
||||||
${REDIS_CMDLINE} 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")
|
||||||
done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
|
done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
DOMAIN_ARR+=("$line")
|
DOMAIN_ARR+=("$line")
|
||||||
done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT alias_domain FROM alias_domain" -Bs)
|
done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT alias_domain FROM alias_domain" -Bs)
|
||||||
|
|
||||||
if [[ ! -z ${DOMAIN_ARR} ]]; then
|
if [[ ! -z ${DOMAIN_ARR} ]]; then
|
||||||
for domain in "${DOMAIN_ARR[@]}"; do
|
for domain in "${DOMAIN_ARR[@]}"; do
|
||||||
${REDIS_CMDLINE} HSET DOMAIN_MAP ${domain} 1 > /dev/null
|
${REDIS_CMDLINE} HSET DOMAIN_MAP ${domain} 1 > /dev/null
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set API options if env vars are not empty
|
# Set API options if env vars are not empty
|
||||||
if [[ ${API_ALLOW_FROM} != "invalid" ]] && [[ ! -z ${API_ALLOW_FROM} ]]; then
|
if [[ ${API_ALLOW_FROM} != "invalid" ]] && [[ ! -z ${API_ALLOW_FROM} ]]; then
|
||||||
IFS=',' read -r -a API_ALLOW_FROM_ARR <<< "${API_ALLOW_FROM}"
|
IFS=',' read -r -a API_ALLOW_FROM_ARR <<< "${API_ALLOW_FROM}"
|
||||||
declare -a VALIDATED_API_ALLOW_FROM_ARR
|
declare -a VALIDATED_API_ALLOW_FROM_ARR
|
||||||
REGEX_IP6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'
|
REGEX_IP6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'
|
||||||
|
@ -139,10 +138,10 @@ INSERT INTO api (api_key, active, allow_from, access) VALUES ("${API_KEY_READ_ON
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create events
|
# Create events (master only, STATUS for event on slave will be SLAVESIDE_DISABLED)
|
||||||
mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF
|
mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF
|
||||||
DROP EVENT IF EXISTS clean_spamalias;
|
DROP EVENT IF EXISTS clean_spamalias;
|
||||||
DELIMITER //
|
DELIMITER //
|
||||||
CREATE EVENT clean_spamalias
|
CREATE EVENT clean_spamalias
|
||||||
|
|
|
@ -102,7 +102,7 @@ services:
|
||||||
- rspamd
|
- rspamd
|
||||||
|
|
||||||
php-fpm-mailcow:
|
php-fpm-mailcow:
|
||||||
image: mailcow/phpfpm:1.62
|
image: mailcow/phpfpm:1.63
|
||||||
command: "php-fpm -d date.timezone=${TZ} -d expose_php=0"
|
command: "php-fpm -d date.timezone=${TZ} -d expose_php=0"
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis-mailcow
|
- redis-mailcow
|
||||||
|
|
Loading…
Reference in New Issue