[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 # SambaEdu 3 # 4 # $Id: start_poste.sh 8306 2014-12-08 15:59:15Z dbo $ 5 # 6 7 WWWPATH="/var/www" 8 9 # recup parametres ldap 10 . /etc/se3/config_l.cache.sh 11 # recup parametres caches : 12 . /etc/se3/config_m.cache.sh 13 . /etc/se3/config_d.cache.sh 14 15 # calcule l'adresse de broadcast à partir de l'ip 16 GETBROADCAST() 17 { 18 if [ "$dhcp" == "1" ]; then 19 vlan= 20 else 21 broadcast=$(echo $1|"s/\.[0-9]*$/.255/") 22 fi 23 24 } 25 if [ -z "$2" ] 26 then 27 echo "Ce script est destine a provoquer l'allumage," 28 echo "l'extinction ou le reboot d'une machine." 29 echo "USAGE: Passer en parametres le nom netbios de la machine et l'action." 30 echo " L'action doit etre shutdown, reboot ou wol." 31 echo " Exemple: $0 CDI01 reboot" 32 # echo "Les parcs existants sont :" 33 # ldapsearch -x -b $PARCSRDN,$BASEDN '(objectclass=*)' | grep cn | grep -v requesting | grep -i -v Rights | grep -i -v member 34 else 35 ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$1 '(objectclass=*)' macAddress | grep macAddress | while read C 36 do 37 echo "$C" | cut -d: -f 2-7 | while read D 38 do 39 getent passwd $1$>/dev/null && TYPE="XP" 40 if [ "$TYPE" = "XP" ]; then 41 echo "<br><h2>Action sur : $1</h2><br>" 42 if [ "$2" = "shutdown" ]; then 43 echo "<h3>Tentative d'arret de la machine $1</h3><br>" 44 ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$1 '(objectclass=ipHost)' ipHostNumber | grep ipHostNumber: | sed "s/ipHostNumber: //g" | while read I 45 do 46 /usr/bin/net rpc shutdown -t 30 -f -C "Arret demande par le serveur sambaEdu3" -I $I -U "$1\adminse3%$xppass" 47 done 48 fi 49 if [ "$2" = "reboot" ]; then 50 echo "<h3>Tentative de reboot de la machine $1</h3><br>" 51 ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$1 '(objectclass=ipHost)' ipHostNumber | grep ipHostNumber: | sed "s/ipHostNumber: //g" | while read I 52 do 53 /usr/bin/net rpc shutdown -t 30 -r -f -C "Arret demande par le serveur sambaEdu3" -I $I -U "$1\adminse3%$xppass" 54 done 55 fi 56 if [ "$2" = "wol" ]; then 57 echo "Tentative d'eveil pour la machine correspondant a l'adresse mac $D<br>" 58 ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$1 '(objectclass=ipHost)' ipHostNumber | grep ipHostNumber: | sed "s/ipHostNumber: //g;s/\.[0-9]*$/.255/g" | while read I 59 do 60 echo "Broadcast: $I<br>" 61 /usr/bin/wakeonlan -i $I $D > /dev/null 62 /usr/bin/wakeonlan $D > /dev/null 63 done 64 fi 65 else 66 # On teste si on a un windows ou un linux 67 ldapsearch -x -b $computersRdn},$ldap_base_dn} uid=$B$ '(objectclass=*)' uidNumber | grep uid |grep -v requesting | grep -v base 68 # On peut penser que l'on a un linux, mais cela peut aussi être un win 9X 69 # A affiner 70 if [ $? = "1" ] 71 then 72 if [ "$2" = "wol" ]; then 73 echo "Tentative d'eveil pour la machine correspondant a l'adresse mac $D<br>" 74 ldapsearch -xLLL -b $computersRdn},$ldap_base_dn} cn=$1 '(objectclass=ipHost)' ipHostNumber | grep ipHostNumber: | sed "s/ipHostNumber: //g;s/\.[0-9]*$/.255/g" | while read I 75 do 76 echo "broadcast: $I<br>" 77 /usr/bin/wakeonlan -i $I $D > /dev/null 78 /usr/bin/wakeonlan $D > /dev/null 79 done 80 fi 81 82 if [ "$2" = "shutdown" ]; then 83 echo "<h3>Tentative d'arret de la machine $1</h3><br>" 84 /usr/bin/ssh -o StrictHostKeyChecking=no $1 halt 85 fi 86 fi 87 fi 88 done 89 done 90 fi
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |