nouveau fichier : TP04/Scripts/Users.csv nouveau fichier : TP04/Scripts/createLogins.sh nouveau fichier : TP04/Scripts/createUsers.sh nouveau fichier : TP04/Scripts/logins.csv nouveau fichier : TP04/Scripts/testlogin.csv
20 lines
439 B
Bash
20 lines
439 B
Bash
#!/bin/bash
|
|
while read line
|
|
do
|
|
touch ./temptp4.txt
|
|
echo $line > ./temptp4.txt
|
|
group=$(cut -d "," -f 5 ./temptp4.txt)
|
|
user=$(cut -d "," -f 1 ./temptp4.txt)
|
|
mdp=$(cut -d "," -f 2 ./temptp4.txt)
|
|
if grep -q $group /etc/group ; then
|
|
echo "ok"
|
|
else
|
|
echo "existe pas ; création"
|
|
groupadd -f $group
|
|
fi
|
|
useradd $user --create-home --groups $group --shell /bin/bash
|
|
echo "$user:$mdp" | chpasswd
|
|
rm ./temptp4.txt
|
|
done < logins.csv
|
|
|