#! /bin/sh : # Copyright (c) 1993-1996, S.R. van den Berg, The Netherlands #$Id: unsubscribe,v 1.31 1996/12/21 03:28:12 srb Exp $ test=test # /bin/test echo=echo # /bin/echo cat=cat # /bin/cat sed=sed # /bin/sed expr=expr # /bin/expr date=date # /bin/date grep=grep # /usr/bin/grep formail=formail # /usr/local/bin/formail multigram=multigram # ../.bin/multigram $test -z "$listaddr" && $echo "Don't start this script directly, it is used in rc.request" && exit 64 tmprequest=tmp.request tmpfrom=tmp.from unsubscribetxt=unsubscribe.txt dist=dist case "$X_ENVELOPE_TO" in *$list-request*) wrongaddress="" ;; *) wrongaddress="WARNING: Please try to use '$listreq' the next time when issuing (un)subscribe requests. " ;; esac remov=-d $test "X$1" = "X-D" && remov=-D $grep '^Subject: Re:' <$tmprequest >/dev/null && wrongaddress="${wrongaddress}WARNING: Send in a new mail, INSTEAD OF REPLYING the next time when issuing (un)subscribe requests. " $formail -i"From: $listreq" -rtA"X-Loop: $listaddr" -I"Precedence: junk" \ <$tmprequest $test ! -z "$wrongaddress" && $echo "$wrongaddress" && wrongaddress="" fromaddr=`$cat $tmpfrom` remtext=` if $multigram -b1 -l$off_threshold -x$listreq -x$listaddr $remov $dist \ 2>/dev/null then $echo "" $echo "You have been removed from the list." else $echo "You have not been removed, I couldn't find your name on the list." if test ! -z "$unsub_assist" -a 0 != "$unsub_assist" then $echo "What I did find were the following approximate matches:" $echo "" $multigram -m -b$unsub_assist -l-32767 -x$listreq -x$listaddr $dist \ <$tmprequest $echo "" $echo "If you recognise one of these addresses as being the one you" $echo "wanted to unsubscribe, send in a new unsubscribe request" $echo "containing the text: unsubscribe the_address_you_meant." fi fi` $echo "$remtext" | $sed -e '1 s/^ *[0-9]* [^ ]* \(.*\)$/\1/' \ -e '2 s/^Removed: \(.*\)$/\1/w '$tmpfrom echo "X$remtext.X" >>$subscribe_log if $test ! -z "$subscribe_log" then case "$remtext" in *You\ have\ been\ removed*) $echo "unsubscribe: `$echo \"$remtext\" | $sed -e '2,$d'` by: $fromaddr `$date`" ;; *) $echo "unsubscribe: attempt `$multigram -b1 -l0 -x$listreq -x$listaddr \ $dist <$tmprequest` by: $fromaddr `$date`" ;; esac >>$subscribe_log fi $echo "$fromaddr" >>$tmpfrom $echo "" $cat $unsubscribetxt $sed -e 's/^/>/' $tmprequest