home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
2
/
2660
/
checkgroups
next >
Wrap
Text File
|
1991-02-04
|
4KB
|
152 lines
#! /bin/sh
: check active file for missing or extra newsgroups
: '@(#)checkgroups 1.25 1/15/89'
. ${NEWSCONFIG-/usenet/bin.server/config}
if test ! -s $NEWSCTL/newsgroups
then
cp /dev/null $NEWSCTL/newsgroups
fi
echo "" >/tmp/$$out
# Read first line of stdin. If of the form "-n group", then only check
# for the specified group. Otherwise, assume doing standard groups
sed -e "/^From: /w /tmp/$$out" -e '/^[a-zA-Z-]*: /d' -e '/^$/d' -e '/^[#:]/d' | (
read line
case "${line}" in
-n*)
# Doing specific group. extract group name and preserve
# all of current newsgroups file except for that group.
# Then append entries for this group.
group=`echo "x${line}" | sed -e 's/x-n /^/' -e 's/$/[. ]/'`
egrep -v "${group}" $NEWSCTL/newsgroups > /tmp/$$a
cat /tmp/$$a - > $NEWSCTL/newsgroups
;;
*)
# Get the distributions from the checkgroups message itself
# This allows sites to append their local groups to the distributed
# checkgroups message and prevents stray checkgroups from other sites
# from showing all the local groups as being bad groups.
#
echo "${line}" > /tmp/$$msg
cat >> /tmp/$$msg
cp /dev/null /tmp/$$b
pipe=''
sed -e "s;[ ].*;;" -e "s;\..*;;" -e "s;^!;;" /tmp/$$msg | sort -u |
while read dist
do
group=`cat /tmp/$$b`
group="${group}${pipe}^$dist[. ]"
echo "${group}" > /tmp/$$b
pipe='|'
done
group=`cat /tmp/$$b`
egrep -v "${group}" $NEWSCTL/newsgroups > /tmp/$$a
cat /tmp/$$a > $NEWSCTL/newsgroups
sed -e "/^!/d" /tmp/$$msg >> $NEWSCTL/newsgroups
rm -f /tmp/$$b /tmp/$$msg
;;
esac
egrep "${group}" $NEWSCTL/active | sed 's/ .*//' | sort >/tmp/$$active
egrep "${group}" $NEWSCTL/newsgroups | sed 's/[ ].*//' | sort >/tmp/$$newsgrps
comm -13 /tmp/$$active /tmp/$$newsgrps >/tmp/$$missing
comm -23 /tmp/$$active /tmp/$$newsgrps >/tmp/$$remove
egrep "${group}" $NEWSCTL/active | sed -n "/m\$/s/ .*//p" |
sort > /tmp/$$amod.all
egrep "${group}" $NEWSCTL/newsgroups |
sed -n "/Moderated/s/[ ][ ]*.*//p" | sort > /tmp/$$ng.mod
comm -12 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.mod
comm -23 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.unmod
cat /tmp/$$add.mod /tmp/$$add.unmod >>/tmp/$$add
comm -23 /tmp/$$amod.all /tmp/$$remove >/tmp/$$amod
comm -13 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$ismod
comm -23 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$nm.all
comm -23 /tmp/$$nm.all /tmp/$$add >/tmp/$$notmod
echo "" >>/tmp/$$out
if test -s /tmp/$$remove
then
(
echo "# The following newsgroups are non-standard."
sed "s/^/# /" /tmp/$$remove
echo ""
#echo "# You can remove them by executing the commands:"
#for i in `cat /tmp/$$remove`
#do
# echo " /usr/lib/news/rmgroup $i"
#done
#echo ""
) 2>&1 >>/tmp/$$out
fi
if test -s /tmp/$$add
then
(
echo "# The following newsgroups were missing and should be added."
sed "s/^/# /" /tmp/$$add
echo ""
#echo "# You can do this by executing the command(s):"
#for i in `cat /tmp/$$add.unmod`
#do
# echo '/usr/lib/news/inews -C '$i' </dev/null'
#done
#for i in `cat /tmp/$$add.mod`
#do
# echo '/usr/lib/news/inews -C '$i' moderated </dev/null'
#done
#echo ""
) 2>&1 >>/tmp/$$out
fi
if test -s /tmp/$$ismod
then
(
echo "# The following newsgroups are not moderated and are marked moderated."
sed "s/^/# /" /tmp/$$ismod
echo ""
#echo "# You can correct this by executing the command(s):"
#for i in `cat /tmp/$$ismod`
#do
# echo '/usr/lib/news/inews -C '$i' </dev/null'
#done
#echo ""
) 2>&1 >>/tmp/$$out
fi
if test -s /tmp/$$notmod
then
(
echo "# The following newsgroups are moderated and not marked so."
sed "s/^/# /" /tmp/$$notmod
echo ""
#echo "# You can correct this by executing the command(s):"
#for i in `cat /tmp/$$notmod`
#do
# echo '/usr/lib/news/inews -C '$i' moderated </dev/null'
#done
#echo ""
) 2>&1 >>/tmp/$$out
fi
if test -s /tmp/$$out
then
(echo "Subject: Problems with your active file"
echo ""
cat /tmp/$$out
) | if test $# -gt 0
then
PATH=/bin:$PATH
mail $1
else
cat
fi
fi
)
rm -f /tmp/$$*