1#!/bin/sh 2# 3# Set credentials for using URLAUTH with IMAP servers. 4# 5 6/usr/sbin/postconf -e imap_submit_cred_file=/Library/Server/Mail/Config/postfix/submit.cred 7 8# Create submit.cred with either the same password dovecot is 9# configured for, or an unguessable random password. 10if [ ! -e /Library/Server/Mail/Config/postfix/submit.cred ] ; then 11 hostname=`/usr/sbin/postconf -c /Library/Server/Mail/Config/postfix -h myhostname` 12 if [ ! "$hostname" ] ; then 13 hostname=`hostname` 14 fi 15 16 # get pw from existing dovecot submit.passdb 17 if [ -s /Library/Server/Mail/Config/dovecot/submit.passdb ] ; then 18 pw=`grep "^submit:" /private/etc/dovecot/submit.passdb | sed -e 's,.*},,' -e 's,:.*,,'` 19 elif [ -s /private/etc/dovecot/submit.passdb ] ; then 20 pw=`grep "^submit:" /Library/Server/Mail/Config/dovecot/submit.passdb | sed -e 's,.*},,' -e 's,:.*,,'` 21 fi 22 23 # if no existing pw, create a new one 24 if [ ! "$pw" ] ; then 25 pw=`dd if=/dev/urandom bs=256 count=1 2>&1 | env LANG=C tr -dc a-zA-Z0-9 2>&1 | cut -b 1-22 2>&1` 26 fi 27 28 # set submit.cred with host name & pw 29 if [ "$pw" -a "$hostname" ]; then 30 echo "submitcred version 1" > /Library/Server/Mail/Config/postfix/submit.cred 31 echo "$hostname|submit|$pw" >> /Library/Server/Mail/Config/postfix/submit.cred 32 fi 33 chmod 600 /Library/Server/Mail/Config/postfix/submit.cred 34fi 35