myvemail/build/run/docker-entrypoint/init.d/20-nginx.sh

46 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Roundcube
if [ ! -f /usr/share/webapps/roundcube/config/config.inc.php ]
then
echo "<?php
\$config['db_dsnw'] = 'mysql://${MYVEMAIL_ROUNDCUBE_DBUSER}:${MYVEMAIL_ROUNDCUBE_DBPASS}@localhost/${MYVEMAIL_ROUNDCUBE_DBNAME}';
\$config['imap_host'] = 'ssl://${MYVEMAIL_SUBDOMAIN}.${MYVEMAIL_DOMAIN}';
\$config['default_port'] = 993;
\$config['smtp_host'] = 'tls://${MYVEMAIL_SUBDOMAIN}.${MYVEMAIL_DOMAIN}';
\$config['product_name'] = '${MYVEMAIL_SUBDOMAIN}.${MYVEMAIL_DOMAIN}';
\$config['create_default_folders'] = true;
\$config['support_url'] = '';
# Logging
\$config['log_driver'] = 'syslog';
\$config['syslog_facility'] = \LOG_MAIL;
\$config['des_key'] = '$(cat /dev/urandom | tr -d -c 'a-zA-Z0-9' | fold -w 24 | head -n 1)';
\$config['plugins'] = [$(printf "'%s', " $(ls /usr/share/webapps/roundcube/plugins | grep -v 'enigma\|database_attachments\|managesieve\|redundant_attachments') | sed "s/\(.*\), /\1/")];" | tee /usr/share/webapps/roundcube/config/config.inc.php >/dev/null
# Password plugin
roundcubepass_strength_drive=$(cat /dev/urandom | tr -d -c 'a-z' | fold -w 8 | head -n 1)
sed -e "/^\$config\['password_db_dsn'\]/ s|=.*|= 'mysql://${MYVEMAIL_POSTFIXADMIN_DBUSER}:${MYVEMAIL_POSTFIXADMIN_DBPASS}@localhost/${MYVEMAIL_POSTFIXADMIN_DBNAME}';|" \
-e "/^\$config\['password_strength_driver'\]/ s/=.*/= '${roundcubepass_strength_drive}';\\
\$config['password_"${roundcubepass_strength_drive}"_min_score'] = 5;/" \
-i /usr/share/webapps/roundcube/plugins/password/config.inc.php
fi
# Permissions
setfacl -R -m u:${MYVEMAIL_NGINX_USERGROUP}:rwx /usr/share/webapps/postfixadmin/templates_c/
chown ${MYVEMAIL_NGINX_USERGROUP}:${MYVEMAIL_NGINX_USERGROUP} /usr/share/webapps/roundcube/{temp,logs}/ -R
chown ${MYVEMAIL_NGINX_USERGROUP}:${MYVEMAIL_NGINX_USERGROUP} /usr/share/webapps/roundcube/plugins/password/config.inc.php
chmod 0600 /usr/share/webapps/roundcube/plugins/password/config.inc.php
# Port
sed "s/{{MYVEMAIL_PORT}}/${MYVEMAIL_PORT:-80}/" -i $(find /etc/nginx -type f -name "default*")
# Start services
/usr/sbin/php-fpm* -D
nginx