Nouvelle place
darcs-hash:20051019153736-41617-45b4633b34a628a50f43d9723e706c016fa338da.gz
This commit is contained in:
parent
7c92f6c2b9
commit
90804f0537
3 changed files with 248 additions and 0 deletions
155
news/fix-active
Executable file
155
news/fix-active
Executable file
|
@ -0,0 +1,155 @@
|
|||
#!/bin/sh
|
||||
##
|
||||
## fix-active
|
||||
##
|
||||
## Made by stransky
|
||||
## Login stransky <stransky@crans.org>
|
||||
##
|
||||
## Started on Mon 01 nov 2001 02:40:25 CET stransky
|
||||
## Last update sam 23 nov 2002 19:15:14 CET stransky
|
||||
##
|
||||
#
|
||||
# à utiliser en cas de plantage et de non synchro de /var/lib/news/active.
|
||||
#
|
||||
# V 2.0 :
|
||||
# à lancer tel quel. théoriquement le script s'occuppe de tout.
|
||||
#
|
||||
# V 1.0 :
|
||||
# ctlinnd throttle ''
|
||||
# à ce niveau, il est TRES important de vérifier que l'on ne peut plus poster de messages.
|
||||
# puis il faut vérifier que le fichier active a la bonne syntaxe du début à la fin, i-e :
|
||||
# newsgroup nombre nombre y
|
||||
# sinon, il faut corriger à la main.
|
||||
# ./fix-active < /var/lib/news/active > active.new
|
||||
# cp active.new /var/lib/news/active
|
||||
# ctlinnd go ''
|
||||
# le 1/11/01 2h40 -- Nico
|
||||
#
|
||||
#
|
||||
|
||||
#exit 0
|
||||
|
||||
if [ `id -u` -ne 0 ] ; then
|
||||
echo "Be r00t or die ! (Need to act as news user)"
|
||||
exit 1
|
||||
elif [ 1 -le "$#" ] ; then
|
||||
echo "erreur : il ne faut pas mettre d'argument"
|
||||
exit 1
|
||||
elif [ "`cat /usr/scripts/news/active.template | wc -l`" -ne "`cat /var/lib/news/active | wc -l`" ] ; then
|
||||
echo "Attention, soit le template est obsolète (nouveaux newsgroups ajeoutés), soit /var/lib/news/active est corrompu (nb de ligne diffère)."
|
||||
echo "mettre à jour active.template ? (n pour abondonner) y/n"
|
||||
read reply2;
|
||||
case $reply2 in
|
||||
y* | Y* | o* | O*)
|
||||
cp /var/lib/news/active /usr/scripts/news/active.template
|
||||
echo active.template mis à jour.
|
||||
;;
|
||||
n* | N*)
|
||||
echo "OK, on laisse active en place ; corriger active.template"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
INNSTOP () {
|
||||
|
||||
#/id/inn2 stop
|
||||
#### Pour avoir des logs plus clairs, on remplace stop par un message personnalisé.
|
||||
|
||||
su news -c '/usr/lib/news/bin/ctlinnd shutdown 'réparation active''
|
||||
|
||||
# Stop innwatch (if running)
|
||||
if [ -f /var/run/news/innwatch.pid ]; then
|
||||
su news -c 'kill `cat /var/run/news/innwatch.pid`'
|
||||
rm -f /var/run/news/innwatch.pid
|
||||
fi
|
||||
|
||||
# wait for innd to exit (up to 60 sec)
|
||||
printf "Stopping innd: "
|
||||
/bin/su news -c 'i=12
|
||||
while [ $i -gt 0 ];
|
||||
do
|
||||
pid=`cat /var/run/news/innd.pid 2>/dev/null`
|
||||
[ "$pid" = "" ] && break
|
||||
kill -0 $pid 2>/dev/null || break
|
||||
sleep 5
|
||||
printf "."
|
||||
i=`expr $i - 1`
|
||||
done'
|
||||
printf "\n"
|
||||
|
||||
sleep 2
|
||||
sync
|
||||
#### fin du stop personnalisé.
|
||||
}
|
||||
|
||||
MAKENEWACTIVE () {
|
||||
rm -f /tmp/active.new
|
||||
cd /var/spool/news/articles
|
||||
while read gr hi lo md
|
||||
do
|
||||
d="`echo $gr | tr . /`"
|
||||
hi="`echo $hi | sed -e 's/^00*//'`"
|
||||
lo="`echo $lo | sed -e 's/^00*//'`"
|
||||
if [ "$hi" = '' ] ; then
|
||||
hi=0
|
||||
fi
|
||||
if [ "$hi" = 0 -a "$lo" = 1 ] ; then
|
||||
last=0
|
||||
lo=0
|
||||
else
|
||||
last="`ls -1 $d 2>/dev/null | sort -n | tail | grep '^[1-9][0-9]*$' | tail -1`" 2> /dev/null
|
||||
if [ "$last" = '' ] ; then
|
||||
last=$hi
|
||||
fi
|
||||
if [ "$lo" = '' -o "$lo" = 0 ] ; then
|
||||
lo=0
|
||||
# certains articles sont encore là mais sont expirés (cf. expire.ctl)
|
||||
# else
|
||||
# lo="`ls -1 $d 2>/dev/null | sort -n | head | grep '^[1-9][0-9]*$' | head -1`" 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
md='y'
|
||||
printf "%s %010d %010d %s\n" $gr $last $lo $md >> /tmp/active.new
|
||||
done < /var/lib/news/active
|
||||
}
|
||||
|
||||
|
||||
echo "arrêt d'innd..."
|
||||
INNSTOP
|
||||
|
||||
MAKENEWACTIVE
|
||||
|
||||
echo "affichage du diff"
|
||||
echo " "
|
||||
diff /tmp/active.new /var/lib/news/active
|
||||
echo " "
|
||||
|
||||
if ! ( diff -q /tmp/active.new /var/lib/news/active > /dev/null ) ; then
|
||||
echo "la version générée et la version en place diffèrent : il faut la remplacer" ;
|
||||
echo "souhaitez-vous remplacer le fichier actuellement en place ? y/n" ;
|
||||
read reply3;
|
||||
case $reply3 in
|
||||
y* | Y* | o* | O*)
|
||||
echo "OK, on le remplace"
|
||||
cp /tmp/active.new /var/lib/news/active
|
||||
chown news.news /var/lib/news/active
|
||||
chmod 664 /var/lib/news/active
|
||||
;;
|
||||
n* | N*)
|
||||
echo "OK, on le laisse, mais il faut corriger cela !"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "la version générée et la version en place sont identiques : on ne fait rien." ;
|
||||
fi
|
||||
|
||||
echo "redémarrage d'innd..."
|
||||
/id/inn2 start
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
48
news/fix-overview
Executable file
48
news/fix-overview
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $UID != 0 ]; then
|
||||
echo "Il faut être root pour lancer ce script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/etc/init.d/inn2 stop
|
||||
|
||||
(awk -F: -f - /etc/news/buffindexed.conf <<EOF""
|
||||
($0 !~ /^#/ && NF == 3) {
|
||||
print "su news -c \"dd if=/dev/zero of="$2" bs=1024 count="$3"\""
|
||||
}
|
||||
EOF
|
||||
) | sh
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
echo "Impossible d'écraser l'overview"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /var/lib/news
|
||||
|
||||
(awk -F£ '{ printf "su news -c \"" ; if ($1 == 1) printf "/usr/lib/news/bin/" ; printf $2"\" ; if [ $? != 0 ]; then echo \"Erreur pour la commande "NR"\" ; exit 2 ; fi\n"}' <<EOF""
|
||||
0£rm -f history*
|
||||
0£touch history
|
||||
1£makedbz -i
|
||||
0£mv -f history.n.dir history.dir
|
||||
0£mv -f history.n.hash history.hash
|
||||
0£mv -f history.n.index history.index
|
||||
0£chmod 664 history*
|
||||
1£makehistory -a -O -b -e
|
||||
EOF
|
||||
) | sh
|
||||
|
||||
echo "OK, redemarrage de INN"
|
||||
/etc/init.d/inn2 start
|
||||
|
||||
(awk -F£ '{ printf "su news -c \"" ; if ($1 == 1) printf "/usr/lib/news/bin/" ; printf $2"\" ; if [ $? != 0 ]; then echo \"Erreur pour la commande "NR"\" ; exit 2 ; fi\n"}' <<EOF""
|
||||
1£news.daily delayrm noexpireover lowmark nostat nomail
|
||||
1£news.daily delayrm expireover lowmark nostat nomail
|
||||
EOF
|
||||
) | sh
|
||||
|
||||
echo -------------------------------------------------
|
||||
echo Stats d'utilisation des fichiers d'overview :
|
||||
su news -c "/usr/lib/news/bin/inndf -o"
|
||||
|
45
news/index_news.sh
Executable file
45
news/index_news.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#! /bin/sh
|
||||
# index-news : Cree les index des messages de news
|
||||
# par Benoit
|
||||
|
||||
# Repertoire des news
|
||||
Rep_News=/var/spool/news/articles/crans/
|
||||
|
||||
# Repertoire d'indexage
|
||||
Rep_Ind=/var/www/search_news/index/crans.
|
||||
|
||||
# Repertoire d'id-xage
|
||||
Rep_Id=/var/www/search_news/mid/crans.
|
||||
|
||||
# Indexage des articles
|
||||
for forum in $(find $Rep_News -type d -mindepth 1 -printf '%P \n') ; do
|
||||
if (($(du -S $Rep_News$forum --max-depth=0 | awk '{print $1}') )) ; then
|
||||
index=($Rep_Ind$(echo $forum | tr "/" "."))
|
||||
nice -10 /usr/bin/index++ -v0 -i $index -r -mFrom -mSubject -mMessage-ID -e 'mail:*' $Rep_News$forum
|
||||
|
||||
# Indexage des Id
|
||||
id=($Rep_Id$(echo $forum | tr "/" "."))
|
||||
if test -f $id ; then
|
||||
number=$(tail -n 1 $id | awk '{print $1}')
|
||||
else
|
||||
number="nexistepas"
|
||||
fi
|
||||
fichier=$Rep_News$forum/$number
|
||||
if test -f $fichier ; then
|
||||
for article in $(find $Rep_News$forum -type f -maxdepth 1 -newer $fichier -printf '%P \n') ; do
|
||||
mid=$(awk '/^Message-ID: / {print $2}' $Rep_News$forum/$article)
|
||||
ref=$(awk 'BEGIN{RS="";FS=":"} /References: / {i=1;while($i !~ /References$/) i++;print $(i+1)}' $Rep_News$forum/$article | grep "^ <" | tr -d '\n')
|
||||
$(echo $article $mid $ref >> $id )
|
||||
done
|
||||
else # si le dernier message avant le dernier id-xage est annule ou modere
|
||||
# ou si le fichier des mid n'existe pas :
|
||||
# on est bourrin : on re-indexe l'ensemble
|
||||
$(echo -n > $id)
|
||||
for article in $(find $Rep_News$forum -type f -maxdepth 1 -printf '%P \n') ; do
|
||||
mid=$(awk '/^Message-ID: / {print $2}' $Rep_News$forum/$article)
|
||||
ref=$(awk 'BEGIN{RS="";FS=":"} /References: / {i=1;while($i !~ /References$/) i++;print $(i+1)}' $Rep_News$forum/$article | grep "^ <" | tr -d '\n')
|
||||
$(echo $article $mid $ref >> $id )
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue