File: unsubscribe

package info (click to toggle)
smartlist 3.15-25
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 2,192 kB
  • ctags: 1,837
  • sloc: ansic: 9,239; sh: 4,947; makefile: 145
file content (89 lines) | stat: -rwxr-xr-x 2,479 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /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: SmartList <$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