[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 # unison_links.sh user 3 # creation des liens symbolique pour les dossiers unison 4 # 5 # 6 7 8 function mkclasses 9 { 10 user=$1 11 if [ "$2" == "x" ]; then 12 rm -fr $unisondir/$user/Classes 13 else 14 classesdir=/var/se3/Classes 15 invuser=$(echo $user|sed "s/\(.*\)\.\(.*\)/\2\.\1/") 16 classes=$(ldapsearch -xLLL "(memberuid=$user)" cn | grep "cn: Equipe" | sed "s/cn: Equipe_/Classe_/") 17 if [ -z "$classes" ]; then 18 #eleve 19 classes=$(ldapsearch -xLLL "(memberuid=$user)" cn | grep "cn: Classe_" | sed "s/cn: //") 20 groupe=eleve 21 else 22 groupe=prof 23 fi 24 # on efface tout et on recommence... 25 rm -fr $unisondir/$user/Classes 26 27 for classe in $classes 28 do 29 mkdir -p $unisondir/$user/Classes/$classe 30 if [ "$groupe" == "eleve" ]; then 31 ln -s $classesdir/$classe/_travail $unisondir/$user/Classes/$classe/_travail 32 ln -s $classesdir/$classe/$invuser $unisondir/$user/Classes/$classe/$invuser 33 [ -d $classesdir/$classe/_echange ] && ln -s $classesdir/$classe/_echange $unisondir/$user/Classes/$classe/_echange 34 elif [ "$groupe" == "prof" ]; then 35 for rep in $(ls -d $classesdir/$classe/*) 36 do 37 rep=$(basename $rep) 38 case $rep in 39 _*) 40 ln -s $classesdir/$classe/$rep $unisondir/$user/Classes/$classe/$rep 41 ;; 42 *) 43 if [ "$2" == "e" ]; then 44 ln -s $classesdir/$classe/$rep $unisondir/$user/Classes/$classe/$rep 45 fi 46 ;; 47 esac 48 done 49 fi 50 ls -ld $unisondir/$user/Classes/$classe/* 51 done 52 fi 53 } 54 function mkdocs 55 { 56 if [ "$2" == "x" ]; then 57 rm -fr $unisondir/$1/Docs 58 else 59 mkdir -p $unisondir/$1 60 ln -s /home/$1/Docs $unisondir/$1/Docs 61 fi 62 } 63 function mkgroupes 64 { 65 user=$1 66 if [ "$2" == "x" ]; then 67 rm -fr $unisondir/$user/Groupes 68 else 69 classesdir=/var/se3/Classes 70 classes=$(ldapsearch -xLLL "(memberuid=$user)" cn | grep "cn: Equipe" | sed "s/cn: Equipe_/Classe_/") 71 if [ -z "$classes" ]; then 72 #eleve 73 classes=$(ldapsearch -xLLL "(memberuid=$user)" cn | grep "cn: Classe_" | sed "s/cn: //") 74 groupe=eleve 75 else 76 groupe=prof 77 fi 78 classes=$(ldapsearch -xLLL "(memberuid=$user)" cn | sed "s/cn: //") 79 80 # on efface tout et on recommence... 81 rm -fr $unisondir/$user/Groupes 82 83 for classe in $classes 84 do 85 pathgroup="$classesdir/Classe_grp_$classe" 86 if [ -d "$pathgroup" ]; then 87 mkdir -p $unisondir/$user/Groupes/$classe 88 ln -s $pathgroup/_travail $unisondir/$user/Groupes/$classe/_travail 89 [ -d $pathgroup/_echange ] && ln -s $pathgroup/_echange $unisondir/$user/Groupes/$classe/_echange 90 if [ "$groupe" == "prof" ]; then 91 ln -s $pathgroup/_profs $unisondir/$user/Groupes/$classe/_profs 92 fi 93 ls -ld $unisondir/$user/Groupes/$classe/* 94 fi 95 done 96 fi 97 } 98 99 100 unisondir=/var/se3/synchro 101 while getopts d:c:e:k:x:p:q: option 102 do 103 case $option in 104 k) 105 mkdocs $OPTARG x 106 ;; 107 x) 108 mkclasses $OPTARG x 109 ;; 110 d) 111 mkdocs $OPTARG 112 ;; 113 c) 114 mkclasses $OPTARG 115 ;; 116 e) 117 mkclasses $OPTARG e 118 ;; 119 p) 120 mkgroupes $OPTARG 121 ;; 122 q) 123 mkgroupes $OPTARG x 124 ;; 125 126 esac 127 done
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 |