siotp/sisr1/Bts-blanc/createUsers.sh

25 lines
1006 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

file=./login.csv
file1=./Users.csv
while read ligne
do
username=$(echo $ligne | cut -d ";" -f1)
useradd -m -s "/bin/bash" $username
roup=$(echo $ligne | cut -d ";" -f5)
usermod -aG $group $username
password=$(echo $ligne | cut -d ";" -f2)
echo $username:$password | chpasswd
chown $username:$username /home/$username
done <$file
while read ligne
do
last_name=$(echo $ligne | cut -d "," -f2) # récupération du nom a chaque ligne
first_name=$(echo $ligne | cut -d "," -f1) # récupération du prénom a chaque ligne
login=$(echo $first_name | cut -c1)$last_name # creation d'un login
login=$(echo $login | tr [:upper:] [:lower:]) #passage de toute les lettre du nom et prenom en minuscule
login=$(echo $login | tr -dc [:alnum:]) #Prise en compte des caractere uniquement alphabéticonumérique
group=$(echo $ligne | cut -d "," -f6)
getent group $group
if [[ $group == "TeamLead" ]] ; then
usermod aG $group $login
fi
done < $file1