From 4d1beb60d3016295d4bee223ec6cb68d44d61445 Mon Sep 17 00:00:00 2001 From: Guillaume Emorine Date: Mon, 12 Feb 2024 11:15:18 +0100 Subject: [PATCH] =?UTF-8?q?=09Nouveau=20fichier=C2=A0:=20sisr1/scripts/cre?= =?UTF-8?q?ateUsers.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sisr1/scripts/createUsers.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sisr1/scripts/createUsers.sh diff --git a/sisr1/scripts/createUsers.sh b/sisr1/scripts/createUsers.sh new file mode 100644 index 0000000..f3eaad6 --- /dev/null +++ b/sisr1/scripts/createUsers.sh @@ -0,0 +1,18 @@ +#!/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 + groupadd -f $usergroup + fi + useradd $user --create-home --groups $usergroup --shell /bin/bash + (echo $passwd ; echo $passwd) | passwd $user + chown -hR $user /home/$user + rm ./temptp4.txt +done < ./logins.csv