File: mkmailpost.sh

package info (click to toggle)
newsgate 1.6-12
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 332 kB
  • ctags: 313
  • sloc: ansic: 2,693; yacc: 499; sh: 278; lex: 183; perl: 151; makefile: 113
file content (54 lines) | stat: -rw-r--r-- 1,231 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
#! /bin/sh
##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/mkmailpost.sh,v 1.4 91/02/12 14:49:26 rsalz Exp Locker: rsalz $
##  Script to make a set of "mailpost" commands for all groups in
##  the news active file.
##  Usage:
##	makemailpost [news active file [mail2newspath] ]

case $# in
[012])
    ;;
*)
    echo "Usage: `basename $0` [activefile [mail2newspath] ]" 1>&2
    exit 1
    ;;
esac

ACTIVE=${1-/var/lib/news/active}
if [ ! -f ${ACTIVE} ] ; then
    echo "`basename $0`:  Can't read input ${ACTIVE}." 1>&2
    exit 1
fi

##  Write the prolog.
echo "/*"
echo "**  Generated from ${ACTIVE}"
echo "**  by `whoami` on `date`"
echo "*/"
if [ "$2" != "" ] ; then
    echo 'default mail2news "'$2'";'
fi

trap "rm -f /tmp/mmp$$ ; exit 1" 1 2 3 15

##  Create the sed temporary file and run it
cat >/tmp/mmp$$ <<\EOF
/# Delete moderated groups/d
/m$/d
/# Trim anything after the first field/d
s/ .*$//
/# Delete control, junk, site-specific/d
/^control$/d
/^junk$/d
/^to\./d
/# Delete test groups and announce, assuming the latter is moderated/d
/\<test\>/d
/\<announce\>/d
/# Turn the line "foo" into "mailpost foo;"/d
s/^.*$/mailpost &;/
EOF

##  Run sed, clean up.
sed -f /tmp/mmp$$ <${ACTIVE} | sort

rm -f /tmp/mmp$$