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