Skip to content
Snippets Groups Projects
Verified Commit 54683eb0 authored by David Beniamine's avatar David Beniamine
Browse files

Fix createuser script

parent d8282eae
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,11 @@ SKELS[cycle_3]="03-maxi" ...@@ -7,6 +7,11 @@ SKELS[cycle_3]="03-maxi"
SKELS[professeur]="prof" SKELS[professeur]="prof"
SKELS[direction]="direction" SKELS[direction]="direction"
user="$1"
level="$2"
TEMPF="$$_temp"
DIR=`dirname $0`
DIST="$DIR/dist"
abort(){ abort(){
rm $TEMPF* rm $TEMPF*
exit 1 exit 1
...@@ -23,11 +28,12 @@ then ...@@ -23,11 +28,12 @@ then
usage usage
abort abort
fi fi
if [ "`echo $LEVELS | tr ' ' '\n' | grep $level`" != "$level" ]
then
echo "Level should be one of $LEVELS"
abort
fi
. /etc/slis/slis.conf . /etc/slis/slis.conf
user="$1"
level="$2"
TEMPF="$$_temp"
DIST="`dirname $0`/dist"
set -x set -x
# Check for LDAP group Primtux # Check for LDAP group Primtux
if [ -z "ldapsearch -x cn=Primtux | grep numEntries" ] if [ -z "ldapsearch -x cn=Primtux | grep numEntries" ]
...@@ -39,6 +45,7 @@ fi ...@@ -39,6 +45,7 @@ fi
ldapsearch -x -LLL uid=$user > $TEMPF.ldiff ldapsearch -x -LLL uid=$user > $TEMPF.ldiff
if [ ! -s $TEMPF.ldiff ] if [ ! -s $TEMPF.ldiff ]
then then
echo "Unknown user $user"
abort abort
fi fi
# Check for UID => 1000 and update if required # 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 ...@@ -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 ldapmodify -x -D "cn=$LDAP_ADMIN_RDN,$LDAP_BASE_DN" -w $LDAP_ADMIN_PW -f $TEMPF.1.ldiff
# Retrieve files from skels # Retrieve files from skels
skel="$DIR/skels/${SKELS[$level]}" skel="$DIR/skels/${SKELS[$level]}"
home=`$TEMPF.ldiff | cut -d ' ' -f 2` home=`grep home $TEMPF.ldiff | cut -d ' ' -f 2`
echo mv $home $home.bak mv $home $home.bak
echo cp -r $skel $home cp -r $skel $home
echo cp -r $home.bak/* $home/ cp -r $home.bak/* $home/
echo rm -rf $home rm -rf $home.bak
# fix links # fix links
echo ln -sf $home/.wine/drive_c/users/01-mini/Bureau $home/Bureau if [ -e "$home/.wine/drive_c/users/01-mini/Bureau" ]
# fix Rights then
echo chown -R $uid: $home ln -sf $home/Bureau $home/.wine/drive_c/users/01-mini/Bureau
fi
# fix samba passwd # fix samba passwd
# TODO: test me # TODO: test me
smbpasswd -w $LDAP_ADMIN_PW -n $user echo "You willbe prompted twice for samba password, please enter the same as for LDAP"
rm $$.ldif smbpasswd -U $user
# fix Rights
chown -R $uid:lcs-users $home
rm $TEMPF*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment