Synchronisation Vulture

Contenu

Voici un exemple de script qui synchronise la configuration et base utilisé par Vulture il utilise nc (netcat) pour emmètre les alerte par mail

#!/bin/sh
DATE=`date +"%Y%m%d-%N"`
SHORT_DATE=`date +"%Y%m%d"`
RESULT=""
SRV_MAIL="IP_SERV_MAIL"
AIL_DST_ALERT="email[email protected]"
HOSTNAME=`hostname -f`
REMOTE_SRV="ip-server-master"

#
# Synchro de la base sqlite
rsync -t -o -g -e ssh $REMOTE_SRV:/var/www/vulture/sql/* /var/www/vulture/sql/
sync_db=$?

if [ $sync_db -eq 0 ]; then
  echo $SHORT_DATE" - SYNC DB : OK" >> /var/log/Vulture-sync.log
else
  echo $SHORT_DATE" - SYNC DB : NOK" >> /var/log/Vulture-sync.log
  (echo "HELO "$HOSTNAME; echo "mail from: "; echo "rcpt to: <"$MAIL_DST_ALERT">"; echo "DATA"; echo "From: [email protected]"$HOSTNAME; echo "Subject: ["$HOSTNAME"] "$SHORT_DATE" - Synchro de la base Vulture NOK"; echo "To: "$MAIL_DST_ALERT; echo; echo "Synchronisation de la base Vulture en echec."; echo; echo "."; echo "QUIT") | nc $SRV_MAIL 25
fi

#
# Synchro des fichiers de configuration
rsync --exclude=httpd.conf -l -t -o -g -e ssh $REMOTE_SRV:/var/www/vulture/conf/*.\{conf,crt,tpl,key,chain\} /var/www/vulture/conf/
sync_conf=$?

if [ $sync_db -eq 0 ]; then
  echo $SHORT_DATE" - SYNC CONF : OK" >> /var/log/Vulture-sync.log
else
  echo $SHORT_DATE" - SYNC CONF : NOK" >> /var/log/Vulture-sync.log
  (echo "HELO "$HOSTNAME; echo "mail from: "; echo "rcpt to: <"$MAIL_DST_ALERT">"; echo "DATA"; echo "From: [email protected]"$HOSTNAME; echo "Subject: ["$HOSTNAME"] "$SHORT_DATE" - Synchro des fichiers de configuration Vulture NOK"; echo "To: "$MAIL_DST_ALERT; echo; echo "Synchronisation des fichiers de configuration Vulture en echec."; echo; echo "."; echo "QUIT") | nc $SRV_MAIL 25
fi
comments powered by Disqus