Rangement des vieux scripts.

darcs-hash:20051019153726-41617-b54e8a50ef8e50786607ee0f5a21d3fd7dfa8d74.gz
This commit is contained in:
pauget 2005-10-19 17:37:26 +02:00
parent 68992febad
commit 7c92f6c2b9
6 changed files with 0 additions and 426 deletions

View file

@ -1,155 +0,0 @@
#!/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/active.template | wc -l`" -ne "`cat /var/lib/news/active | wc -l`" ] ; then
echo "Attention, soit le template est obsolète (nouveaux newsgroups ajouté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/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

View file

@ -1,48 +0,0 @@
#!/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"

View file

@ -1,45 +0,0 @@
#! /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/local/search_news/index/crans.
# Repertoire d'id-xage
Rep_Id=/var/local/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

View file

@ -1,40 +0,0 @@
#!/bin/sh
#
# Envoie la liste des fichiers modifiés localement.
# base: cvs -q status|grep Status|grep -v "Up-to-date"
# suivi de cvs -q status | grep -A8 Locally
tempF=$(tempfile -d /tmp -p "cvs_list")
tempF2=$(tempfile -d /tmp -p "cvs_list")
tempF3=$(tempfile -d /tmp -p "cvs_list")
( echo "Subject: CVS status sur Zamok"
echo "X-CVSinfo: CRANS"
echo "To: $1"
echo ""
echo "Liste des fichiers non synchros"
echo "-------------------------------"
) > $tempF 2>&1
cd /etc
cvs -q -d /usr/cvs-rep status /etc/ >$tempF3
cvs -q -d /var/lib/cvs status /usr/scripts/ >> $tempF3
#/usr/bin/cvs -q -d /usr/cvs-rep status /etc/ >$tempF3
grep "Status" $tempF3 |grep -v "Up-to-date" >$tempF2
if test -s $tempF2; then
dirtyCVS="carrement"
# echo DIRTY
fi
echo -ne "\nDetails des Locally modified files\n" >>$tempF2
echo -ne "----------------------------------\n" >>$tempF2
grep -A8 "Locally" $tempF3 >> $tempF2
if test -n "$1";
then test -n "$dirtyCVS" && cat $tempF $tempF2 | sendmail "$1";
else cat $tempF $tempF2;
fi
rm $tempF $tempF2 $tempF3

View file

@ -1,128 +0,0 @@
#!/bin/sh
##
## news-cancel
##
## Made by stransky
## Login stransky <stransky@crans.org>
##
## Started on dim 13 jan 2002 02:30:56 CET Nicolas STRANSKY
## Last update ven 19 sep 2003 14:21:27 CEST Nicolas STRANSKY
##
## Script pour annuler ou modérer un message de news.
##
## 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}'`
else moderateur=${ORIG_LOGNAME-$SUDO_USER}
fi
ovfiles=$(grep "^[[:digit:]]" /etc/news/buffindexed.conf | cut -d ':' -f 2 | tr "\n" " ")
groupe=adm
tempF=$(tempfile -d /tmp -p "newscancel")
tempF2=$(tempfile -d /tmp -p "newscancelcommentaire")
tempF3=$(tempfile -d /tmp -p "newscancelmessage")
VERIF () {
ligne=`grep -h --binary-files=text " $1 " $ovfiles | head -n 1 | awk -F "\t" '{print $1"~"$2"~"$3"~"$9}'`
auteur=`echo $ligne | awk -F "~" '{print $3}'`
titre=`echo $ligne | awk -F "~" '{print $2}'`
newsgroup=`echo $ligne | awk -F "~" '{print $4}' | awk '{print $3}' | awk -F : '{print $1}'`
#numero=`echo $ligne | awk -F "~" '{print $1}'`
numero=`echo $ligne | awk -F "~" '{print $4}' |awk -v VAR1=$newsgroup 'BEGIN {RS = " "} ; $0 ~ VAR1 {print $1}' | awk -F ":" '{print strtonum($2)}'`
if [[ $ligne != "" ]] ; then
echo "il s'agit du message \"$titre\", numéro $numero, posté par $auteur dans $newsgroup"
echo ""
echo -n "exact ? [o/n] "
read confirmation
case $confirmation in
o*|O*)
;;
*)
echo "On ne fait rien."
exit 0
;;
esac
else
echo "Aucun message ne correspond à cette ID"
exit 1
fi
}
SAUVEGARDE () {
echo "Sauvegarde du message dans /root/moderes/..."
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" > $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 () {
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.3 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 ''"
(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 news.crans.org 119
}
if [ $UID -eq 0 ]
then
case $1 in
\<*@*\>)
VERIF $1
echo "Edition ou Annulation du message ? [E/A] "
read action
case $action in
e*|E*)
SAUVEGARDE Edition
EDITION $1
;;
a*|A*)
SAUVEGARDE Annulation
CANCEL $1
;;
*)
echo "attention, il n'y a eu ni édition ni annulation. relancer le script"
;;
esac
;;
*)
echo "usage : news-cancel '<Message-ID>'"
;;
esac
else
echo "You must be root to launch this command."
exit 1
fi

View file

@ -1,10 +0,0 @@
#! /bin/sh
MBOX=/var/tmp/mbox
TMP=mktemp
spamc -t 60 < $MBOX > $TMP
if diff $TMP $MBOX > /dev/null; then
/etc/init.d/spamassassin restart
echo "Spam Assassin a été relancé." | mail roots@crans.org -s "Spam Assassin"
fi