scripts/check-samba
stransky 7f07072806 a commence prendre forme ; les plantages samba font maintenant partie du pass :)
N.

darcs-hash:20030202113345-a279a-bb5fc21cf51461e3db70bbacb8650ef022feea06.gz
2003-02-02 12:33:45 +01:00

37 lines
1.2 KiB
Bash
Executable file

#!/bin/zsh
##
## check-samba
##
## Made by stransky
## Login stransky <stransky@crans.org>
##
## Started on jeu 01 oct 2000 19:25:35 CET Jérôme Kieffer
## Last update sam 01 fév 2003 00:24:11 CET Nicolas STRANSKY
##
# surveillance de nmbd
LOG=/var/log/cransMisc/samba-master.log
master=$(smbclient -N -L zamok |grep -A5 Master |grep CRANS | awk '{print $2}')
if [ "$master" != 'ZAMOK' ];
then
echo "$(date) : Crans local master is \"$master\" ; waiting to confirm..." >> $LOG
# on attend pour être sûr que zamok n'est pas justement en train de déclencher une élection :
sleep 30
# on refait le test :
master=$(smbclient -N -L zamok |grep -A5 Master |grep CRANS | awk '{print $2}')
# Si on est sûr que ça chie, on sort les armes :
if [ "$master" != 'ZAMOK' ];
then
echo "$(date) : Crans local master is \"$master\" ; restarting samba" >> $LOG
echo -n "$(date) : " >> $LOG
/id/samba stop >> $LOG 2>&1
echo -n "$(date) : " >> $LOG
killall -9 nmbd && echo "remaining nmbd process killed" >> $LOG 2>&1 # tant qu'à faire on peut killer complètement nmbd
echo -n "$(date) : " >> $LOG
/id/samba start >> $LOG 2>&1
else
echo "$(date) : Well done, good boy" >> $LOG
fi
fi