chiark / gitweb /
Commit 2.4.5-5 as unpacked
[inn-innduct.git] / control / docheckgroups.in
1 #! /bin/sh
2 # fixscript will replace this line with code to load innshellvars
3
4 ##  $Revision: 7743 $
5 ##  Script to execute checkgroups text; results to stdout.
6
7 T=${TMPDIR}
8
9 cat /dev/null >${T}/$$out
10
11 ##  Copy the article without headers, append local newsgroups.
12 cat >${T}/$$msg
13 test -f ${LOCALGROUPS} && cat ${LOCALGROUPS} >>${T}/$$msg
14
15 ##  Get the top-level newsgroup names from the message and turn it into
16 ##  an egrep pattern.
17 PATS=`${SED} <${T}/$$msg \
18         -e 's/[         ].*//' -e 's/\..*//' \
19         -e 's/^!//' -e '/^$/d' \
20         -e 's/^/^/' -e 's/$/[.  ]/' \
21     | sort -u \
22     | (tr '\012' '|' ; echo '' )\
23     | ${SED} -e 's/|$//'`
24
25 ${EGREP} "${PATS}" ${ACTIVE} | ${EGREP} "${1:-.}" | ${SED} 's/ .*//' | sort >${T}/$$active
26 ${EGREP} "${PATS}" ${T}/$$msg | ${EGREP} "${1:-.}" | ${SED} 's/[        ].*//' | sort >${T}/$$newsgrps
27
28 comm -13 ${T}/$$active ${T}/$$newsgrps >${T}/$$missing
29 comm -23 ${T}/$$active ${T}/$$newsgrps >${T}/$$remove
30
31 ${EGREP} "${PATS}" ${ACTIVE} | ${EGREP} "${1:-.}" | ${SED} -n '/ m$/s/ .*//p' | sort >${T}/$$amod.all
32 ${EGREP} "${PATS}" ${T}/$$msg | ${EGREP} "${1:-.}" | ${SED} 's/\r\?$//' |
33 ${SED} -n '/(Moderated)$/s/[    ].*//p' | sort >${T}/$$ng.mod
34
35 comm -12 ${T}/$$missing ${T}/$$ng.mod >${T}/$$add.mod
36 comm -23 ${T}/$$missing ${T}/$$ng.mod >${T}/$$add.unmod
37 cat ${T}/$$add.mod ${T}/$$add.unmod >>${T}/$$add
38
39 comm -23 ${T}/$$amod.all ${T}/$$remove >${T}/$$amod
40 comm -13 ${T}/$$ng.mod ${T}/$$amod >${T}/$$ismod
41 comm -23 ${T}/$$ng.mod ${T}/$$amod >${T}/$$nm.all
42 comm -23 ${T}/$$nm.all ${T}/$$add >${T}/$$notmod
43
44 ${EGREP} "${PATS}" ${NEWSGROUPS} | ${EGREP} "${1:-.}" | ${SED} 's/[     ]\+/    /' | sort >${T}/$$localdesc
45 ${EGREP} "${PATS}" ${T}/$$msg | ${EGREP} "${1:-.}" | ${SED} 's/\r\?$//' |
46 ${SED} 's/[     ]\+/    /' | sort >${T}/$$newdesc
47
48 if ! (head -1 ${T}/$$newdesc | egrep " [[:digit:]]+ [[:digit:]]+ " > /dev/null) ; then
49   comm -13 ${T}/$$localdesc ${T}/$$newdesc >${T}/$$missingdesc
50   comm -23 ${T}/$$localdesc ${T}/$$newdesc >${T}/$$removedesc
51 fi
52
53 if [ -s ${T}/$$remove ] ; then
54     (
55         echo "# The following newsgroups are non-standard."
56         ${SED} "s/^/#   /" ${T}/$$remove
57         echo "# You can remove them by executing the commands:"
58         for i in `cat ${T}/$$remove` ; do
59             echo "      ${PATHBIN}/ctlinnd rmgroup $i"
60             ${EGREP} "^$i       " ${NEWSGROUPS} >>${T}/$$ngdel
61         done
62         echo ''
63     ) >>${T}/$$out
64 fi
65
66 if [ -s ${T}/$$add ] ; then
67     (
68         echo "# The following newsgroups were missing and should be added."
69         ${SED} "s/^/#   /" ${T}/$$add
70         echo "# You can do this by executing the command(s):"
71         for i in `cat ${T}/$$add.unmod` ; do
72             echo "      ${PATHBIN}/ctlinnd newgroup $i y ${FROM}"
73             ${EGREP} "^$i       " ${T}/$$msg >>${T}/$$ngadd
74         done
75         for i in `cat ${T}/$$add.mod` ; do
76             echo "      ${PATHBIN}/ctlinnd newgroup $i m ${FROM}"
77             ${EGREP} "^$i       " ${T}/$$msg >>${T}/$$ngadd
78         done
79         echo ''
80     ) >>${T}/$$out
81 fi
82
83 if [ -s ${T}/$$ismod ] ; then
84     (
85         echo "# The following groups are incorrectly marked as moderated:"
86         ${SED} "s/^/#   /" ${T}/$$ismod
87         echo "# You can correct this by executing the following:"
88         for i in `cat ${T}/$$ismod` ; do
89             echo "      ${PATHBIN}/ctlinnd changegroup $i y"
90             ${EGREP} "^$i       " ${T}/$$msg >>${T}/$$ngchng
91         done
92         echo ''
93     ) >>${T}/$$out
94 fi
95
96 if [ -s ${T}/$$notmod ] ; then
97     (
98         echo "# The following groups are incorrectly marked as unmoderated:"
99         ${SED} "s/^/#   /" ${T}/$$notmod
100         echo "# You can correct this by executing the following:"
101         for i in `cat ${T}/$$notmod` ;do
102             echo "      ${PATHBIN}/ctlinnd changegroup $i m"
103             ${EGREP} "^$i       " ${T}/$$msg >>${T}/$$ngchng
104         done
105         echo ''
106     ) >>${T}/$$out
107 fi
108
109 if [ -s ${T}/$$removedesc ] ; then
110     (
111         echo "# The following newsgroups descriptions are obsolete."
112         ${SED} "s/^/#   /" ${T}/$$removedesc
113         echo "# You can remove them by editing ${NEWSGROUPS}."
114         echo ''
115     ) >>${T}/$$out
116 fi
117
118 if [ -s ${T}/$$missingdesc ] ; then
119     (
120         echo "# The following newsgroups descriptions were missing and should be added."
121         ${SED} "s/^/#   /" ${T}/$$missingdesc
122         echo "# You can add them by editing ${NEWSGROUPS}."
123         echo ''
124     ) >>${T}/$$out
125 fi
126
127
128 test -s ${T}/$$out && {
129     cat ${T}/$$out
130     echo 'exit # so you can feed this message into the shell'
131     echo "# And remember to update ${NEWSGROUPS}."
132     test -s ${T}/$$ngdel && {
133         echo "# Remove these lines:"
134         ${SED} "s/^/#   /" ${T}/$$ngdel
135         echo ''
136     }
137     test -s ${T}/$$ngadd && {
138         echo "# Add these lines:"
139         ${SED} "s/^/#   /" ${T}/$$ngadd
140         echo ''
141     }
142     test -s ${T}/$$ngchng && {
143         echo "# Change these lines:"
144         ${SED} "s/^/#   /" ${T}/$$ngchng
145         echo ''
146     }
147 }
148
149 rm -f ${T}/$$*