scripts/check-samba
stransky abbd2982ce et dire que ce truc existe encore... et sert encore, apparemment.
darcs-hash:20050222004449-a279a-61757a0daf3b7fb3c4a7e03b1ad47d68e61980e5.gz
2005-02-22 01:44:49 +01:00

38 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 -A20 "Workgroup *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 35
# on refait le test :
master=$(smbclient -N -L zamok |grep -A20 "Workgroup *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
sleep 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