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

Bypass the web interface of the slis

+ CHG : generate_users now only create one txt file that is to be given
to create_mass_primtux_users
+ CHG : create_mass_primtux_users now do actually create ldap users by
calling /usr/share/lcs/sbin/userAdd.pl
parent 0fd2b925
Branches
No related tags found
No related merge requests found
...@@ -21,10 +21,26 @@ then ...@@ -21,10 +21,26 @@ then
fi fi
rm -f users.txt rm -f users.txt
scriptbinpath="/usr/share/lcs/sbin"
. /etc/slis/slis.conf . /etc/slis/slis.conf
while read first last level
if [ ! -x $scriptbinpath/userAdd.pl ]
then
echo "Critical error : $scriptbinpath/userAdd.pl does not exist or is not executable"
exit 1
fi
while read first last level gender categorie
do do
echo "Creating user for $first $last"
$scriptbinpath/userAdd.pl $first $last "xxx" "" $gender $categorie
uid=`ldapsearch -x cn="$first $last" | grep "^uid:" | cut -d ' ' -f 2` uid=`ldapsearch -x cn="$first $last" | grep "^uid:" | cut -d ' ' -f 2`
if [ -z "$uid" ]
then
KO="$KO $uid"
echo "Failed to create user for $first $last"
continue
fi
$DIR/create_primtux_user.sh $uid $level $DIR/create_primtux_user.sh $uid $level
# set initial password # set initial password
echo "dn: uid=$uid,ou=People,$LDAP_BASE_DN" > $$.ldiff echo "dn: uid=$uid,ou=People,$LDAP_BASE_DN" > $$.ldiff
...@@ -35,4 +51,13 @@ do ...@@ -35,4 +51,13 @@ do
rm $$.ldiff rm $$.ldiff
echo -e "$uid\n$uid" | smbpasswd -s -U $uid echo -e "$uid\n$uid" | smbpasswd -s -U $uid
echo $uid >> users.txt echo $uid >> users.txt
echo "Done creating $uid"
OK="$OK $uid"
done < $1 done < $1
echo "The following users where correctly created"
echo -e "\t$OK"
if [ ! -z $KO ]
then
echo "Some errors where encountered while creating the following users :"
echo -e "\t$KO"
fi
...@@ -85,9 +85,9 @@ find $home/.wine/drive_c/ -type l ! -exec test -e {} \; -print | while read f ...@@ -85,9 +85,9 @@ find $home/.wine/drive_c/ -type l ! -exec test -e {} \; -print | while read f
do do
ln -sf "$home/`basename \"$f\" | sed 's/.* \(.*\)/\u\1/'`" "$f" ln -sf "$home/`basename \"$f\" | sed 's/.* \(.*\)/\u\1/'`" "$f"
done done
sed -i s@${SKELS[$level]}@$user@g $home/.config/xfce4/panel/launcher-4/14504679941.desktop sed -i "s@${SKELS[$level]}@$user@g" $home/.config/xfce4/panel/launcher-4/14504679941.desktop
sed -i s@/home/${SKELS[$level]}/Documents@/home/$user/Documents @g $home/.handymenu.conf sed -i "s@/home/${SKELS[$level]}/Documents@/home/$user/Documents @g" $home/.handymenu.conf
sed -i s@${SKELS[$level]}@$user@g $home/.handymenu.conf sed -i "s@${SKELS[$level]}@$user@g" $home/.handymenu.conf
# fix samba passwd # fix samba passwd
# echo "You will be prompted twice for samba password, please enter the same as for LDAP" # echo "You will be prompted twice for samba password, please enter the same as for LDAP"
# smbpasswd -U $user # smbpasswd -U $user
......
...@@ -8,34 +8,29 @@ then ...@@ -8,34 +8,29 @@ then
usage usage
exit 1 exit 1
fi fi
output="users.txt"
save_uid (){ save_uid (){
echo $2 $1 $3 >> names.txt echo $@ >> $output
}
randomgender(){
[ $(( $RANDOM % 2 )) == 1 ] && echo "M" || echo "F"
} }
STUDENT_LEVELS="cycle1 cycle2 cycle3" STUDENT_LEVELS="cycle1 cycle2 cycle3"
TEACH_LEVELS="prof" TEACH_LEVELS="prof"
rm classes.txt eleves.txt profs.txt names.txt rm -f $output
for i in `seq 1 $1` for i in `seq 1 $1`
do do
for l in $STUDENT_LEVELS for l in $STUDENT_LEVELS
do do
gender=`[ $(( $RANDOM % 2 )) == 1 ] && echo "M" || echo "F"` save_uid -$i $l $l `randomgender` Eleves
echo "|$l|-$i|19700101|$gender|Primtux" >> eleves.txt
save_uid $l -$i $l
done done
for l in $TEACH_LEVELS for l in $TEACH_LEVELS
do do
gender=$(( 1 + $RANDOM % 2 )) gender=`[ $(( $RANDOM % 2 )) == 1 ] && echo "M" || echo "F"`
echo "|$l|$i|19700101|$gender" >> profs.txt save_uid $i $l $l `randomgender` Profs
save_uid $l $i $l
done
done done
echo "|direction|1|19700101|$gender" >> profs.txt
save_uid direction 1 direction
echo "|administratif|1|19700101|$gender" >> profs.txt
save_uid administratif 1 direction
for level in $STUDENT_LEVELS $TEACH_LEVELS direction
do
echo "$level|classe des $level|" >> classes.txt
done done
echo "All done, please import eleves.txt, profs.txt and classes.txt" save_uid 1 direction direction `randomgender` Administratifs
echo "Then run `dirname $0`/create_mass_primtux_users.sh names.txt" save_uid 1 administratif direction `randomgender` Administratifs
echo "All done"
echo "Run `dirname $0`/create_mass_primtux_users.sh $output to actually create the users"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment