Rubber-stamped by Brady Eidson.
[webbrowser.git] / BugsSite / contrib / yp_nomail.sh
blob961916cd86ab85d11bb4838c21b09bbd5971f181
1 #!/bin/sh
2 # -*- Mode: ksh -*-
3 ##############################################################################
4 # $Id$
5 # yp_nomail
7 # Our mail admins got annoyed when bugzilla kept sending email
8 # to people who'd had bugzilla entries and left the company. They
9 # were no longer in the list of valid email users so it'd bounce.
10 # Maintaining the 'data/nomail' file was a pain. Luckily, our UNIX
11 # admins list all the users that ever were, but the people who've left
12 # have a distinct marker in their password file. For example:
14 # fired:*LK*:2053:1010:You're Fired Dude:/home/loser:/bin/false
16 # This script takes advantage of the "*LK*" convention seen via
17 # ypcat passwd and dumps those people into the nomail file. Any
18 # manual additions are kept in a "nomail.(domainname)" file and
19 # appended to the list of yp lockouts every night via Cron
21 # 58 23 * * * /export/bugzilla/contrib/yp_nomail.sh > /dev/null 2>&1
23 # Tak ( Mark Takacs ) 08/2000
25 # XXX: Maybe should crosscheck w/bugzilla users?
26 ##############################################################################
28 ####
29 # Configure this section to suite yer installation
30 ####
32 DOMAIN=`domainname`
33 MOZILLA_HOME="/export/mozilla"
34 BUGZILLA_HOME="${MOZILLA_HOME}/bugzilla"
35 NOMAIL_DIR="${BUGZILLA_HOME}/data"
36 NOMAIL="${NOMAIL_DIR}/nomail"
37 NOMAIL_ETIME="${NOMAIL}.${DOMAIN}"
38 NOMAIL_YP="${NOMAIL}.yp"
39 FIRED_FLAG="\*LK\*"
41 YPCAT="/usr/bin/ypcat"
42 GREP="/usr/bin/grep"
43 SORT="/usr/bin/sort"
45 ########################## no more config needed #################
47 # This dir comes w/Bugzilla. WAY too paranoid
48 if [ ! -d ${NOMAIL_DIR} ] ; then
49 echo "Creating $date_dir"
50 mkdir -p ${NOMAIL_DIR}
54 # Do some (more) paranoid checking
56 touch ${NOMAIL}
57 if [ ! -w ${NOMAIL} ] ; then
58 echo "Can't write nomail file: ${NOMAIL} -- exiting"
59 exit
61 if [ ! -r ${NOMAIL_ETIME} ] ; then
62 echo "Can't access custom nomail file: ${NOMAIL_ETIME} -- skipping"
63 NOMAIL_ETIME=""
67 # add all the people with '*LK*' password to the nomail list
68 # XXX: maybe I should customize the *LK* string. Doh.
71 LOCKOUT=`$YPCAT passwd | $GREP "${FIRED_FLAG}" | cut -d: -f1 | sort > ${NOMAIL_YP}`
72 `cat ${NOMAIL_YP} ${NOMAIL_ETIME} > ${NOMAIL}`
74 exit
77 # end