From 6171fbe6dae724407b80777afba72389487b9ed7 Mon Sep 17 00:00:00 2001 From: "aboulai.bayo" Date: Mon, 24 Mar 2025 09:45:10 +0100 Subject: [PATCH] git push --- sisr1/tp04_scripts_admin/createGroups.sh | 1 + sisr1/tp04_scripts_admin/createUsers.sh | 2 +- sisr1/tp04_scripts_admin/deployUsers.sh | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 sisr1/tp04_scripts_admin/deployUsers.sh diff --git a/sisr1/tp04_scripts_admin/createGroups.sh b/sisr1/tp04_scripts_admin/createGroups.sh index 34837dc..c433356 100644 --- a/sisr1/tp04_scripts_admin/createGroups.sh +++ b/sisr1/tp04_scripts_admin/createGroups.sh @@ -4,6 +4,7 @@ fichier=Users.csv while read ligne # définit la variable "ligne" comme le contenu de la ligne du fichier en cours de lecture do metier=$(echo $ligne | cut -d "," -f5 ) #A chaque utilisateur itération,stocker le méttier + echo $metier if [[ $(grep $metier /etc/group) == "" ]] ; then groupadd $metier fi diff --git a/sisr1/tp04_scripts_admin/createUsers.sh b/sisr1/tp04_scripts_admin/createUsers.sh index 7d7d59c..044adfb 100644 --- a/sisr1/tp04_scripts_admin/createUsers.sh +++ b/sisr1/tp04_scripts_admin/createUsers.sh @@ -7,7 +7,7 @@ useradd -m -s "/bin/bash" $username group=$(echo $ligne | -d ";" -f5) usermod -aG $group $username - +#le mot de passe de l'utilisateur echo $username:$passwd | chpasswd chown $username:$username /home/$username diff --git a/sisr1/tp04_scripts_admin/deployUsers.sh b/sisr1/tp04_scripts_admin/deployUsers.sh new file mode 100644 index 0000000..a04f98c --- /dev/null +++ b/sisr1/tp04_scripts_admin/deployUsers.sh @@ -0,0 +1,18 @@ +#bin/bash + +ip=$1 #Ip de machine cible passé en paramètre +user=root +workdir=/root/deploy #répertoire déploiement + +ssh root@$ip "mkdir $workdir" 2> /dev/null #création du répertoire + +#copie de scripts et fichier +scp createGroups.sh $user@ip:$workdir +scp createUsers.sh $user@ip:$workdir +scp logins.csv $user@ip:$workdir +scp Users.scv $user@ip:$workdir + +ssh $user@ip "cd $workdir ; bash $workdir/createGroups.sh" +ssh $user@ip "bash $workdir/createUsers.sh" + +ssh root@ip "rm-R $workdir" #suppression \ No newline at end of file