[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

   1  #!/bin/bash
   2  #
   3  # SambaEdu
   4  #
   5  # $Id: se3_parc_members.sh 6239 2011-03-16 07:39:37Z ericg $
   6  #
   7  
   8  WWWPATH="/var/www"
   9  
  10  # recup parametres ldap
  11  . /etc/se3/config_l.cache.sh
  12  # recup parametres caches : 
  13  . /etc/se3/config_m.cache.sh
  14  . /etc/se3/config_d.cache.sh
  15  
  16  if [ "$1" = "-h" -o "$1" = "--help" ]; then
  17      echo "Script destine a retourner la liste des membres d'un parc (cn)."
  18      echo ""
  19      echo "USAGE: Passer en parametre le nom du parc."
  20      echo "       Sinon, sans parametre, la liste des parcs est proposee."
  21      echo ""
  22      echo "       A IMPLEMENTER:"
  23      echo "       Si un parc est passe en parametre, on peut donner ensuite,"
  24      echo "       la liste des attributs a recuperer."
  25      exit
  26  fi
  27  
  28  interactif="y"
  29  
  30  parc=""
  31  if [ -n "$1" ]; then
  32      t=$(ldapsearch -xLLL cn=$1 -b $parcsRdn},$ldap_base_dn})
  33      if [ -z "$t" ]; then
  34          echo "Parc $1 invalide"
  35      else
  36          parc=$1
  37          interactif="n"
  38      fi
  39  fi
  40  
  41  avec_ip="n"
  42  t=$(echo "$*" | egrep -i "( ip$| ip | ipHostNumber$| ipHostNumber )")
  43  if [ -n "$t" ]; then
  44      avec_ip="y"
  45  fi
  46  
  47  avec_mac="n"
  48  t=$(echo "$*" | egrep -i "( mac$| mac | macAddress$| macAddress )")
  49  if [ -n "$t" ]; then
  50      avec_mac="y"
  51  fi
  52  
  53  while [ -z "$parc" ]
  54  do
  55      # Choix du parc
  56      echo ""
  57      echo "Voici la liste des parcs existants: "
  58      ldapsearch -xLLL -b $parcsRdn},$ldap_base_dn} cn|grep "^cn: "| sed -e "s|^cn:||" | sort | tr -d '\n' | more
  59  
  60      echo ""
  61      echo -e "Choix du parc: \c"
  62      read -e parc
  63  
  64      if [ -n "$parc" ]; then
  65          t=$(ldapsearch -xLLL cn=$parc -b $parcsRdn},$ldap_base_dn})
  66          if [ -z "$t" ]; then
  67              echo "Parc $parc invalide"
  68              parc=""
  69          fi
  70      fi
  71  done
  72  
  73  if [ "$interactif" = "y" ]; then
  74      echo ""
  75      echo "Liste des machines ou imprimantes du parc $parc:"
  76      ldapsearch -xLLL cn=$parc -b $parcsRdn},$ldap_base_dn} member | grep "^member: " | sed -e "s|^member: cn=||"|cut -d"," -f1 | more
  77  else
  78      opt=""
  79      if [ "$avec_ip" = "y" ]; then
  80          opt="$opt ipHostNumber"
  81      fi
  82      if [ "$avec_mac" = "y" ]; then
  83          opt="$opt macAddress"
  84      fi
  85  
  86      if [ -n "$opt" ]; then
  87          ldapsearch -xLLL cn=$parc -b $parcsRdn},$ldap_base_dn} member | grep "^member: " | sed -e "s|^member: cn=||"|cut -d"," -f1|while read cn
  88          do
  89              ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$cn $opt
  90          done
  91      else
  92          ldapsearch -xLLL cn=$parc -b $parcsRdn},$ldap_base_dn} member | grep "^member: " | sed -e "s|^member: cn=||"|cut -d"," -f1
  93      fi
  94  fi


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