diff --git a/create_primtux_user.sh b/create_primtux_user.sh index 35c977c5bfdae0b8178eda639880e43045d9dcd4..7ef30df5422e41eb408d139fe94917ff6b413ee8 100644 --- a/create_primtux_user.sh +++ b/create_primtux_user.sh @@ -7,6 +7,11 @@ SKELS[cycle_3]="03-maxi" SKELS[professeur]="prof" SKELS[direction]="direction" +user="$1" +level="$2" +TEMPF="$$_temp" +DIR=`dirname $0` +DIST="$DIR/dist" abort(){ rm $TEMPF* exit 1 @@ -23,11 +28,12 @@ then usage abort fi +if [ "`echo $LEVELS | tr ' ' '\n' | grep $level`" != "$level" ] +then + echo "Level should be one of $LEVELS" + abort +fi . /etc/slis/slis.conf -user="$1" -level="$2" -TEMPF="$$_temp" -DIST="`dirname $0`/dist" set -x # Check for LDAP group Primtux if [ -z "ldapsearch -x cn=Primtux | grep numEntries" ] @@ -39,6 +45,7 @@ fi ldapsearch -x -LLL uid=$user > $TEMPF.ldiff if [ ! -s $TEMPF.ldiff ] then + echo "Unknown user $user" abort fi # Check for UID => 1000 and update if required @@ -59,16 +66,20 @@ echo -e "dn: cn=Primtux,ou=Groups,$LDAP_BASE_DN\nchangetype: modify\nadd: member ldapmodify -x -D "cn=$LDAP_ADMIN_RDN,$LDAP_BASE_DN" -w $LDAP_ADMIN_PW -f $TEMPF.1.ldiff # Retrieve files from skels skel="$DIR/skels/${SKELS[$level]}" -home=`$TEMPF.ldiff | cut -d ' ' -f 2` -echo mv $home $home.bak -echo cp -r $skel $home -echo cp -r $home.bak/* $home/ -echo rm -rf $home +home=`grep home $TEMPF.ldiff | cut -d ' ' -f 2` +mv $home $home.bak +cp -r $skel $home +cp -r $home.bak/* $home/ +rm -rf $home.bak # fix links -echo ln -sf $home/.wine/drive_c/users/01-mini/Bureau $home/Bureau -# fix Rights -echo chown -R $uid: $home +if [ -e "$home/.wine/drive_c/users/01-mini/Bureau" ] +then + ln -sf $home/Bureau $home/.wine/drive_c/users/01-mini/Bureau +fi # fix samba passwd # TODO: test me -smbpasswd -w $LDAP_ADMIN_PW -n $user -rm $$.ldif +echo "You willbe prompted twice for samba password, please enter the same as for LDAP" +smbpasswd -U $user +# fix Rights +chown -R $uid:lcs-users $home +rm $TEMPF*