yp_nomail.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. # -*- Mode: ksh -*-
  3. ##############################################################################
  4. # $Id$
  5. # yp_nomail
  6. #
  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:
  13. #
  14. # fired:*LK*:2053:1010:You're Fired Dude:/home/loser:/bin/false
  15. #
  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
  20. #
  21. # 58 23 * * * /export/bugzilla/contrib/yp_nomail.sh > /dev/null 2>&1
  22. #
  23. # Tak ( Mark Takacs ) 08/2000
  24. #
  25. # XXX: Maybe should crosscheck w/bugzilla users?
  26. ##############################################################################
  27. ####
  28. # Configure this section to suite yer installation
  29. ####
  30. DOMAIN=`domainname`
  31. MOZILLA_HOME="/export/mozilla"
  32. BUGZILLA_HOME="${MOZILLA_HOME}/bugzilla"
  33. NOMAIL_DIR="${BUGZILLA_HOME}/data"
  34. NOMAIL="${NOMAIL_DIR}/nomail"
  35. NOMAIL_ETIME="${NOMAIL}.${DOMAIN}"
  36. NOMAIL_YP="${NOMAIL}.yp"
  37. FIRED_FLAG="\*LK\*"
  38. YPCAT="/usr/bin/ypcat"
  39. GREP="/usr/bin/grep"
  40. SORT="/usr/bin/sort"
  41. ########################## no more config needed #################
  42. # This dir comes w/Bugzilla. WAY too paranoid
  43. if [ ! -d ${NOMAIL_DIR} ] ; then
  44. echo "Creating $date_dir"
  45. mkdir -p ${NOMAIL_DIR}
  46. fi
  47. #
  48. # Do some (more) paranoid checking
  49. #
  50. touch ${NOMAIL}
  51. if [ ! -w ${NOMAIL} ] ; then
  52. echo "Can't write nomail file: ${NOMAIL} -- exiting"
  53. exit
  54. fi
  55. if [ ! -r ${NOMAIL_ETIME} ] ; then
  56. echo "Can't access custom nomail file: ${NOMAIL_ETIME} -- skipping"
  57. NOMAIL_ETIME=""
  58. fi
  59. #
  60. # add all the people with '*LK*' password to the nomail list
  61. # XXX: maybe I should customize the *LK* string. Doh.
  62. #
  63. LOCKOUT=`$YPCAT passwd | $GREP "${FIRED_FLAG}" | cut -d: -f1 | sort > ${NOMAIL_YP}`
  64. `cat ${NOMAIL_YP} ${NOMAIL_ETIME} > ${NOMAIL}`
  65. exit
  66. # end