From bf47e85a79a4c8df53fcdb649831c1f6cf8db689 Mon Sep 17 00:00:00 2001 From: stransky Date: Sat, 27 Apr 2002 18:35:00 +0200 Subject: [PATCH] V2 : utilisation de control cancel et supersede via telnet darcs-hash:20020427163500-a279a-dab6aba6168a995a1ecbc009bb56d9e81c0bd0ea.gz --- news-cancel | 61 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/news-cancel b/news-cancel index fceadfea..6691019a 100755 --- a/news-cancel +++ b/news-cancel @@ -6,11 +6,14 @@ ## Login stransky ## ## 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,37 +52,42 @@ 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 '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 '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 } - - + + if [ $UID -eq 0 ] then case $1 in @@ -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"