diff --git a/data/Dockerfiles/acme/docker-entrypoint.sh b/data/Dockerfiles/acme/docker-entrypoint.sh
index bb9a5a53..c8501168 100755
--- a/data/Dockerfiles/acme/docker-entrypoint.sh
+++ b/data/Dockerfiles/acme/docker-entrypoint.sh
@@ -42,7 +42,6 @@ mkdir -p ${ACME_BASE}/acme
[[ -f ${ACME_BASE}/acme/private/privkey.pem ]] && mv ${ACME_BASE}/acme/private/privkey.pem ${ACME_BASE}/acme/key.pem
[[ -f ${ACME_BASE}/acme/private/account.key ]] && mv ${ACME_BASE}/acme/private/account.key ${ACME_BASE}/acme/account.pem
-
reload_configurations(){
# Reading container IDs
# Wrapping as array to ensure trimmed content when calling $NGINX etc.
@@ -156,6 +155,7 @@ else
exec env TRIGGER_RESTART=1 $(readlink -f "$0")
fi
fi
+chmod 600 ${ACME_BASE}/key.pem
log_f "Waiting for database... " no_nl
while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do
@@ -196,6 +196,9 @@ while true; do
log_f "Using existing Lets Encrypt account key ${ACME_BASE}/acme/account.pem"
fi
+ chmod 600 ${ACME_BASE}/acme/key.pem
+ chmod 600 ${ACME_BASE}/acme/account.pem
+
# Skipping IP check when we like to live dangerously
if [[ "${SKIP_IP_CHECK}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
SKIP_IP_CHECK=y
diff --git a/data/Dockerfiles/phpfpm/docker-entrypoint.sh b/data/Dockerfiles/phpfpm/docker-entrypoint.sh
index 76c4035e..bf055f3a 100755
--- a/data/Dockerfiles/phpfpm/docker-entrypoint.sh
+++ b/data/Dockerfiles/phpfpm/docker-entrypoint.sh
@@ -25,23 +25,26 @@ CONTAINER_ID=
# Todo: Better check if upgrade failed
# This can happen due to a broken sogo_view
[ -s /mysql_upgrade_loop ] && SQL_LOOP_C=$(cat /mysql_upgrade_loop)
-CONTAINER_ID=$(curl --silent --insecure https://dockerapi/containers/json | jq -r ".[] | {name: .Config.Labels[\"com.docker.compose.service\"], id: .Id}" | jq -rc "select( .name | tostring | contains(\"mysql-mailcow\")) | .id")
-if [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ [^a-zA-Z0-9] ]]; then
- SQL_UPGRADE_RETURN=$(curl --silent --insecure -XPOST https://dockerapi/containers/${CONTAINER_ID}/exec -d '{"cmd":"system", "task":"mysql_upgrade"}' --silent -H 'Content-type: application/json' | jq -r .type)
- if [[ ${SQL_UPGRADE_RETURN} == 'warning' ]]; then
- if [ -z ${SQL_LOOP_C} ]; then
- echo 1 > /mysql_upgrade_loop
- echo "MySQL applied an upgrade, restarting PHP-FPM..."
- exit 1
- else
- rm /mysql_upgrade_loop
- echo "MySQL was not applied previously, skipping. Restart php-fpm-mailcow to retry or run mysql_upgrade manually."
- while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do
- echo "Waiting for SQL to return..."
- sleep 2
- done
- fi
+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)
+done
+echo "MySQL @ ${CONTAINER_ID}"
+SQL_UPGRADE_RETURN=$(curl --silent --insecure -XPOST https://dockerapi/containers/${CONTAINER_ID}/exec -d '{"cmd":"system", "task":"mysql_upgrade"}' --silent -H 'Content-type: application/json' | jq -r .type)
+if [[ ${SQL_UPGRADE_RETURN} == 'warning' ]]; then
+ if [ -z ${SQL_LOOP_C} ]; then
+ echo 1 > /mysql_upgrade_loop
+ echo "MySQL applied an upgrade, restarting PHP-FPM..."
+ exit 1
+ else
+ rm /mysql_upgrade_loop
+ echo "MySQL was not applied previously, skipping. Restart php-fpm-mailcow to retry or run mysql_upgrade manually."
+ while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do
+ echo "Waiting for SQL to return..."
+ sleep 2
+ done
fi
+else
+ echo "MySQL is up-to-date"
fi
# Trigger db init
diff --git a/data/Dockerfiles/rspamd/Dockerfile b/data/Dockerfiles/rspamd/Dockerfile
index 4c2094cf..87d92139 100644
--- a/data/Dockerfiles/rspamd/Dockerfile
+++ b/data/Dockerfiles/rspamd/Dockerfile
@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \
gnupg2 \
apt-transport-https \
&& apt-key adv --fetch-keys https://rspamd.com/apt/gpg.key \
- && echo "deb https://rspamd.com/apt/ bionic main" > /etc/apt/sources.list.d/rspamd.list \
+ && echo "deb https://rspamd.com/apt-stable/ bionic main" > /etc/apt/sources.list.d/rspamd.list \
&& apt-get update && apt-get install -y rspamd \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get autoremove --purge \
diff --git a/data/Dockerfiles/solr/Dockerfile b/data/Dockerfiles/solr/Dockerfile
index 25235664..1c74fde8 100644
--- a/data/Dockerfiles/solr/Dockerfile
+++ b/data/Dockerfiles/solr/Dockerfile
@@ -1,8 +1,12 @@
FROM solr:7.7-alpine
USER root
COPY docker-entrypoint.sh /
+COPY solr-config-7.7.0.xml /
+COPY solr-schema-7.7.0.xml /
+
RUN apk --no-cache add su-exec curl tzdata \
- && chmod +x /docker-entrypoint.sh
+ && chmod +x /docker-entrypoint.sh \
+ && bash /docker-entrypoint.sh --bootstrap
ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/data/Dockerfiles/solr/docker-entrypoint.sh b/data/Dockerfiles/solr/docker-entrypoint.sh
old mode 100755
new mode 100644
index 0634874f..5a33620d
--- a/data/Dockerfiles/solr/docker-entrypoint.sh
+++ b/data/Dockerfiles/solr/docker-entrypoint.sh
@@ -18,16 +18,10 @@ fi
set -e
-# allow easier debugging with `docker run -e VERBOSE=yes`
-if [[ "$VERBOSE" = "yes" ]]; then
- set -x
-fi
-
# run the optional initdb
. /opt/docker-solr/scripts/run-initdb
# fixing volume permission
-
[[ -d /opt/solr/server/solr/dovecot-fts/data ]] && chown -R solr:solr /opt/solr/server/solr/dovecot-fts/data
if [[ "${1}" != "--bootstrap" ]]; then
sed -i '/SOLR_HEAP=/c\SOLR_HEAP="'${SOLR_HEAP:-1024}'m"' /opt/solr/bin/solr.in.sh
@@ -35,15 +29,13 @@ else
sed -i '/SOLR_HEAP=/c\SOLR_HEAP="256m"' /opt/solr/bin/solr.in.sh
fi
-# keep a sentinel file so we don't try to create the core a second time
-# for example when we restart a container.
-# todo: check if a core exists without sentinel file
+if [[ "${1}" == "--bootstrap" ]]; then
+ echo "Creating initial configuration"
+ echo "Modifying default config set"
+ cp /solr-config-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/solrconfig.xml
+ cp /solr-schema-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/schema.xml
+ rm /opt/solr/server/solr/configsets/_default/conf/managed-schema
-SENTINEL=/opt/docker-solr/fts_core_created
-
-if [[ -f ${SENTINEL} ]]; then
- echo "skipping core creation"
-else
echo "Starting local Solr instance to setup configuration"
su-exec solr start-local-solr
@@ -58,19 +50,12 @@ else
done
echo "Created core \"dovecot-fts\""
- touch ${SENTINEL}
echo "Stopping local Solr"
su-exec solr stop-local-solr
+
+ exit 0
fi
-rm -f /opt/solr/server/solr/dovecot-fts/conf/schema.xml
-rm -f /opt/solr/server/solr/dovecot-fts/conf/managed-schema
-rm -f /opt/solr/server/solr/dovecot-fts/conf/solrconfig.xml
-
-cp /etc/solr/solr-config-7.7.0.xml /opt/solr/server/solr/dovecot-fts/conf/solrconfig.xml
-cp /etc/solr/solr-schema-7.7.0.xml /opt/solr/server/solr/dovecot-fts/conf/schema.xml
-
-chown -R solr:solr /opt/solr/server/solr/dovecot-fts/conf/{schema.xml,solrconfig.xml}
-
exec su-exec solr solr-foreground
+
diff --git a/data/conf/solr/solr-config-7.7.0.xml b/data/Dockerfiles/solr/solr-config-7.7.0.xml
similarity index 100%
rename from data/conf/solr/solr-config-7.7.0.xml
rename to data/Dockerfiles/solr/solr-config-7.7.0.xml
diff --git a/data/conf/solr/solr-schema-7.7.0.xml b/data/Dockerfiles/solr/solr-schema-7.7.0.xml
similarity index 95%
rename from data/conf/solr/solr-schema-7.7.0.xml
rename to data/Dockerfiles/solr/solr-schema-7.7.0.xml
index a41cbb47..2c2e6343 100644
--- a/data/conf/solr/solr-schema-7.7.0.xml
+++ b/data/Dockerfiles/solr/solr-schema-7.7.0.xml
@@ -1,6 +1,6 @@
-
' + value[0] + ' (' + value[1] + ')' + + ' - ' + lang.check_hash + '
' + ); + }); + } + else { + qAtts.text('-'); + } + } + }); + }); + // Initial table drawings draw_quarantine_table(); }); diff --git a/docker-compose.yml b/docker-compose.yml index 52a1ecc4..eaa6cc42 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,7 +71,7 @@ services: - clamd rspamd-mailcow: - image: mailcow/rspamd:1.37 + image: mailcow/rspamd:1.38 build: ./data/Dockerfiles/rspamd stop_grace_period: 30s depends_on: @@ -94,7 +94,7 @@ services: - rspamd php-fpm-mailcow: - image: mailcow/phpfpm:1.34 + image: mailcow/phpfpm:1.35 build: ./data/Dockerfiles/phpfpm command: "php-fpm -d date.timezone=${TZ} -d expose_php=0" depends_on: @@ -306,7 +306,7 @@ services: acme-mailcow: depends_on: - nginx-mailcow - image: mailcow/acme:1.48 + image: mailcow/acme:1.49 build: ./data/Dockerfiles/acme dns: - ${IPV4_NETWORK:-172.22.1}.254 @@ -405,12 +405,11 @@ services: - dockerapi solr-mailcow: - image: mailcow/solr:1.3 + image: mailcow/solr:1.4 build: ./data/Dockerfiles/solr restart: always volumes: - - solr-vol-1:/opt/solr/server/solr/dovecot/data - - ./data/conf/solr:/etc/solr + - solr-vol-1:/opt/solr/server/solr/dovecot-fts/data dns: - ${IPV4_NETWORK:-172.22.1}.254 environment: diff --git a/generate_config.sh b/generate_config.sh index e6005b72..e3947d8c 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -16,6 +16,7 @@ if [ -f mailcow.conf ]; then case $response in [yY][eE][sS]|[yY]) mv mailcow.conf mailcow.conf_backup + chmod 600 mailcow.conf_backup ;; *) exit 1 @@ -241,5 +242,7 @@ EOF mkdir -p data/assets/ssl +chmod 600 mailcow.conf + # copy but don't overwrite existing certificate cp -n data/assets/ssl-example/*.pem data/assets/ssl/ diff --git a/helper-scripts/nextcloud.sh b/helper-scripts/nextcloud.sh index d04f52d4..2ddac47a 100755 --- a/helper-scripts/nextcloud.sh +++ b/helper-scripts/nextcloud.sh @@ -76,9 +76,8 @@ elif [[ ${NC_UPDATE} == "y" ]]; then curl -L# -o nextcloud.tar.bz2 "https://download.nextcloud.com/server/releases/latest-15.tar.bz2" || { echo "Failed to download Nextcloud archive."; exit 1; } \ && tar -xjf nextcloud.tar.bz2 -C ./data/web/ \ && rm nextcloud.tar.bz2 \ - && rm -rf ./data/web/nextcloud/updater \ + #&& rm -rf ./data/web/nextcloud/updater \ && mkdir -p ./data/web/nextcloud/data \ - && mkdir -p ./data/web/nextcloud/custom_apps \ && chmod +x ./data/web/nextcloud/occ docker exec -it $(docker ps -f name=php-fpm-mailcow -q) bash -c "chown www-data:www-data -R /web/nextcloud" docker exec -it -u www-data $(docker ps -f name=php-fpm-mailcow -q) bash -c "/web/nextcloud/occ --no-warnings upgrade" @@ -106,12 +105,11 @@ elif [[ ${NC_INSTALL} == "y" ]]; then curl -L# -o nextcloud.tar.bz2 "https://download.nextcloud.com/server/releases/latest-15.tar.bz2" || { echo "Failed to download Nextcloud archive."; exit 1; } \ && tar -xjf nextcloud.tar.bz2 -C ./data/web/ \ && rm nextcloud.tar.bz2 \ - && rm -rf ./data/web/nextcloud/updater \ + #&& rm -rf ./data/web/nextcloud/updater \ && mkdir -p ./data/web/nextcloud/data \ - && mkdir -p ./data/web/nextcloud/custom_apps \ && chmod +x ./data/web/nextcloud/occ - docker exec -it $(docker ps -f name=php-fpm-mailcow -q) /bin/bash -c "chown -R www-data:www-data /web/nextcloud/data /web/nextcloud/config /web/nextcloud/apps /web/nextcloud/custom_apps" + docker exec -it $(docker ps -f name=php-fpm-mailcow -q) /bin/bash -c "chown -R www-data:www-data /web/nextcloud/data /web/nextcloud/config /web/nextcloud/apps" docker exec -it -u www-data $(docker ps -f name=php-fpm-mailcow -q) /web/nextcloud/occ --no-warnings maintenance:install \ --database mysql \ --database-host mysql \ diff --git a/update.sh b/update.sh index 887f2637..6ccbf8bb 100755 --- a/update.sh +++ b/update.sh @@ -71,8 +71,12 @@ while (($#)); do case "${1}" in --check|-c) echo "Checking remote code for updates..." - git fetch origin #${BRANCH} - if [[ -z $(git log HEAD --pretty=format:"%H" | grep $(git rev-parse origin/${BRANCH})) ]]; then + LATEST_REV=$(git ls-remote --exit-code --refs --quiet https://github.com/mailcow/mailcow-dockerized ${BRANCH} | cut -f1) + if [ $? -ne 0 ]; then + echo "A problem occurred while trying to fetch the latest revision from github." + exit 99 + fi + if [[ -z $(git log HEAD --pretty=format:"%H" | grep "${LATEST_REV}") ]]; then echo "Updated code is available." exit 0 else @@ -101,6 +105,7 @@ while (($#)); do done [[ ! -f mailcow.conf ]] && { echo "mailcow.conf is missing"; exit 1;} +chmod 600 mailcow.conf source mailcow.conf DOTS=${MAILCOW_HOSTNAME//[^.]}; if [ ${#DOTS} -lt 2 ]; then @@ -355,9 +360,8 @@ if grep -q 'SYSCTL_IPV6_DISABLED=1' mailcow.conf; then read -p "Press any key to continue..." < /dev/tty fi -echo -e "Fixing project name... " +# Checking for old project name bug sed -i 's#COMPOSEPROJECT_NAME#COMPOSE_PROJECT_NAME#g' mailcow.conf -sed -i '/COMPOSE_PROJECT_NAME=/s/-//g' mailcow.conf echo -e "Fixing PHP-FPM worker ports for Nginx sites..." sed -i 's#phpfpm:9000#phpfpm:9002#g' data/conf/nginx/*.conf