Botchk
Un article de Communaute francophone sur les Eggdrops.
Le fichier botchk permet, associé à un crontab, permet de redémarrer automatiquement un eggdrop s'il s'arrétait anormalement.
Sommaire |
Configuration
Il y a 5 paramètres pour configurer le fichier botchk.
Les exemples sont ici donnés pour l'eggdrop Artus.
Répertoire
Il s'agit ici du répertoire dans lequel se trouve votre fichier eggdrop.
botdir="/home/user/eggdrop"
Script
Contrairement à ce qui est donné dans l'exemple initial, il ne faut pas mettre que le nom du fichier de configuration mais aussi l'exécutable:
botscript="eggdrop Artus.conf"
Nom
On utilise ici le botnet-nick car il est normalement unique sur une même machine. Pour ma part, le botnet-nick et le username sont toujours les mêmes, ainsi que l'on peut le voir dans ma configuration générique.
botname="Artus"
Userfile
Il faut indiquer le userfile tel que définit dans le fichier de configuration. Ceci sert essentiellement si l'eggdrop s'est arrété alors qu'il était en train de sauvegarder son fichier utilisateur.
userfile="Artus.user"
Pid
Le pidfile, tel que définit dans le fichier de configuration, permet de vérifier si l'eggdrop est bien lancé.
pidfile="pid.Artus"
Source
Voici les sources du fichier botchk:
#! /bin/sh
#
# CONFIGURATION
#
botdir="/home/user/eggdrop"
botscript="eggdrop Artus.conf"
botname="Artus"
userfile="Artus.user"
pidfile="pid.Artus"
#
# DO NOT EDIT
#
cd $botdir
# is there a pid file?
if test -r $pidfile
then
# there is a pid file -- is it current?
botpid=`cat $pidfile`
if `kill -CHLD $botpid >/dev/null 2>&1`
then
# it is still going -- back out quietly
exit 0
fi
echo ""
echo "Stale $pidfile file, erasing..."
rm -f $pidfile
fi
if test -r CANTSTART.$botname
then
if test -r $userfile || test -r $userfile~new || test -r $userfile~bak
then
echo ""
echo "Userfile found, removing check file 'CANTSTART.$botname'..."
rm -f CANTSTART.$botname
fi
fi
# test if we have run botchk previously and did not find a userfile
if test ! -f CANTSTART.$botname
then
echo ""
echo "Couldn't find bot '$botname' running, reloading..."
echo ""
# check for userfile and reload bot if found
if test -r $userfile
then
# It is there, load the bot
./$botscript
exit 0
else
if test -r $userfile~new
then
# Bot f*@!ed up while saving the userfile last time. Move it over.
echo "Userfile missing. Using last saved userfile..."
mv -f $userfile~new $userfile
./$botscript
exit 0
else
if test -r $userfile~bak
then
# Userfile is missing, use backup userfile.
echo "Userfile missing. Using backup userfile..."
cp -f $userfile~bak $userfile
./$botscript
exit 0
else
# Well, nothing to work with...
echo "No userfile. Could not reload the bot..."
echo "no userfile" > CANTSTART.$botname
exit 1
fi
fi
fi
fi
exit 0

