#!/bin/ksh # Description: Cron run script to keep qmail alias addresses current: # http://www.netdevice.com/qmail/patch/qaset-06-script # Users run ~/qtool-06.script to add, remove or list aliases. # Messages will be accepted for postmaster, and for postmaster at # domains listed in rcpthosts, and delivered to the user # contained in the relevant file in /var/qmail/alias/. # Directories in /var/qmail/stage/ have permissions of 777. # Usage: * * * * * /scripts/qaset-06.script >/dev/null 2>&1 # Author: Eben Pratt, goodrcptto at netdevice dot com # 2003-09-02 01: Original version. # 2003-10-04 02: Added support for protected accept client addresses. # User to domain mapping is contained in the staged alias file. # 2003-11-07 03: Accept address of postmaster without @ sign and domain, per # RFC2821 4.5.1 Minimum Implementation. # 2004-05-16 05: No changes from 03, matched version with qtool-05.script. # 2004-09-28 06: No changes from 05, matched version with qtool-06.script. EGR='/bin/egrep -v' ALI='/var/qmail/alias' NOR='/var/qmail/stage/normal' PRO='/var/qmail/stage/protected' MOR='/var/qmail/control/moregoodrcptto' GOO='/var/qmail/control/protectedgood' DEF="^postmaster$|^mailer-daemon$|^root$" for LIN in `/bin/ls ${NOR}/.qmail-* | /bin/cut -d- -f2-` do if [[ ! -e ${ALI}/.qmail-${LIN} ]] then /bin/cat ${NOR}/.qmail-${LIN} | /bin/cut -d@ -f1 > ${ALI}/.qmail-${LIN} SET=1 fi done for LIN in `/bin/ls ${PRO}/.qmail-* | /bin/cut -d- -f2-` do if [[ ! -e ${ALI}/.qmail-${LIN} ]] then /bin/cat ${PRO}/.qmail-${LIN} | /bin/cut -d@ -f1 > ${ALI}/.qmail-${LIN} SET=1 fi done for LIN in `/bin/ls ${ALI}/.qmail-* | /bin/cut -d- -f2-` do if [[ ! -e ${NOR}/.qmail-${LIN} ]] && [[ ! -e ${PRO}/.qmail-${LIN} ]] then /bin/rm ${ALI}/.qmail-${LIN} SET=1 fi done if [[ ${SET} -eq 1 ]] then echo postmaster > ${MOR}.tem for LIN in `/bin/cat /var/qmail/control/rcpthosts` do echo postmaster@${LIN} >> ${MOR}.tem done for LIN in `/bin/ls ${ALI}/.qmail-* | /bin/cut -d- -f2- | ${EGR} ${DEF}` do if [[ ! -e ${PRO}/.qmail-${LIN} ]] then DOM=`/bin/cat ${NOR}/.qmail-${LIN} | /bin/cut -d@ -f2` echo ${LIN}@${DOM} | /bin/tr : . >> ${MOR}.tem fi done /bin/mv ${MOR}.tem ${MOR} /var/qmail/bin/qmail-newmgrt if [[ -e ${GOO}.tem ]] then /bin/rm ${GOO}.tem fi for LIN in `/bin/ls ${PRO}/.qmail-* | /bin/cut -d- -f2-` do DOM=`/bin/cat ${PRO}/.qmail-${LIN} | /bin/cut -d@ -f2` echo ${LIN}@${DOM} | /bin/tr : . >> ${GOO}.tem done /bin/mv ${GOO}.tem ${GOO} fi |