deployUsers.sh
This commit is contained in:
parent
295c5cfe6f
commit
f927a18301
@ -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
|
||||
|
21
sisr1/tp04-scripts-admin/deployUsers.sh
Normal file
21
sisr1/tp04-scripts-admin/deployUsers.sh
Normal file
@ -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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user