From 3f9d2e31f3317ac44951e0bb9946534161d18476 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 31 Mar 2021 09:59:35 -0700 Subject: [PATCH] vmail .my.cnf --- etc/vmail.conf | 3 +-- install.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/etc/vmail.conf b/etc/vmail.conf index 1537ff6..a2a98a8 100644 --- a/etc/vmail.conf +++ b/etc/vmail.conf @@ -6,9 +6,8 @@ if [ "$USER" != "vmail" ]; then fi # constants -readonly MYSQL_CONNECTION_INFO_FILE=/usr/local/etc/vmail-db-info.conf readonly VMAIL_DIR=/var/vmail -readonly VMAIL_DB=vmail +readonly MYSQL_CONNECTION_INFO_FILE=$VMAIL_DIR/.my.cnf # check that MYSQL_CONNECTION_INFO_FILE exists and is readable if [ ! -f "$MYSQL_CONNECTION_INFO_FILE" ]; then diff --git a/install.sh b/install.sh index ae023b4..3604923 100755 --- a/install.sh +++ b/install.sh @@ -77,6 +77,15 @@ apt -y install exim4-daemon-heavy spf-tools-perl spamassassin libclass-dbi-mysql usermod -a -G ssl-cert Debian-exim useradd --create-home --home-dir /var/vmail --shell /usr/sbin/nologin --system --user-group vmail +# configure vmail user .my.cnf for db access +install --owner=vmail --group=vmail --mode=640 /dev/null /var/vmail/.my.cnf +echo "[client]" > /var/vmail/.my.cnf +echo "host = localhost" >> /var/vmail/.my.cnf +echo "database = vmail" >> /var/vmail/.my.cnf +echo "user = vmail" >> /var/vmail/.my.cnf +echo "password = $VMAILPASS" >> /var/vmail/.my.cnf +echo "socket = /var/run/mysqld/mysqld.sock" >> /var/vmail/.my.cnf + # configure vmail dirs chmod 750 /var/vmail/ if [ ! -d "/etc/ssl/dkim" ]; then