[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 3 # $Id: mv_Trash_Home.sh 7061 2012-04-02 09:22:45Z dbo $ 4 # Script destine a deplacer dans un dossier /home_Trash_$date les homes de comptes orphelins 5 # plutot que de les supprimer directement 6 # Auteur: Stephane Boireau 7 # Derniere modification: 12/10/2008 8 9 ### recup pass root mysql 10 . /root/.my.cnf 2>/dev/null 11 12 BASEDN=$(cat /etc/ldap/ldap.conf | grep "^BASE" | tr "\t" " " | sed -e "s/ \{2,\}/ /g" | cut -d" " -f2) 13 ROOTDN=$(cat /etc/ldap/slapd.conf | grep "^rootdn" | tr "\t" " " | cut -d'"' -f2) 14 PASSDN=$(cat /etc/ldap.secret) 15 16 dest=/home/_Trash_$(date +%Y%m%d_%H%M%S) 17 fich=/var/www/se3/Admin/mv_Trash_$(date +%Y%m%d%H%M%S) 18 19 cpt=0 20 echo "Parcours de la Corbeille...<br />" 21 ldapsearch -xLLL -b ou=Trash,$BASEDN uid | grep "^uid: " | sed -e "s/^uid: //" | while read uid 22 do 23 #echo "Controle de $uid" | tee -a $fich 24 if [ -d "/home/$uid" ]; then 25 if [ "$cpt" = "0" ]; then 26 27 mkdir -p $dest} 28 if [ "$?" != "0" ]; then 29 echo "ERREUR: La creation du dossier $dest} a echoue." | tee -a $fich 30 exit 31 fi 32 33 echo "Deplacement vers $dest}: " | tee -a $fich 34 else 35 echo ", "|tee -a $fich 36 fi 37 echo "$uid"|tee -a $fich 38 mv /home/$uid $dest}/ 39 chown -R admin:admins $dest}/$uid 40 cpt=$(($cpt+1)) 41 else 42 echo "/home/$uid n'existe pas"| tee -a $fich 43 fi 44 45 # A VOIR pour LCS: 46 # Faut-il un dump de sauvegarde?... 47 #db_name=$(echo "$uid" | sed -e "s/-//g" | sed -e "s/_//g" | sed -e "s/\.//g") 48 #echo "DROP DATABASE ${db_name}" | mysql -h $dbhost -u $dbuser -p$dbpass > /dev/null 2>&1 49 #echo "delete from personne where login = '$uid'" | mysql -h $dbhost lcs_db -u $dbuser -p$dbpass 50 done 51
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 |