siotp/bts_annee_1/tp05_samba/deployment_samba.sh
2024-11-14 15:22:34 +01:00

19 lines
479 B
Bash

#!/bin/bash
while read line
do
touch ./temptp4.txt
file="./temptp4.txt"
echo $line > $file
user=$(cut -d "," -f 1 $file)
usergroup=$(cut -d "," -f 5 $file)
passwd=$(cut -d "," -f 2 $file)
if ! grep -q $usergroup /etc/group ; then
echo "Tentative de création du groupe"
groupadd "$usergroup"
fi
useradd $user -d /dev/null -s /bin/false
usermod -aG $usergroup $user
(echo $passwd ; echo $passwd) | smbpasswd -a $user
rm ./temptp4.txt
done < /root/files/logins.csv