1 Date: Thu, 26 Nov 1998 09:39:52 +0000
2 From: David M Walker <davidw@datamgmt.com>
4 Thanks to Philip and others I now have my ISP style config built and
5 therefore am posting the final configuration fragments to the list in
6 case anyone else wants to do a similar thing.
8 Date: Mon, 26 Jul 1999 00:02:14 +0100
9 From: David M Walker <davidw@datamgmt.com>
11 Some time ago I posted ISP nstyle configuration C011 and continue
12 to get mails of the form:
14 > But can you please explain me how do the clients get their
15 > email if it's placed in many directories and the password
16 > are stored in "private" passwd files. The popper is not able
17 > to understand it. What approach do you use?
19 The way I approach this is described after the configuration.
22 ######################################################################
24 # This configuration fragment is for use with an ISP type solution
25 # Each client has their own directory that contains their own
26 # editable passwd, alias etc type files. Furthemore if they create
27 # a local user then that user can also have a a .forward file and/or
30 # Files and Directories
31 # Password file for a domain
32 # /clients/${domain}/etc/passwd
33 # Alias file for a domain
34 # /clients/${domain}/etc/aliases
35 # Directory where users mail for a domain is stored
36 # /clients/${domain}/mail/
37 # Location of file with a list of domains
38 # /clients/utils/data/domains
40 ######################################################################
41 # TRANPORTS CONFIGURATION #
42 ######################################################################
44 # This transport is used for local delivery to user mailboxes.
46 virtual_localdelivery:
48 file = /clients/${domain}/mail/${local_part}
49 user = ${lookup{$local_part}lsearch{/etc/passwd}{$value}{exim}}
53 # This transport is used to handly autoreplys
57 from = $local_part@$domain
59 subject = "Reply re: $header_subject:"
61 "${extract{5}{:}{${expand:${lookup{$local_part}lsearch{/clients/${domain}/etc/passwd}{$value}}}}}/.autoreply"
64 # This transport is used for handling pipe addresses generated by alias
71 # This transport is used for handling file addresses generated by alias
77 # This transport is used for handling file addresses generated by alias
78 # or .forward files if the path ends in "/".
86 # This transport is used for handling autoreplies generated by the
88 # option of the forwardfile director.
93 # This transport is used for delivering messages over SMTP connections.
102 ######################################################################
103 # DIRECTORS CONFIGURATION #
104 ######################################################################
106 # Handles .autoreply files
110 transport = auto_transport
112 root:${extract{5}{:}{${expand:${lookup{$local_part}lsearch{/clients/${domain}/etc/passwd}{$value}}}}}/.autoreply
113 condition = ${if eq{$sender_address}{}{no}{yes}}
116 # Handles any .forward files
120 check_local_user = false
122 "${extract{5}{:}{${expand:${lookup{$local_part}lsearch{/clients/${domain}/etc/passwd}{$value}}}}}"
125 "${extract{5}{:}{${expand:${lookup{$local_part}lsearch{/clients/${domain}/etc/passwd}{$value}}}}}/.forward"
131 # This director matches local user mailboxes.
135 transport = virtual_localdelivery
136 domains = lsearch;/clients/utils/data/domains
137 file = /clients/${domain}/etc/passwd
138 search_type = lsearch
140 # This director matches anything in the aliases
144 domains = lsearch;/clients/utils/data/domains
145 file = /clients/${domain}/etc/aliases
146 search_type = lsearch*
147 qualify_preserve_domain
150 ######################################################################
153 Our domains each have a unique last number from their IP address
154 in the form x.y.z.222 etc. but a simple serial number would do.
155 We prefix this domain number with an 'm' because it's a bad thing
156 to create a username that starts with a digit. The 'm' stands for
157 nothing special - originally I think it meant mail.
159 As a result we get a username of the form m222.dwalker
161 We now use the shell script below to create the user, setup
162 symbolic links from /var/spool/mail/m222.dwalker to the user's
163 account directory etc. This is either called from a web page via
166 Therefore mail sent to dwalker@datamgmt.com will be accessable
167 from a pop or imap account called m222.dwalker and uniqueness
168 across multiple domains is preserved.
173 PATH=${PATH}:/usr/sbin; export PATH
175 # General Configuration
176 export PROGNAME=`basename $0`
178 export SHELL=/bin/false
179 export SYSPASS=/etc/passwd
180 export SYSSHAD=/etc/shadow
199 if [ "${ESTATUS}" != 0 ]
201 echo "Command exited with non-zero value (${ESTATUS})"
204 echo "Command successful"
210 DOMUID=$(id -u ${USER})
212 . getdomain ${DOMGRP}
215 DOMROOT=/monza/clients/${DOMAIN}
216 POPUSER=${PREFIX}${DOMUID}.${DOMUSER}
218 DOMPASS=${DOMROOT}/etc/passwd
219 HOMEDIR=${DOMROOT}/users/${DOMUSER}
220 MAILBOX=${DOMROOT}/mail/${DOMUSER}
221 MAILLNK=/var/spool/mail/${POPUSER}
226 STRNGTST=`grep "^${POPUSER}:" ${SYSPASS}`
227 if [ -z "${STRNGTST}" ]
229 echo "Making ${SYSPASS} entry"
230 useradd -u ${DOMUID} -g ${DOMGRP} -d ${HOMEDIR} -s ${SHELL} -m -n ${POPUSER}
232 #echo "${POPUSER}:x:${DOMUID}:${POPGID}::${HOMEDIR}:${SHELL}" >> ${SYSPASS}
234 echo "User ${POPUSER} already in ${SYSPASS}"
240 STRNGTST=`grep "^${DOMUSER}:" ${DOMPASS}`
241 if [ -z "${STRNGTST}" ]
243 echo "Making ${DOMPASS} entry"
244 echo "${DOMUSER}:x:${DOMUID}:${DOMGID}::${HOMEDIR}:" >> ${DOMPASS}
246 echo "User ${DOMUSER} already in ${DOMPASS}"
252 if [ ! -e ${HOMEDIR}/mail ]
254 echo "Making ${HOMEDIR}/mail"
255 mkdir ${HOMEDIR}/mail
257 echo "Setting permissions on ${HOMEDIR}"
258 chown ${DOMUID}:${DOMGID} ${HOMEDIR}
265 if [ ! -e ${MAILBOX} ]
267 echo "Creating empty mailbox"
271 echo "Setting ownership"
272 chown ${DOMUID}.mail ${MAILBOX}
274 echo "Setting permissions"
285 echo "Removing old link"
289 echo "${MAILLNK} is not a link - moving to .old"
290 mv ${MAILLNK} ${MAILLNK}.old
302 echo "Removing old link"
306 echo "File ${MAILLNK} exists moving to .old"
307 mv ${MAILLNK} ${MAILLNK}.old
311 echo "Creating a new link"
312 ln -s ${MAILBOX} ${MAILLNK}
318 echo "Set password for ${DOMUSER}"
329 echo "Pop account deleted for ${POPUSER}"
330 echo "Files in the domain user and mail directories must be deleted manually"
331 echo "The entry in the domain passwd file is also redundant"
338 echo "E-Mail Address: ${DOMUSER}@${DOMAIN}"
339 echo "Pop username: ${POPUSER}"
340 echo "Pop password: ********"
341 echo "Inbound mail: mail.${DOMAIN}"
342 echo "Inbound port: 110"
343 echo "Outbound mail: mail.${DOMAIN}"
344 echo "Outbound mail: 25"
369 echo "Usage: ${PROGNAME} -a username [add a user]"
370 echo " ${PROGNAME} -c username [change a users password]"
371 echo " ${PROGNAME} -d username [delete a user]"
372 echo " ${PROGNAME} -l [lists all user]"
374 echo "There is also a -n option to set the prefix to null rather"
375 echo "than m for backward compatiblity with earlier versions"
376 echo "Note: -n must proceed any other parameters"
382 STRNGTST=`grep "^${POPUSER}:" ${SYSPASS}`
383 if [ -n "${STRNGTST}" ]
388 echo "User ${POPUSER} already deleted from ${SYSPASS}"
395 echo "Username\t/etc/passwd\t/etc/shadow\tLocal Password"
396 for POPUSER in `grep "^${PREFIX}${DOMUID}\." ${SYSPASS} | cut -d: -f1 -s`
398 echo "${POPUSER}\tOK\t\t\c"
399 OKS=`grep "^${POPUSER}:" ${SYSSHAD}`
406 DUS=`echo ${POPUSER} | cut -d"." -f2 -s`
407 OKD=`grep "^${DUS}:" ${DOMPASS}`
419 while getopts a:c:d:ln PARAM
438 POPUSER=${PREFIX}${DOMUID}.${DOMUSER}
443 shift $(($OPTIND -1))