home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / listserv5.31 / part01 / peer < prev    next >
Encoding:
Text File  |  1991-12-12  |  1.8 KB  |  66 lines

  1. #!/bin/sh
  2. # Shell script to add a peer list to a discussion list. 
  3. #
  4. # Usage: peer <LIST_ALIAS> <remote alias> <remote peer email address> 
  5. #          <remote peer listserv email address>
  6. # where:
  7. # LIST_ALIAS: a local list alias, capitalized, that is to be connected to
  8. #  the new peer.
  9. # remote alias: the peer's list alias on the remote machine
  10. # remote peer email address: full email address of the peer list to be added
  11. # remote peer listserv email address: full email address of the server
  12. #   that handles the remote peer.
  13.  
  14. PROG=`basename $0`
  15. if [ $# -lt 4 ]; then
  16.   echo Usage: $PROG \<LIST_ALIAS\> \<remote alias\> \
  17. \<remote $PROG email address\> \<remote $PROG listserv email address\>
  18.   exit 1
  19. fi
  20.  
  21. ARGS=$PROG\ $*
  22. DIR=/usr/server/lists/`echo $1 | tr '[a-z]' '[A-Z]'`
  23. REMOTE_ALIAS=`echo $2 | tr '[A-Z]' '[a-z]'`
  24. EMAIL=`echo $3 | tr '[A-Z]' '[a-z]'`
  25. REMOTE_SERVER=`echo $4 | tr '[A-Z]' '[a-z]'`
  26. REPORT=/usr/server/.report.server
  27. CONFIG=/usr/server/config
  28. MODE=NOACK
  29. FILE=$DIR/.peers
  30. shift; shift; shift; shift
  31.  
  32. if [ ! -d $DIR ]; then
  33.   echo $DIR: no such list
  34.   exit 2
  35. fi
  36. if [ ! -r $CONFIG ]; then
  37.   echo Cannot open $CONFIG
  38.   exit 2
  39. fi
  40. if [ ! -r $FILE ]; then
  41.   echo Cannot open $FILE
  42.   exit 2
  43. fi
  44.  
  45. echo >> $REPORT
  46. echo --- NEW MAIL HAS ARRIVED --- >> $REPORT
  47. echo $ARGS >> $REPORT
  48. LOCAL=`grep -i "^list *$REMOTE_ALIAS *$EMAIL" $CONFIG | awk '{ print $2 }'`
  49. if [ "$LOCAL" = "" ]; then
  50.   LOCAL=`grep -i "^server\  *$EMAIL" $CONFIG | awk '{ print $2 }'`
  51.   txt=server
  52. else
  53.   txt=list
  54. fi
  55. if [ "$LOCAL" != "" ]; then
  56.   echo Cannot add local $txt $LOCAL as $PROG to $FILE >&1 | tee -a $REPORT
  57. else
  58.   if [ "`grep -i $EMAIL $FILE`" != "" ]; then
  59.     echo $EMAIL\: Already subscribed as a $PROG in $FILE >&1 | tee -a $REPORT
  60.   else
  61.     echo $EMAIL $MODE $REMOTE_ALIAS $REMOTE_SERVER >> $FILE
  62.   fi
  63. fi
  64. echo Time/Date: `date` >> $REPORT
  65. exit 0
  66.