Ajouter createUsers.sh

This commit is contained in:
jibril.bouhbas 2024-03-04 11:26:19 +01:00
parent b72178ba78
commit ef58899c8e

25
createUsers.sh Normal file
View File

@ -0,0 +1,25 @@
!/bin/bash
while read line
do
echo $line > ./temptp4
group=$(cut -d "," -f 5 ./temptp4)
user=$(cut -d "," -f 1 ./temptp4)
mdp=$(cut -d "," -f 2 ./temptp4)
if grep -q $group /etc/group ; then
echo "ok"
else
groupadd $group
fi
useradd $user --create-home --groups $group --shell /bin/bash
chown $user /home/$user
(echo $mdp ; echo $mdp) | passwd $user
done < logins.csv
rm ./temptp4