diff --git a/sisr1/tp04-scripts-admin/createUser.sh b/sisr1/tp04-scripts-admin/createUser.sh index 7b3a7e3..09b1f6c 100644 --- a/sisr1/tp04-scripts-admin/createUser.sh +++ b/sisr1/tp04-scripts-admin/createUser.sh @@ -1,27 +1,17 @@ #!/bin/bash -fichier_a_lire=./login.csv - - +fichier_a_lire=./Users.csv while read ligne #définit la variable "ligne" comme le contenu de la ligne du fichier en cours de lecture do username=$(echo $ligne | cut -d ";" -f1) - usseradd -m -s "/bin/bash" $username - - - + useradd -m -s "/bin/bash" $username group=$(echo $ligne | cut -d "," -f5) usermod -aG $group $username - passwd=$(echo $ligne | cut -d ";" -f2) - - echo $username:$passwd | chpasswd - - chown $username:$username /home/$username - done < $fichier + done < $fichier_a_lire diff --git a/sisr1/tp04-scripts-admin/deployUsers.sh b/sisr1/tp04-scripts-admin/deployUsers.sh new file mode 100644 index 0000000..2d7fcd8 --- /dev/null +++ b/sisr1/tp04-scripts-admin/deployUsers.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +ip=$1 +workdir=/root/deploy + +ssh root@$ip "mkdir $workdir" 2> /dev/null + +scp createGroups.sh $user$ip:$workdir +scp createUser.sh $user$ip:$workdir +scp login.csv $user$ip:/root +scp Users.csv $user$ip:/root + +# exécution des scripts +ssh $user@$ip "bash $workdir/createGroups.sh" +ssh $user@$ip "bash $workdir/createUsers.sh" + + +ssh root@$ip "rm -R $workdir" # suppression répertoire et scripts + + +