[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/sbin/ -> mail_alertes_ups.sh (source)

   1  #!/bin/bash
   2  # SambaEdu
   3  #
   4  # $Id: mail_alertes_ups.sh 7723 2013-03-18 23:57:26Z keyser $
   5  #
   6  ##### Expédie les alertes de NUT#####
   7  
   8  WWWPATH="/var/www"
   9  DROITS="se3_is_admin"
  10  
  11  if [ -e $WWWPATH/se3/includes/config.inc.php ]; then
  12          dbhost=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f 2 |cut -d \" -f 2`
  13      dbname=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2`
  14      dbuser=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 |cut -d \" -f 2`
  15      dbpass=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 |cut -d \" -f 2`
  16  else
  17      echo "Fichier de conf inaccessible"
  18          exit 1
  19  fi
  20  BASEDN=`echo "SELECT value FROM params WHERE name='ldap_base_dn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  21  if [ -z "$BASEDN" ]; then
  22          echo "Impossible d'accéder au paramètre BASEDN"
  23          exit 1
  24  fi
  25  
  26  RIGHTSRDN=`echo "SELECT value FROM params WHERE name='RightsRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  27  if [ -z "$RIGHTSRDN" ]; then
  28          echo "Impossible d'accéder au paramètre RIGHTSRDN"
  29          exit 1
  30  fi
  31          
  32  PEOPLERDN=`echo "SELECT value FROM params WHERE name='peopleRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  33  if [ -z "$PEOPLERDN" ]; then
  34          echo "Impossible d'accéder au paramètre PEOPLERDN"
  35          exit 1
  36  fi
  37  
  38  ALERTE_ACTIVE=`echo "SELECT ACTIVE FROM alertes WHERE NAME='UPS'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  39  if [ "$ALERTE_ACTIVE" != "1" ]; then
  40          exit 1
  41  fi
  42  
  43  if [ "$DROITS" != "" ]
  44  then
  45      ldapsearch  -x -b cn=$DROITS,$RIGHTSRDN,$BASEDN '(objectclass=groupOfNames)' member | grep member | grep -v requesting | while read A
  46      do
  47          echo "$A" | cut -d: -f2 | cut -d, -f1 | while read B
  48              do
  49               MAIL_UPS=`ldapsearch  -x -b $B,$PEOPLERDN,$BASEDN '(objectclass=*)' mail | grep mail | grep -v requesting | cut -d: -f2`
  50              if [ "$MAIL_UPS" != "" ]
  51              then
  52                  NOM=`/bin/hostname`
  53                  echo $* | mail -s "[Se3: $NOM] UPS Alerte" $MAIL_UPS
  54              fi    
  55              done
  56      done
  57  fi


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1