#!/bin/ksh ## ## SCRIPT: chk_aliases4varmail ## Where : in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ##################################################################### ## PURPOSE: Checks /var/mail/$USER files on sgia and compares to the ## userids in the sgia:/etc/aliases file. Provides a list of ## userids in /var/mail filenames BUT NOT IN /etc/aliases. ## ##################################################################### ## CALL FORMAT: feamain -> office_utils.menu -> mailhelp.menu ## (or manually) ## ##################################################################### ## MAINTENANCE HISTORY: ## Written by : B. Montandon 19Oct98 ## Last Update: B. Montandon 30Jul90 Updated report heading. ## ##################################################################### if test ! "`hostname`" = "sgia" then echo " This 'chk_aliases4varmail' utilitiy should be run on 'sgia'. Exiting ... " exit fi ####################################################################### ## Prep OUTLIST filename ####################################################################### if test "$FEDIR" = "" then export FEDIR=/apps/nns_com/fea fi . $FEDIR/scripts/set_localoutlist ####################################################################### ## Prep heading of $OUTLIST report ####################################################################### echo "\ ************** `date` ************************ Check of difference between - userids in the 1st column of the 'sgia' /etc/aliases file and - userids in /var/mail/ directories. Following is a list of userids in /var/mail/ directories but NOT IN the 'sgia' /etc/aliases file. This list is generated by the script $FEDIR/scripts/chk_aliases4varmail Can be run via nnsFEAmenu option 'u o h ca' (Utilities, Office, Help, CheckAliases) --------------------------------------------------------------------- " > $OUTLIST ####################################################################### ## Prep list of userids from /var/mail directory ####################################################################### ls -1 /var/mail | egrep -v 'partials|saved' > ${OUTLIST}_varmail_userids ####################################################################### ## Prep list of userids from /usr/people directory ####################################################################### # ls -1 /usr/people > ${OUTLIST}_usrpeople_userids ####################################################################### ## Prep list of userids from /etc/aliases file ####################################################################### cut -d: -f1 /etc/aliases > ${OUTLIST}_etcalias_userids ####################################################################### ## Prep difference of userids from /var/mail and from /etc/aliases file ####################################################################### # diff ${OUTLIST}_varmail_userids ${OUTLIST}_etcalias_userids | \ # grep '>' > ${OUTLIST}_etcalias_NOTIN_varmail diff ${OUTLIST}_varmail_userids ${OUTLIST}_etcalias_userids | \ grep '<' >> $OUTLIST # grep '<' >> ${OUTLIST}_varmail_NOTIN_etcalias ####################################################################### ## Some sample code from chk_varmail -- might be useful ####################################################################### # ls -l /var/mail 2> /dev/null \ # | grep -v '^d' \ # | awk '{ if ( NF != 9 ) {print # continue } # ## ## Statements like this can be used to skip special files/directories : # # if ( $9 ~ ".partial" ) { # # continue } # ## ## For Testing /var/mail/whatever* : # # userchek = substr($9,11,20) # # # userchek = $9 # # if ( $3 !~ userchek ) printf ("%10s owns '/var/mail' FILE %20s \n", $3, $9) # ## For testing: # # printf ("%20s %20s \n", userchek, $3) # # }' >> $OUTLIST ####################################################################### ## SHOW THE REPORT FILE ####################################################################### $FEDIR/scripts/shofil $OUTLIST # set -