diff --git a/check-samba b/check-samba index 51f1e40b..93223e1d 100755 --- a/check-samba +++ b/check-samba @@ -1,15 +1,36 @@ #!/bin/zsh -#script shell par kif 01/10/00 +## +## check-samba +## +## Made by stransky +## Login stransky +## +## Started on jeu 01 oct 2000 19:25:35 CET Jérôme Kieffer +## Last update jeu 30 jan 2003 19:25:35 CET Nicolas STRANSKY +## +# surveillance de nmbd LOG=/var/log/cransMisc/samba-master.log -master=`smbclient -N -L zamok |grep -A5 Master |grep CRANS |tail -c 6 ` + +master=$(smbclient -N -L zamok |grep -A5 Master |grep CRANS | awk '{print $2}') if [ "$master" != 'ZAMOK' ]; then - echo -n `date` >> $LOG - echo " : le maitre est $master " >> $LOG - echo "Zamok n'est plus maitre ; je relance samba" >> $LOG - /id/samba restart >> $LOG 2>&1 -#else -# echo zamok est encore maitre + # on attend pour être sûr que zamok n'est pas justement en train de déclencher une élection : + sleep 20 + # 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 + date=`date` + echo "$date : Crans local master is $master " >> $LOG + echo "$date : restarting samba" >> $LOG + echo -n $date >> $LOG + /id/samba stop >> $LOG 2>&1 + echo -n $date >> $LOG + killall -9 nmbd >> $LOG 2>&1 # tant qu'à faire on peut killer complètement nmbd + echo -n $date >> $LOG + /id/samba start >> $LOG 2>&1 + fi fi