V2 : utilisation de control cancel et supersede via telnet

darcs-hash:20020427163500-a279a-dab6aba6168a995a1ecbc009bb56d9e81c0bd0ea.gz
This commit is contained in:
stransky 2002-04-27 18:35:00 +02:00
parent d13748dc17
commit bf47e85a79

View file

@ -6,11 +6,14 @@
## Login stransky <stransky@crans.org>
##
## Started on dim 13 jan 2002 02:30:56 CET Nicolas STRANSKY
## Last update mer 03 avr 2002 23:15:46 CEST Nicolas STRANSKY
## Last update sam 27 avr 2002 00:56:25 CEST Nicolas STRANSKY
##
## Script pour annuler ou modérer un message de news.
#
# TODO : implémenter la possibilité de définir le message par un NG et un numéro.
##
## V 1.0 : utilisation de la commande ctlinnd cancel.
## V 2.0 : utilisation des commandes control cancel et supersede pour assurer
## la propagation des modifications effectuées.
if [[ "${ORIG_LOGNAME-$SUDO_USER}" = "" ]]
then moderateur=`who am i | awk '{print $1}'`
@ -18,6 +21,9 @@ if [[ "${ORIG_LOGNAME-$SUDO_USER}" = "" ]]
fi
groupe=adm
tempF=$(tempfile -d /tmp -p "news-cancel")
tempF2=$(tempfile -d /tmp -p "news-cancel-commentaire")
tempF3=$(tempfile -d /tmp -p "news-cancel-message")
VERIF () {
ligne=`grep --binary-files=text " $1 " /var/spool/news/overview/OV1 | head -n 1 | awk -F "\t" '{print $1"~"$2"~"$3"~"$9}'`
@ -46,33 +52,38 @@ SAUVEGARDE () {
sleep 1
rep=`echo $newsgroup | sed 's/\./\//g'`
cp /var/spool/news/articles/$rep/$numero /root/moderes/$newsgroup'.'$numero.nws
echo "$1 de $newsgroup.$numero" > /tmp/news-cancel1.txt
echo " " >> /tmp/news-cancel1.txt
echo "modérateur : $moderateur" >> /tmp/news-cancel1.txt
echo "commentaires : " > /tmp/news-cancel-commentaires.txt
chown $moderateur.$groupe /tmp/news-cancel-commentaires.txt
/bin/su $moderateur -c "$EDITOR /tmp/news-cancel-commentaires.txt"
cat /tmp/news-cancel-commentaires.txt >> /tmp/news-cancel1.txt
cat /tmp/news-cancel1.txt | mutt -nx -a /root/moderes/$newsgroup'.'$numero.nws -s "moderation de $newsgroup.$numero par $moderateur" moderateurs
rm -f /tmp/news-cancel*
echo "$1 de $newsgroup.$numero" > $tempF
echo " " >> $tempF
echo "modérateur : $moderateur" >> $tempF
echo "commentaires : " > $tempF2
chown $moderateur.$groupe $tempF2
/bin/su $moderateur -c "$EDITOR $tempF2"
cat $tempF2 >> $tempF
echo "Envoi du mail aux modérateurs..."
cat $tempF | mutt -nx -a /root/moderes/$newsgroup'.'$numero.nws -s "moderation de $newsgroup.$numero par $moderateur" moderateurs@crans.org
rm -f $tempF $tempF2
echo " "
}
EDITION () {
chown $moderateur.$groupe /var/spool/news/articles/$rep/$numero
/bin/su $moderateur -c "$EDITOR /var/spool/news/articles/$rep/$numero"
cp /var/spool/news/articles/$rep/$numero $tempF3
chown $moderateur.$groupe $tempF3
/bin/su $moderateur -c "$EDITOR $tempF3"
(sleep 1 ; echo "mode reader" ; sleep 1 ; echo "group $newsgroup" ; sleep 1 ; echo post ; sleep 1 ; echo "Supersedes: $1" ; cat $tempF3 | egrep -v "^Message-ID:|^NNTP-Posting|^Path:|^X-Trace:|^X-Complaints-To:|^Xref:" ; echo '.' ; sleep 1 ; echo quit) | nc 138.231.136.6 119
rm -f $tempF3
}
CANCEL () {
echo -n 'throttling inn... '
/bin/su news -c "/usr/lib/news/bin/ctlinnd throttle 'article canceling'"
echo "canceling article $1"
/bin/su news -c "/usr/lib/news/bin/ctlinnd cancel $1"
echo -n 'starting inn... '
/bin/su news -c "/usr/lib/news/bin/ctlinnd go ''"
# echo -n 'throttling inn... '
# /bin/su news -c "/usr/lib/news/bin/ctlinnd throttle 'article canceling'"
# echo "canceling article $1"
# /bin/su news -c "/usr/lib/news/bin/ctlinnd cancel $1"
#
# echo -n 'starting inn... '
# /bin/su news -c "/usr/lib/news/bin/ctlinnd go ''"
(sleep 1 ; echo "mode reader" ; sleep 1 ; echo "group $newsgroup" ; sleep 1 ; echo post ; sleep 1 ; echo "Control: cancel $1" ; echo "From: $moderateur@crans.org" ; echo "Subject: Moderation" ; echo "Newsgroups: $newsgroup" ; echo -e "\n" ; echo "This post has been moderated with news-cancel." ; echo '.' ; sleep 1 ; echo quit) | nc 138.231.136.6 119
}
@ -87,11 +98,11 @@ then
case $action in
e*|E*)
SAUVEGARDE Edition
EDITION
EDITION $1
;;
a*|A*)
SAUVEGARDE Annulation
CANCEL \'$1\'
CANCEL $1
;;
*)
echo "attention, il n'y a eu ni édition ni annulation. relancer le script"